summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2026-10-17 16:37:20 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-10-17 22:01:13 +0000
commit13ac7c05bc45d3445b580da186548dd3487fae4e (patch)
treea83a56b602f8db48d510dabe3122a9032c3971f0 /include/linux
parent070a96b2a98f66087797d8a31d53126de7a5208f (diff)
downloadlinux-13ac7c05bc45d3445b580da186548dd3487fae4e.tar.gz
linux-13ac7c05bc45d3445b580da186548dd3487fae4e.zip
bpf: Bound the nesting that the BTF show code follows
btf_struct_show() and btf_array_show() recurse for every nested struct and array. MAX_RESOLVE_DEPTH bounds one resolve walk when BTF is loaded, not the nesting: a member whose type is resolved already is not walked again, so BTF that defines its types from the inside out can nest them as deep as it has types. Whoever may load BTF, with CAP_BPF or a BPF token, can give such a type to the value of a map. Reading the file of that map in bpffs then overruns the kernel stack: with a few hundred levels the stack guard page is hit and the kernel panics. Stop at 32 levels. That is MAX_RESOLVE_DEPTH, and __btf_show_indent() has as many columns. Nothing is shown for a member that lies deeper, and the status becomes -E2BIG, which bpf_snprintf_btf() and bpf_seq_printf_btf() return. The types of an x86_64 defconfig kernel nest 14 deep. Fixes: b00b8daec828 ("bpf: btf: Add pretty print capability for data with BTF type info") Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261017163745.3341787-19-alexei.starovoitov@gmail.com
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions