kernel/bpf/coro.c:143 bpf_coro_frame_class() error: buffer overflow 'small' 8 <= 576460752303423487
kernel test robot
build botUnfiltered warning: this smatch report is sent as-is and has not been reviewed for false positives, so please treat it with due skepticism.
BCC: [email protected]
CC: [email protected]
TO: Kumar Kartikeya Dwivedi <[email protected]>
tree: https://github.com/kkdwivedi/linux fermata head: 1d98f92a7b37670e804415b13c1d5d039706d4ce commit: 4d3cd4b6be701549f74ad943124f4ed5bef27765 [254/348] bpf: Keep the coroutine frames that a program frees for its next ones
:::::: branch date: 9 hours ago
:::::: commit date: 11 hours ago
config: arm64-randconfig-2200-20261127 (https://download.01.org/0day-ci/archive/20261127/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 578b1f2d6a9776b63cbb6b86f4cca6208d429f48)
smatch: v0.5.0-9187-g5189e3fb
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:kernel/bpf/coro.c:143 bpf_coro_frame_class() error: buffer overflow 'small' 8 <= 576460752303423487
vim +/small +143 kernel/bpf/coro.c
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 131
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 132 static_assert(sizeof(struct bpf_coro_frame_hdr) + BPF_MAX_REF_SLOTS * BPF_REG_SIZE <= 1024);
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 133 static_assert(BPF_CORO_FRAME_CLASSES <=
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 134 BITS_PER_TYPE(typeof_member(struct bpf_prog_aux, coro_classes)));
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 135
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 136 /* @size is that of the header and the frame */
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 137 static unsigned int bpf_coro_frame_class(size_t size)
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 138 {
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 139 /* in steps of 32 bytes up to 256 */
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 140 static const u8 small[] = { 1, 2, 3, 4, 5, 5, 6, 6 };
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 141
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 142 if (size <= 256)
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 @143 return small[(size - 1) / 32];
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 144 return size <= 512 ? 7 : 8;
4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 145 }4d3cd4b6be7015 Kumar Kartikeya Dwivedi 2026-11-26 146
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki