From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F6423998B4 for ; Fri, 21 Aug 2026 07:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787299102; cv=none; b=XAkmXPo4I1ezLWf5gAyDZLUgOx/7TpFFroWcxJtf1rpG+vzpJeW7LvOzCpxld+y+hRF5HU4X8wl2A4zYeulnFMh3fxRIr9VvA5Nog3U/bpaCQq2ar77YS1cpAfdJr/USuJxHTEaJBis6FjHYOLkK8HgYSuN0uGv47UHIUENlSQA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787299102; c=relaxed/simple; bh=+zIe5NVPDKz8/Ej7QeLs9cHzLQjVNcAlMk5IFomQP7w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qrF1G3L2P61Jru4WBUcUajqUBpiK3BmHks9CsUcscD9o5Dax9MMAC9ddFtN/srM6bAG1Bj9VsVrSjZgAhiM6nMSxTGeIrVBdMwzI0JA8oVkYR1aG5qrI0wfetLYAlqZzd/4Uypb/UdCRGyRV12jQPa/lHeK8MPdHfvoPFljygOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KC/lqPVN; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KC/lqPVN" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2ccf2360620so5901425ad.3 for ; Fri, 21 Aug 2026 00:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787299101; x=1787903901; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=tGqZc2QCVfVmshUDzN/Ox9VPqNMMVTOEB7NVHdB7+5E=; b=KC/lqPVNo6ZzavEezjtZCjh/F53fKv7I2WSjrIZgBelEXaHCL8CQda/ioaAG9BOiSZ 5zA61YnQOgIPeCJQeNt5wmn6rXP9M/vvu/snes10iZMFOzR5l47rSfBaccdVTEnnMJxf FHbdg5h09+5THtTMSNaNgE1n49j7bEpEHSptxVivLzsaCjyvO8AQGGFy4wdL3FLUW9cW P6MYqdiIV00/St+Fq1+gS4HC5EszpL2iOUfkX7oqe1K55LwkvYIYz16ddW09GpIcWCOs BGiqkA5pvnshjdH11Zf9SDKYNaZyMjOf89qtUkJjxablsk+k+0XCfvv32lZB1eiTHv5m 2xew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787299101; x=1787903901; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=tGqZc2QCVfVmshUDzN/Ox9VPqNMMVTOEB7NVHdB7+5E=; b=rbabLICwQg8eD4wm4lBNRPRZzS7SJNbBkeFlYXSoE0DpnS/avYCtCKrW8O97OImzXv nVkcXvEHeuB7ldOcujsZ+80K+6VFxFaf0z8PlqY+ptTY8k3SNQOjtlh2LXkIPk1CpbAN b2ubQ+5pqbvf3i30Hon9N4AogVM5lD2ZT0RAldT4pZU6RkVAmqrQTSfAdiu8zHJE4qiH nE1HunqUSrOuaLTo1K4ozrPgvsfliyzsMrjgyn2wOXX02SLYIpDYpGWy5yoqPA9b+h4h Qf44zOwE/0hgCePM+wgdcCS+biurM4KKKsscWWjWvnle7KJMveJWHhyRrS9y1QeV9GEd SWBQ== X-Forwarded-Encrypted: i=1; AHgh+RpgxetksCJMHb+SFSdyqps9TFFhGPAtCFd/M4nBsnr4JrzpK6MjayE6IeTRKmm7DowjHSKlCTepbTm5I5o=@vger.kernel.org X-Gm-Message-State: AFuF++nFXMtXe8cpgsaaf8KkfDLOWmwn0N1ulL230a4iFdnN40/+Tw/d LqIEaDy8VFHoRURWRyiuxfWL9gYTfDzCA8kxUW7CnXtKx0TrwjO1/4l0F+wNiQ== X-Gm-Gg: AR+sD10sg5ccXRUVb7ebzOypYW5g7li9lnDv68r1xxBqd49qgg7/WAzD8duwnJso5KH lhh5cpMDxqSxWA1DXb4CBQ3DGDZo/bUDf5STbXsqfXXcshetv+qvT1nigsVutxKCDFuH9jlz42F 1karS2e1MVT3FlixKZghzt/TznkA+JH5Ji38zuBnLWuvsIjLTu7FSXI0IyyoS3J+vfdNMg0mmXp dHnMwBnQgJnNSLrM6ejPa8EE1Xjf9R//MdgSA9cfA6jU+xqkBvJK+o2jsSpVPg8nMwy3TQOFRLn zbsFP548DSaWyX00nnTYQC0fe76uQ88CdMB8zDpg9ShwyJUlV2bgOvgi03WZ2EVzyCA5U8qqjSH CsfUydUnGK2Z+eSt8XlwT4rR+qbOzE1dSE2NbHux4gySBgWvPqfxI/fyofh6PXRSYDkfaBPCXca OWnSYag3EcbqOMrjrVquohKFiRwyzzAQo9em9sNenA/dT2qUWEXGd7fCCT+c9RwxJHfw== X-Received: by 2002:a17:903:b4e:b0:2d0:8b28:51ab with SMTP id d9443c01a7336-2d64af3a1e9mr91546415ad.7.1787299100851; Fri, 21 Aug 2026 00:58:20 -0700 (PDT) Received: from omen-arch ([147.46.124.101]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d62e3cf99csm15290755ad.74.2026.08.21.00.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 00:58:20 -0700 (PDT) Date: Fri, 21 Aug 2026 16:58:11 +0900 From: Junseo Lim To: florent.revest@linux.dev Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , KP Singh , Emil Tsalapatis , John Fastabend , "Paul E. McKenney" , Jose Fernandez , linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf] bpf: Keep progs alive until the trampoline image calling them is freed Message-ID: References: <20260819122252.1782790-1-florent.revest@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Aug 20, 2026 at 04:06:30PM +0000, florent.revest@linux.dev wrote: > 20 août 2026 à 17:26 "Junseo Lim" a écrit: > > > > > On Wed, Aug 19, 2026 at 12:22:50PM +0000, Florent Revest (Anthropic) wrote: > > > > > > > > bpf_tramp_image_put() makes sure a trampoline image is not freed while > > > a task may still be running in it (call_rcu_tasks() + im->pcref), but > > > nothing similar is done for the progs called by that image. Since > > > commit e21aa341785c ("bpf: Fix fexit trampoline."), detach patches the > > > return path so that a task still in the original function skips the > > > fexit progs when it comes back, and counts on the prog's own RCU flavor > > > to cover a task that is inside a prog. On that basis the last prog > > > reference is dropped right away and the prog is freed after a single > > > RCU / RCU tasks trace grace period. > > > > > > [...] > > > > > > Fix it by having the image take a reference on every prog it calls, in > > > bpf_tramp_image_alloc(), and drop them in bpf_tramp_image_free(). A > > > detached prog now stays loaded until the old image is gone, which > > > reverts a deliberate choice of commit e21aa341785c ("bpf: Fix fexit > > > trampoline."). Detached fexit progs still stop being called right away > > > since the return path is patched. > > > > > This appears to be the same issue addressed by my earlier patch [1]. > > > > I think the flexible-array approach here is cleaner, so I'm fine with this > > version going forward. Could you please carry the original Reported-by tag? > > > > Reported-by: Sechang Lim > > > > [1] https://lore.kernel.org/bpf/20260815071927.147049-1-zirajs7@gmail.com/T/ > > > Oh wow, sorry, I had no idea we raced on this! > > I also like the idea of guarding this with CONFIG_PREEMPTION and of > course I don't mind adding your Reported-by tag in a v2. I'll give a bit > of time for others to chime in first. Just in case it helps with the CONFIG_PREEMPTION angle: Sashiko pointed out on my patch that a CONFIG_PREEMPTION guard would leave the unlink/update failure path uncovered on CONFIG_PREEMPTION=n. So your unconditional version looks right to me. Cheers, Junseo