 bpf: Fix issue in verifying allow_ptr_leaks · gregkh/linux@acfdc8b · 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 acfdc8b 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 a3199a1 commit acfdc8b Copy full SHA for acfdc8b 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 @@ -13816,6 +13816,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 13816 13816 return -EINVAL; 13817 13817 } 13818 13818 13819 + /* check src2 operand */ 13820 + err = check_reg_arg(env, insn-&gt;dst_reg, SRC_OP); 13821 + if (err) 13822 + return err; 13823 + 13824 + dst_reg = &amp;regs[insn-&gt;dst_reg]; 13819 13825 if (BPF_SRC(insn-&gt;code) == BPF_X) { 13820 13826 if (insn-&gt;imm != 0) { 13821 13827 verbose(env, &quot;BPF_JMP/JMP32 uses reserved fields\n&quot;); @@ -13827,25 +13833,20 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 13827 13833 if (err) 13828 13834 return err; 13829 13835 13830 - if (is_pointer_value(env, insn-&gt;src_reg)) { 13836 + src_reg = &amp;regs[insn-&gt;src_reg]; 13837 + if (!(reg_is_pkt_pointer_any(dst_reg) &amp;&amp; reg_is_pkt_pointer_any(src_reg)) &amp;&amp; 13838 + is_pointer_value(env, insn-&gt;src_reg)) { 13831 13839 verbose(env, &quot;R%d pointer comparison prohibited\n&quot;, 13832 13840 insn-&gt;src_reg); 13833 13841 return -EACCES; 13834 13842 } 13835 - src_reg = &amp;regs[insn-&gt;src_reg]; 13836 13843 } else { 13837 13844 if (insn-&gt;src_reg != BPF_REG_0) { 13838 13845 verbose(env, &quot;BPF_JMP/JMP32 uses reserved fields\n&quot;); 13839 13846 return -EINVAL; 13840 13847 } 13841 13848 } 13842 13849 13843 - /* check src2 operand */ 13844 - err = check_reg_arg(env, insn-&gt;dst_reg, SRC_OP); 13845 - if (err) 13846 - return err; 13847 - 13848 - dst_reg = &amp;regs[insn-&gt;dst_reg]; 13849 13850 is_jmp32 = BPF_CLASS(insn-&gt;code) == BPF_JMP32; 13850 13851 13851 13852 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. 