 bpf: Fix stale offload-&gt;prog pointer after constant blinding · gregkh/linux@25484c3 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Copilot app Direct agents from issue to merge MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 732 Star 683 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 25484c3 Browse files Browse files MingTao Huang authored and gregkh committed bpf: Fix stale offload-&gt;prog pointer after constant blinding [ Upstream commit a1aa9ef ] When a dev-bound-only BPF program (BPF_F_XDP_DEV_BOUND_ONLY) undergoes JIT compilation with constant blinding enabled (bpf_jit_harden &gt;= 2), bpf_jit_blind_constants() clones the program. The original prog is then freed in bpf_jit_prog_release_other(), which updates aux-&gt;prog to point to the surviving clone, but fails to update offload-&gt;prog. This leaves offload-&gt;prog pointing to the freed original program. When the network namespace is subsequently destroyed, cleanup_net() triggers bpf_dev_bound_netdev_unregister(), which iterates ondev-&gt;progs and calls __bpf_prog_offload_destroy(offload-&gt;prog). Accessing the freed prog causes a page fault: BUG: unable to handle page fault for address: ffffc900085f1038 Workqueue: netns cleanup_net RIP: 0010:__bpf_prog_offload_destroy+0xc/0x80 Call Trace: __bpf_offload_dev_netdev_unregister+0x257/0x350 bpf_dev_bound_netdev_unregister+0x4a/0x90 unregister_netdevice_many_notify+0x2a2/0x660 ... cleanup_net+0x21a/0x320 The test sequence that triggers this reliably is: 1. Set net.core.bpf_jit_harden=2 (echo 2 &gt; /proc/sys/net/core/bpf_jit_harden) 2. Run xdp_metadata selftest, which creates a dev-bound-only XDP program on a veth inside a netns (./test_progs -t xdp_metadata) 3. cleanup_net -&gt; page fault in __bpf_prog_offload_destroy Dev-bound-only programs are unique in that they have an offload structure but go through the normal JIT path instead of bpf_prog_offload_compile(). This means they are subject to constant blinding's prog clone-and-replace, while also having offload-&gt;prog that must stay in sync. Fix this by updating offload-&gt;prog in bpf_jit_prog_release_other(), alongside the existing aux-&gt;prog update. Both are back-pointers to the prog that must be kept in sync when the prog is replaced. Fixes: 2b3486b ("bpf: Introduce device-bound XDP programs") Signed-off-by: MingTao Huang &lt;mintaohuang@tencent.com&gt; Link: https://lore.kernel.org/r/tencent_BCF692F45859CCE6C22B7B0B64827947D406@qq.com Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent 85a2f30 commit 25484c3 Copy full SHA for 25484c3 1 file changed + 2 Lines changed: 2 additions &amp; 0 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options kernel/bpf core.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ kernel/bpf/core.c ‎ Copy file name to clipboard Expand all lines: kernel/bpf/core.c + 2 Lines changed: 2 additions &amp; 0 deletions Original file line number Diff line number Diff line change @@ -1489,6 +1489,8 @@ void bpf_jit_prog_release_other(struct bpf_prog *fp, struct bpf_prog *fp_other) 1489 1489 * know whether fp here is the clone or the original. 1490 1490 */ 1491 1491 fp -&gt; aux -&gt; prog = fp ; 1492 + if ( fp -&gt; aux -&gt; offload ) 1493 + fp -&gt; aux -&gt; offload -&gt; prog = fp ; 1492 1494 bpf_prog_clone_free ( fp_other ); 1493 1495 } 1494 1496 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 