 bpf: Silence a warning in btf_type_id_size() · gregkh/linux@7c4f5ab · 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 7c4f5ab Browse files Browse files yonghong-song authored and gregkh committed bpf: Silence a warning in btf_type_id_size() [ Upstream commit e6c2f59 ] 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; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent 79e4371 commit 7c4f5ab Copy full SHA for 7c4f5ab 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 @@ -485,25 +485,26 @@ static bool btf_type_is_fwd(const struct btf_type *t) 485 485 return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_FWD ; 486 486 } 487 487 488 - static bool btf_type_nosize ( const struct btf_type * t ) 488 + static bool btf_type_is_datasec ( const struct btf_type * t ) 489 489 { 490 - return btf_type_is_void ( t ) || btf_type_is_fwd ( t ) || 491 - btf_type_is_func ( t ) || btf_type_is_func_proto ( t ); 490 + return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DATASEC ; 492 491 } 493 492 494 - static bool btf_type_nosize_or_null ( const struct btf_type * t ) 493 + static bool btf_type_is_decl_tag ( const struct btf_type * t ) 495 494 { 496 - return ! t || btf_type_nosize ( t ) ; 495 + return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DECL_TAG ; 497 496 } 498 497 499 - static bool btf_type_is_datasec ( const struct btf_type * t ) 498 + static bool btf_type_nosize ( const struct btf_type * t ) 500 499 { 501 - return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DATASEC ; 500 + return btf_type_is_void ( t ) || btf_type_is_fwd ( t ) || 501 + btf_type_is_func ( t ) || btf_type_is_func_proto ( t ) || 502 + btf_type_is_decl_tag ( t ); 502 503 } 503 504 504 - static bool btf_type_is_decl_tag ( const struct btf_type * t ) 505 + static bool btf_type_nosize_or_null ( const struct btf_type * t ) 505 506 { 506 - return BTF_INFO_KIND ( t -&gt; info ) == BTF_KIND_DECL_TAG ; 507 + return ! t || btf_type_nosize ( t ) ; 507 508 } 508 509 509 510 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. 