 bpf: Fix issue in verifying allow_ptr_leaks · gregkh/linux@5927f01 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts 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 676 Star 636 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 5927f01 Browse files Browse files laoar authored and gregkh committed bpf: Fix issue in verifying allow_ptr_leaks commit d75e30d upstream. After we converted the capabilities of our networking-bpf program from cap_sys_admin to cap_net_admin+cap_bpf, our networking-bpf program failed to start. Because it failed the bpf verifier, and the error log is "R3 pointer comparison prohibited". A simple reproducer as follows, SEC("cls-ingress") int ingress(struct __sk_buff *skb) { struct iphdr *iph = (void *)(long)skb-&gt;data + sizeof(struct ethhdr); if ((long)(iph + 1) &gt; (long)skb-&gt;data_end) return TC_ACT_STOLEN; return TC_ACT_OK; } Per discussion with Yonghong and Alexei [1], comparison of two packet pointers is not a pointer leak. This patch fixes it. Our local kernel is 6.1.y and we expect this fix to be backported to 6.1.y, so stable is CCed. [1]. https://lore.kernel.org/bpf/CAADnVQ+Nmspr7Si+pxWn8zkE7hX-7s93ugwC+94aXSy4uQ9vBg@mail.gmail.com/ Suggested-by: Yonghong Song &lt;yonghong.song@linux.dev&gt; Suggested-by: Alexei Starovoitov &lt;alexei.starovoitov@gmail.com&gt; Signed-off-by: Yafang Shao &lt;laoar.shao@gmail.com&gt; Acked-by: Eduard Zingerman &lt;eddyz87@gmail.com&gt; Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230823020703.3790-2-laoar.shao@gmail.com Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt; Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt; 1 parent 247ee56 commit 5927f01 Copy full SHA for 5927f01 1 file changed + 9 - 8 Lines changed: 9 additions &amp; 8 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options kernel/bpf verifier.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ kernel/bpf/verifier.c ‎ Copy file name to clipboard Expand all lines: kernel/bpf/verifier.c + 9 - 8 Lines changed: 9 additions &amp; 8 deletions Original file line number Diff line number Diff line change @@ -13597,6 +13597,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 13597 13597 return -EINVAL; 13598 13598 } 13599 13599 13600 + /* check src2 operand */ 13601 + err = check_reg_arg(env, insn-&gt;dst_reg, SRC_OP); 13602 + if (err) 13603 + return err; 13604 + 13605 + dst_reg = &amp;regs[insn-&gt;dst_reg]; 13600 13606 if (BPF_SRC(insn-&gt;code) == BPF_X) { 13601 13607 if (insn-&gt;imm != 0) { 13602 13608 verbose(env, &quot;BPF_JMP/JMP32 uses reserved fields\n&quot;); @@ -13608,25 +13614,20 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 13608 13614 if (err) 13609 13615 return err; 13610 13616 13611 - if (is_pointer_value(env, insn-&gt;src_reg)) { 13617 + src_reg = &amp;regs[insn-&gt;src_reg]; 13618 + if (!(reg_is_pkt_pointer_any(dst_reg) &amp;&amp; reg_is_pkt_pointer_any(src_reg)) &amp;&amp; 13619 + is_pointer_value(env, insn-&gt;src_reg)) { 13612 13620 verbose(env, &quot;R%d pointer comparison prohibited\n&quot;, 13613 13621 insn-&gt;src_reg); 13614 13622 return -EACCES; 13615 13623 } 13616 - src_reg = &amp;regs[insn-&gt;src_reg]; 13617 13624 } else { 13618 13625 if (insn-&gt;src_reg != BPF_REG_0) { 13619 13626 verbose(env, &quot;BPF_JMP/JMP32 uses reserved fields\n&quot;); 13620 13627 return -EINVAL; 13621 13628 } 13622 13629 } 13623 13630 13624 - /* check src2 operand */ 13625 - err = check_reg_arg(env, insn-&gt;dst_reg, SRC_OP); 13626 - if (err) 13627 - return err; 13628 - 13629 - dst_reg = &amp;regs[insn-&gt;dst_reg]; 13630 13631 is_jmp32 = BPF_CLASS(insn-&gt;code) == BPF_JMP32; 13631 13632 13632 13633 if (BPF_SRC(insn-&gt;code) == BPF_K) { 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. 