Re: [PATCH bpf-next 1/8] bpf: Enable annotating trusted nested pointers

From: David Vernet
Date: Thu Jan 19 2023 - 21:28:03 EST


On Fri, Jan 20, 2023 at 09:14:25AM +0800, kernel test robot wrote:
> Hi David,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on bpf-next/master]
>
> url: https://github.com/intel-lab-lkp/linux/commits/David-Vernet/bpf-Enable-annotating-trusted-nested-pointers/20230120-080139
> base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
> patch link: https://lore.kernel.org/r/20230119235833.2948341-2-void%40manifault.com
> patch subject: [PATCH bpf-next 1/8] bpf: Enable annotating trusted nested pointers
> config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230120/202301200957.At49rpzu-lkp@xxxxxxxxx/config)
> compiler: ia64-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/intel-lab-lkp/linux/commit/8f6df14342b1be3516f8e21037edf771df851427
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review David-Vernet/bpf-Enable-annotating-trusted-nested-pointers/20230120-080139
> git checkout 8f6df14342b1be3516f8e21037edf771df851427
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash kernel/bpf/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
> >> kernel/bpf/btf.c:533:5: warning: no previous prototype for 'bpf_find_btf_id' [-Wmissing-prototypes]
> 533 | s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p)

Silly mistake on my part. I removed static while debugging something in
verifier.c and forgot to put it back. I'll put it back in v2.

> | ^~~~~~~~~~~~~~~
> kernel/bpf/btf.c: In function 'btf_seq_show':
> kernel/bpf/btf.c:6977:29: warning: function 'btf_seq_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 6977 | seq_vprintf((struct seq_file *)show->target, fmt, args);
> | ^~~~~~~~
> kernel/bpf/btf.c: In function 'btf_snprintf_show':
> kernel/bpf/btf.c:7014:9: warning: function 'btf_snprintf_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 7014 | len = vsnprintf(show->target, ssnprintf->len_left, fmt, args);
> | ^~~
>
>
> vim +/bpf_find_btf_id +533 kernel/bpf/btf.c
>
> 532
> > 533 s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p)
> 534 {
> 535 struct btf *btf;
> 536 s32 ret;
> 537 int id;
> 538
> 539 btf = bpf_get_btf_vmlinux();
> 540 if (IS_ERR(btf))
> 541 return PTR_ERR(btf);
> 542 if (!btf)
> 543 return -EINVAL;
> 544
> 545 ret = btf_find_by_name_kind(btf, name, kind);
> 546 /* ret is never zero, since btf_find_by_name_kind returns
> 547 * positive btf_id or negative error.
> 548 */
> 549 if (ret > 0) {
> 550 btf_get(btf);
> 551 *btf_p = btf;
> 552 return ret;
> 553 }
> 554
> 555 /* If name is not found in vmlinux's BTF then search in module's BTFs */
> 556 spin_lock_bh(&btf_idr_lock);
> 557 idr_for_each_entry(&btf_idr, btf, id) {
> 558 if (!btf_is_module(btf))
> 559 continue;
> 560 /* linear search could be slow hence unlock/lock
> 561 * the IDR to avoiding holding it for too long
> 562 */
> 563 btf_get(btf);
> 564 spin_unlock_bh(&btf_idr_lock);
> 565 ret = btf_find_by_name_kind(btf, name, kind);
> 566 if (ret > 0) {
> 567 *btf_p = btf;
> 568 return ret;
> 569 }
> 570 spin_lock_bh(&btf_idr_lock);
> 571 btf_put(btf);
> 572 }
> 573 spin_unlock_bh(&btf_idr_lock);
> 574 return ret;
> 575 }
> 576
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests