 bpf: Fix issue in verifying allow_ptr_leaks · gregkh/linux@c96c679 · 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 c96c679 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 b23c965 commit c96c679 Copy full SHA for c96c679 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 @@ -10401,6 +10401,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 10401 10401 return - EINVAL ; 10402 10402 } 10403 10403 10404 + /* check src2 operand */ 10405 + err = check_reg_arg ( env , insn -&gt; dst_reg , SRC_OP ); 10406 + if ( err ) 10407 + return err ; 10408 + 10409 + dst_reg = &amp; regs [ insn -&gt; dst_reg ]; 10404 10410 if ( BPF_SRC ( insn -&gt; code ) == BPF_X ) { 10405 10411 if ( insn -&gt; imm != 0 ) { 10406 10412 verbose ( env , &quot;BPF_JMP/JMP32 uses reserved fields\n&quot; ); @@ -10412,25 +10418,20 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, 10412 10418 if ( err ) 10413 10419 return err ; 10414 10420 10415 - if ( is_pointer_value ( env , insn -&gt; src_reg )) { 10421 + src_reg = &amp; regs [ insn -&gt; src_reg ]; 10422 + if (!( reg_is_pkt_pointer_any ( dst_reg ) &amp;&amp; reg_is_pkt_pointer_any ( src_reg )) &amp;&amp; 10423 + is_pointer_value ( env , insn -&gt; src_reg )) { 10416 10424 verbose ( env , &quot;R%d pointer comparison prohibited\n&quot; , 10417 10425 insn -&gt; src_reg ); 10418 10426 return - EACCES ; 10419 10427 } 10420 - src_reg = &amp; regs [ insn -&gt; src_reg ]; 10421 10428 } else { 10422 10429 if ( insn -&gt; src_reg != BPF_REG_0 ) { 10423 10430 verbose ( env , &quot;BPF_JMP/JMP32 uses reserved fields\n&quot; ); 10424 10431 return - EINVAL ; 10425 10432 } 10426 10433 } 10427 10434 10428 - /* check src2 operand */ 10429 - err = check_reg_arg ( env , insn -&gt; dst_reg , SRC_OP ); 10430 - if ( err ) 10431 - return err ; 10432 - 10433 - dst_reg = &amp; regs [ insn -&gt; dst_reg ]; 10434 10435 is_jmp32 = BPF_CLASS ( insn -&gt; code ) == BPF_JMP32 ; 10435 10436 10436 10437 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. 