 bpf: Silence a warning in btf_type_id_size() · gregkh/linux@e6c2f59 · 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 e6c2f59 Browse files Browse files yonghong-song authored and Martin KaFai Lau committed bpf: Silence a warning in btf_type_id_size() syzbot reported a warning in [1] with the following stacktrace: WARNING: CPU: 0 PID: 5005 at kernel/bpf/btf.c:1988 btf_type_id_size+0x2d9/0x9d0 kernel/bpf/btf.c:1988 ... RIP: 0010:btf_type_id_size+0x2d9/0x9d0 kernel/bpf/btf.c:1988 ... Call Trace: &lt;TASK&gt; map_check_btf kernel/bpf/syscall.c:1024 [inline] map_create+0x1157/0x1860 kernel/bpf/syscall.c:1198 __sys_bpf+0x127f/0x5420 kernel/bpf/syscall.c:5040 __do_sys_bpf kernel/bpf/syscall.c:5162 [inline] __se_sys_bpf kernel/bpf/syscall.c:5160 [inline] __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5160 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd With the following btf [1] DECL_TAG 'a' type_id=4 component_idx=-1 [2] PTR '(anon)' type_id=0 [3] TYPE_TAG 'a' type_id=2 [4] VAR 'a' type_id=3, linkage=static and when the bpf_attr.btf_key_type_id = 1 (DECL_TAG), the following WARN_ON_ONCE in btf_type_id_size() is triggered: if (WARN_ON_ONCE(!btf_type_is_modifier(size_type) &amp;&amp; !btf_type_is_var(size_type))) return NULL; Note that 'return NULL' is the correct behavior as we don't want a DECL_TAG type to be used as a btf_{key,value}_type_id even for the case like 'DECL_TAG -&gt; STRUCT'. So there is no correctness issue here, we just want to silence warning. To silence the warning, I added DECL_TAG as one of kinds in btf_type_nosize() which will cause btf_type_id_size() returning NULL earlier without the warning. [1] https://lore.kernel.org/bpf/000000000000e0df8d05fc75ba86@google.com/ Reported-by: syzbot+958967f249155967d42a@syzkaller.appspotmail.com Signed-off-by: Yonghong Song &lt;yhs@fb.com&gt; Link: https://lore.kernel.org/r/20230530205029.264910-1-yhs@fb.com Signed-off-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt; 1 parent bc590b4 commit e6c2f59 Copy full SHA for e6c2f59 1 file changed + 10 - 9 Lines changed: 10 additions &amp; 9 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options kernel/bpf btf.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ kernel/bpf/btf.c ‎ Copy file name to clipboard Expand all lines: kernel/bpf/btf.c + 10 - 9 Lines changed: 10 additions &amp; 9 deletions Original file line number Diff line number Diff line change @@ -492,25 +492,26 @@ static bool btf_type_is_fwd(const struct btf_type *t) 492 492 return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_FWD ; 493 493 } 494 494 495 - static bool btf_type_nosize ( const struct btf_type * t ) 495 + static bool btf_type_is_datasec ( const struct btf_type * t ) 496 496 { 497 - return btf_type_is_void ( t ) || btf_type_is_fwd ( t ) || 498 - btf_type_is_func ( t ) || btf_type_is_func_proto ( t ); 497 + return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DATASEC ; 499 498 } 500 499 501 - static bool btf_type_nosize_or_null ( const struct btf_type * t ) 500 + static bool btf_type_is_decl_tag ( const struct btf_type * t ) 502 501 { 503 - return ! t || btf_type_nosize ( t ) ; 502 + return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DECL_TAG ; 504 503 } 505 504 506 - static bool btf_type_is_datasec ( const struct btf_type * t ) 505 + static bool btf_type_nosize ( const struct btf_type * t ) 507 506 { 508 - return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DATASEC ; 507 + return btf_type_is_void ( t ) || btf_type_is_fwd ( t ) || 508 + btf_type_is_func ( t ) || btf_type_is_func_proto ( t ) || 509 + btf_type_is_decl_tag ( t ); 509 510 } 510 511 511 - static bool btf_type_is_decl_tag ( const struct btf_type * t ) 512 + static bool btf_type_nosize_or_null ( const struct btf_type * t ) 512 513 { 513 - return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DECL_TAG ; 514 + return ! t || btf_type_nosize ( t ) ; 514 515 } 515 516 516 517 static bool btf_type_is_decl_tag_target ( const struct btf_type * t ) 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. 