Re: [PATCH 07/14] bpf: Implement BPF_LOAD_FD subcommand handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Blaise,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf/master]
[also build test WARNING on linus/master v6.13-rc6]
[cannot apply to bpf-next/master next-20250110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Blaise-Boscaccy/bpf-Add-data-structures-for-managing-in-kernel-eBPF-relocations/20250110-064354
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
patch link:    https://lore.kernel.org/r/20250109214617.485144-8-bboscaccy%40linux.microsoft.com
patch subject: [PATCH 07/14] bpf: Implement BPF_LOAD_FD subcommand handler
config: i386-buildonly-randconfig-003-20250111 (https://download.01.org/0day-ci/archive/20250111/202501110812.QzSvbAtK-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250111/202501110812.QzSvbAtK-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/202501110812.QzSvbAtK-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

   kernel/bpf/syscall.c: In function 'load_fd':
>> kernel/bpf/syscall.c:6290:47: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    6290 |                 if (copy_from_user(obj->maps, (const void *)attr->load_fd.maps,
         |                                               ^
   kernel/bpf/syscall.c:6310:45: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    6310 |                 if (copy_from_user(modules, (const void *)attr->load_fd.modules,
         |                                             ^
   kernel/bpf/syscall.c: At top level:
   kernel/bpf/syscall.c:6092:1: warning: 'skip_mods_and_typedefs' defined but not used [-Wunused-function]
    6092 | skip_mods_and_typedefs(const struct btf *btf, u32 id, u32 *res_id)
         | ^~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/syscall.c:6082:13: warning: 'sym_is_extern' defined but not used [-Wunused-function]
    6082 | static bool sym_is_extern(const Elf64_Sym *sym)
         |             ^~~~~~~~~~~~~
   kernel/bpf/syscall.c:6056:12: warning: 'find_extern_sec_btf_id' defined but not used [-Wunused-function]
    6056 | static int find_extern_sec_btf_id(struct btf *btf, int ext_btf_id)
         |            ^~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/syscall.c:6016:12: warning: 'find_extern_btf_id' defined but not used [-Wunused-function]
    6016 | static int find_extern_btf_id(const struct btf *btf, const char *ext_name)
         |            ^~~~~~~~~~~~~~~~~~
   kernel/bpf/syscall.c:5998:12: warning: 'elf_sec_idx_by_name' defined but not used [-Wunused-function]
    5998 | static int elf_sec_idx_by_name(struct bpf_obj *obj, const char *name)
         |            ^~~~~~~~~~~~~~~~~~~
   kernel/bpf/syscall.c:5948:24: warning: 'btf_ext__new' defined but not used [-Wunused-function]
    5948 | static struct btf_ext *btf_ext__new(const __u8 *data, __u32 size)
         |                        ^~~~~~~~~~~~


vim +6290 kernel/bpf/syscall.c

  6233	
  6234	static int load_fd(union bpf_attr *attr)
  6235	{
  6236		void *buf = NULL;
  6237		int len;
  6238		int i;
  6239		int obj_f;
  6240		struct fd obj_fd;
  6241		struct bpf_module_obj *modules;
  6242		struct bpf_obj *obj;
  6243		int err;
  6244	
  6245		struct fd f;
  6246		struct fd bpffs_fd;
  6247	
  6248		f = fdget(attr->load_fd.obj_fd);
  6249		if (!fd_file(f)) {
  6250			err = -EBADF;
  6251			goto out;
  6252		}
  6253	
  6254		bpffs_fd = fdget(attr->load_fd.bpffs_fd);
  6255		if (!fd_file(bpffs_fd)) {
  6256			fdput(f);
  6257			err = -EBADF;
  6258			goto out;
  6259		}
  6260	
  6261		obj_f = loader_create(attr->load_fd.bpffs_fd);
  6262		if (obj_f < 0) {
  6263			err = obj_f;
  6264			fdput(f);
  6265			fdput(bpffs_fd);
  6266			goto out;
  6267		}
  6268	
  6269		obj_fd = fdget(obj_f);
  6270		obj = fd_file(obj_fd)->private_data;
  6271	
  6272		len = kernel_read_file(fd_file(f), 0, &buf, INT_MAX, NULL, READING_EBPF);
  6273		if (len < 0) {
  6274			fdput(obj_fd);
  6275			err = len;
  6276			goto out;
  6277		}
  6278	
  6279		obj->hdr = buf;
  6280		obj->len = len;
  6281		obj->nr_maps = attr->load_fd.map_cnt;
  6282		obj->maps = kmalloc_array(attr->load_fd.map_cnt, sizeof(struct bpf_map_obj), GFP_KERNEL);
  6283	
  6284		if (!obj->maps) {
  6285			err = -ENOMEM;
  6286			goto free;
  6287		}
  6288	
  6289		if (attr->load_fd.map_cnt) {
> 6290			if (copy_from_user(obj->maps, (const void *)attr->load_fd.maps,
  6291					   sizeof(struct bpf_map_obj) * attr->load_fd.map_cnt) != 0) {
  6292				err = -EFAULT;
  6293				goto free;
  6294			}
  6295		}
  6296	
  6297		obj->kconfig_map_idx = attr->load_fd.kconfig_map_idx;
  6298		obj->arena_map_idx = attr->load_fd.arena_map_idx;
  6299		obj->btf_vmlinux = bpf_get_btf_vmlinux();
  6300		modules = kmalloc_array(attr->load_fd.module_cnt,
  6301					sizeof(struct bpf_module_obj), GFP_KERNEL);
  6302	
  6303		if (!modules) {
  6304			err = -ENOMEM;
  6305			goto free;
  6306		}
  6307	
  6308	
  6309		if (attr->load_fd.module_cnt) {
  6310			if (copy_from_user(modules, (const void *)attr->load_fd.modules,
  6311					   sizeof(struct bpf_module_obj) * attr->load_fd.module_cnt) != 0) {
  6312				err = -EFAULT;
  6313				goto free;
  6314			}
  6315		}
  6316	
  6317		obj->btf_modules_cnt = attr->load_fd.module_cnt;
  6318		obj->btf_modules = kmalloc_array(attr->load_fd.module_cnt,
  6319						 sizeof(struct bpf_module_btf), GFP_KERNEL);
  6320	
  6321		if (!obj->btf_modules) {
  6322			err = -ENOMEM;
  6323			goto free;
  6324		}
  6325	
  6326		for (i = 0; i < obj->btf_modules_cnt; i++) {
  6327			obj->btf_modules[i].fd = modules[i].fd;
  6328			obj->btf_modules[i].id = modules[i].id;
  6329			obj->btf_modules[i].fd_array_idx = modules[i].fd_array_idx;
  6330			obj->btf_modules[i].btf = btf_get_by_fd(obj->btf_modules[i].fd);
  6331			if (IS_ERR(obj->btf_modules[i].btf)) {
  6332				err = PTR_ERR(obj->btf_modules[i].btf);
  6333				kfree(modules);
  6334				goto free;
  6335			}
  6336		}
  6337		kfree(modules);
  6338	
  6339		return obj_f;
  6340	free:
  6341		free_bpf_obj(obj);
  6342		fd_file(obj_fd)->private_data = NULL;
  6343	out:
  6344		return err;
  6345	}
  6346	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux