 bpf: Fix issue in verifying allow_ptr_leaks · gregkh/linux@d75e30d · 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 d75e30d Browse files Browse files laoar authored and Alexei Starovoitov committed bpf: Fix issue in verifying allow_ptr_leaks 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; 1 parent 29d67fd commit d75e30d Copy full SHA for d75e30d 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 @@ -14041,6 +14041,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 14041 14041 return -EINVAL; 14042 14042 } 14043 14043 14044 + /* check src2 operand */ 14045 + err = check_reg_arg(env, insn-&gt;dst_reg, SRC_OP); 14046 + if (err) 14047 + return err; 14048 + 14049 + dst_reg = &amp;regs[insn-&gt;dst_reg]; 14044 14050 if (BPF_SRC(insn-&gt;code) == BPF_X) { 14045 14051 if (insn-&gt;imm != 0) { 14046 14052 verbose(env, &quot;BPF_JMP/JMP32 uses reserved fields\n&quot;); @@ -14052,25 +14058,20 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 14052 14058 if (err) 14053 14059 return err; 14054 14060 14055 - if (is_pointer_value(env, insn-&gt;src_reg)) { 14061 + src_reg = &amp;regs[insn-&gt;src_reg]; 14062 + if (!(reg_is_pkt_pointer_any(dst_reg) &amp;&amp; reg_is_pkt_pointer_any(src_reg)) &amp;&amp; 14063 + is_pointer_value(env, insn-&gt;src_reg)) { 14056 14064 verbose(env, &quot;R%d pointer comparison prohibited\n&quot;, 14057 14065 insn-&gt;src_reg); 14058 14066 return -EACCES; 14059 14067 } 14060 - src_reg = &amp;regs[insn-&gt;src_reg]; 14061 14068 } else { 14062 14069 if (insn-&gt;src_reg != BPF_REG_0) { 14063 14070 verbose(env, &quot;BPF_JMP/JMP32 uses reserved fields\n&quot;); 14064 14071 return -EINVAL; 14065 14072 } 14066 14073 } 14067 14074 14068 - /* check src2 operand */ 14069 - err = check_reg_arg(env, insn-&gt;dst_reg, SRC_OP); 14070 - if (err) 14071 - return err; 14072 - 14073 - dst_reg = &amp;regs[insn-&gt;dst_reg]; 14074 14075 is_jmp32 = BPF_CLASS(insn-&gt;code) == BPF_JMP32; 14075 14076 14076 14077 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. 