Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Add a verbose message when the BTF limit is reached

When a BPF program which is being loaded reaches the map limit
(MAX_USED_MAPS) or the BTF limit (MAX_USED_BTFS) the -E2BIG is
returned. However, in the former case there is an accompanying
verifier verbose message, and in the latter case there is not.
Add a verbose message to make the behaviour symmetrical.

Reported-by: Kevin Sheldrake <kevin.sheldrake@isovalent.com>
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20250816151554.902995-1-a.s.protopopov@gmail.com

authored by

Anton Protopopov and committed by
Daniel Borkmann
dbe99ea5 d87fdb1f

+4 -1
+4 -1
kernel/bpf/verifier.c
··· 20193 20193 if (env->used_btfs[i].btf == btf) 20194 20194 return i; 20195 20195 20196 - if (env->used_btf_cnt >= MAX_USED_BTFS) 20196 + if (env->used_btf_cnt >= MAX_USED_BTFS) { 20197 + verbose(env, "The total number of btfs per program has reached the limit of %u\n", 20198 + MAX_USED_BTFS); 20197 20199 return -E2BIG; 20200 + } 20198 20201 20199 20202 btf_get(btf); 20200 20203