Since there're 4 bytes padding at the end of struct bpf_map_info, they won't be checked by bpf_check_uarg_tail_zero(). pahole -C bpf_map_info ./vmlinux struct bpf_map_info { ... __u64 hash __attribute__((__aligned__(8))); /* 88 8 */ __u32 hash_size; /* 96 4 */ /* size: 104, cachelines: 2, members: 18 */ /* padding: 4 */ /* forced alignments: 1 */ /* last cacheline: 40 bytes */ } __attribute__((__aligned__(8))); If a future kernel extension adds a new 4-byte field, older userspace programs allocating this structure on the stack might inadvertently pass uninitialized stack garbage into the new field, permanently breaking backward compatibility. -- sashiko [1] Fix it by changing sizeof(info) to offsetofend(struct bpf_map_info, hash_size). And, add "__u32 :32" to the tail of struct bpf_map_info. [1] https://lore.kernel.org/bpf/20260513224823.6494FC19425@smtp.kernel.org/
Showing the changes to tools/include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -6733,6 +6733,7 @@ struct bpf_map_info { · 6732 unmodified lines | |||
| 6733 | __u64 map_extra; | 6733 | __u64 map_extra; |
| 6734 | __aligned_u64 hash; | 6734 | __aligned_u64 hash; |
| 6735 | __u32 hash_size; | 6735 | __u32 hash_size; |
| 6736 | __u32 :32; | ||
| 6736 | } __attribute__((aligned(8))); | 6737 | } __attribute__((aligned(8))); |
| 6737 | 6738 | ||
| 6738 | struct bpf_btf_info { | 6739 | struct bpf_btf_info { |