On 7/21/24 3:45 PM, Amery Hung wrote:
On Sat, Jul 20, 2024 at 7:45 AM kernel test robot <lkp@xxxxxxxxx> wrote:
Hi Martin,
kernel test robot noticed the following build warnings:
[auto build test WARNING on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Martin-KaFai-Lau/bpf-Check-unsupported-ops-from-the-bpf_struct_ops-s-cfi_stubs/20240720-144313
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20240720062233.2319723-2-martin.lau%40linux.dev
patch subject: [PATCH bpf-next 1/3] bpf: Check unsupported ops from the bpf_struct_ops's cfi_stubs
config: i386-randconfig-001-20240720 (https://download.01.org/0day-ci/archive/20240720/202407202244.HvnUVyjM-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240720/202407202244.HvnUVyjM-lkp@xxxxxxxxx/reproduce)
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 <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407202244.HvnUVyjM-lkp@xxxxxxxxx/
All warnings (new ones prefixed by >>):
kernel/bpf/bpf_struct_ops.c: In function 'bpf_struct_ops_supported':
kernel/bpf/bpf_struct_ops.c:1045:48: warning: dereferencing 'void *' pointer
void *func_ptr = *(void **)(&st_ops->cfi_stubs[moff]);
^
vim +1045 kernel/bpf/bpf_struct_ops.c
1042
1043 int bpf_struct_ops_supported(const struct bpf_struct_ops *st_ops, u32 moff)
1044 {
1045 void *func_ptr = *(void **)(&st_ops->cfi_stubs[moff]);
The compiler warning can be fixed with:
void *func_ptr = *(void **)(st_ops->cfi_stubs + moff);
The patch looks good to me. I tested it with bpf qdisc, and it does
what it is supposed to do by prohibiting users to attach to an
operator whose cfi stub is not defined.
Thanks for testing. I just tried gcc and can repro it. I will respin.