Hi, On 10/13/2024 9:08 PM, Dan Carpenter wrote: > Hi Hou, > > kernel test robot noticed the following build warnings: > > url: https://github.com/intel-lab-lkp/linux/commits/Hou-Tao/bpf-Introduce-map-flag-BPF_F_DYNPTR_IN_KEY/20241008-171136 > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > patch link: https://lore.kernel.org/r/20241008091501.8302-9-houtao%40huaweicloud.com > patch subject: [PATCH bpf-next 08/16] bpf: Handle bpf_dynptr_user in bpf syscall when it is used as input > config: x86_64-randconfig-161-20241011 (https://download.01.org/0day-ci/archive/20241012/202410120530.zUoa1scp-lkp@xxxxxxxxx/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > > 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> > | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > | Closes: https://lore.kernel.org/r/202410120530.zUoa1scp-lkp@xxxxxxxxx/ > > smatch warnings: > kernel/bpf/syscall.c:1557 bpf_copy_from_dynptr_ukey() warn: 'key' is an error pointer or valid > > vim +/key +1557 kernel/bpf/syscall.c > > e1883aa78ac1fe9 Hou Tao 2024-10-08 1543 static void *bpf_copy_from_dynptr_ukey(const struct bpf_map *map, bpfptr_t ukey) > e1883aa78ac1fe9 Hou Tao 2024-10-08 1544 { > e1883aa78ac1fe9 Hou Tao 2024-10-08 1545 const struct btf_record *record; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1546 const struct btf_field *field; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1547 struct bpf_dynptr_user *uptr; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1548 struct bpf_dynptr_kern *kptr; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1549 void *key, *new_key, *kdata; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1550 unsigned int key_size, size; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1551 bpfptr_t udata; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1552 unsigned int i; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1553 int err; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1554 > e1883aa78ac1fe9 Hou Tao 2024-10-08 1555 key_size = map->key_size; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1556 key = kvmemdup_bpfptr(ukey, key_size); > e1883aa78ac1fe9 Hou Tao 2024-10-08 @1557 if (!key) > > This should be if (IS_ERR(key)) Thanks for the report. You are right, the check of key which is returned by kvmemdup_bpfptr is incorrect(). Will fix it in the next revision and will try to add some test cases for these error paths. > > e1883aa78ac1fe9 Hou Tao 2024-10-08 1558 return ERR_PTR(-ENOMEM); > e1883aa78ac1fe9 Hou Tao 2024-10-08 1559 > e1883aa78ac1fe9 Hou Tao 2024-10-08 1560 size = key_size; > e1883aa78ac1fe9 Hou Tao 2024-10-08 1561 record = map->key_record; >