[ammarfaizi2-block:bpf/bpf/master 1/2] kernel/bpf/syscall.c:5089:5: warning: no previous prototype for function 'kern_sys_bpf'

From: kernel test robot
Date: Wed Aug 10 2022 - 16:15:06 EST


tree: https://github.com/ammarfaizi2/linux-block bpf/bpf/master
head: 86f44fcec22ce2979507742bc53db8400e454f46
commit: 86f44fcec22ce2979507742bc53db8400e454f46 [1/2] bpf: Disallow bpf programs call prog_run command.
config: arm64-randconfig-r003-20220810 (https://download.01.org/0day-ci/archive/20220811/202208110447.5dGsjBot-lkp@xxxxxxxxx/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 5f1c7e2cc5a3c07cbc2412e851a7283c1841f520)
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
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/ammarfaizi2/linux-block/commit/86f44fcec22ce2979507742bc53db8400e454f46
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block bpf/bpf/master
git checkout 86f44fcec22ce2979507742bc53db8400e454f46
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 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/syscall.c:5089:5: warning: no previous prototype for function 'kern_sys_bpf' [-Wmissing-prototypes]
int kern_sys_bpf(int cmd, union bpf_attr *attr, unsigned int size)
^
kernel/bpf/syscall.c:5089:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int kern_sys_bpf(int cmd, union bpf_attr *attr, unsigned int size)
^
static
1 warning generated.


vim +/kern_sys_bpf +5089 kernel/bpf/syscall.c

5088
> 5089 int kern_sys_bpf(int cmd, union bpf_attr *attr, unsigned int size)
5090 {
5091 struct bpf_prog * __maybe_unused prog;
5092 struct bpf_tramp_run_ctx __maybe_unused run_ctx;
5093
5094 switch (cmd) {
5095 #ifdef CONFIG_BPF_JIT /* __bpf_prog_enter_sleepable used by trampoline and JIT */
5096 case BPF_PROG_TEST_RUN:
5097 if (attr->test.data_in || attr->test.data_out ||
5098 attr->test.ctx_out || attr->test.duration ||
5099 attr->test.repeat || attr->test.flags)
5100 return -EINVAL;
5101
5102 prog = bpf_prog_get_type(attr->test.prog_fd, BPF_PROG_TYPE_SYSCALL);
5103 if (IS_ERR(prog))
5104 return PTR_ERR(prog);
5105
5106 if (attr->test.ctx_size_in < prog->aux->max_ctx_offset ||
5107 attr->test.ctx_size_in > U16_MAX) {
5108 bpf_prog_put(prog);
5109 return -EINVAL;
5110 }
5111
5112 run_ctx.bpf_cookie = 0;
5113 run_ctx.saved_run_ctx = NULL;
5114 if (!__bpf_prog_enter_sleepable(prog, &run_ctx)) {
5115 /* recursion detected */
5116 bpf_prog_put(prog);
5117 return -EBUSY;
5118 }
5119 attr->test.retval = bpf_prog_run(prog, (void *) (long) attr->test.ctx_in);
5120 __bpf_prog_exit_sleepable(prog, 0 /* bpf_prog_run does runtime stats */, &run_ctx);
5121 bpf_prog_put(prog);
5122 return 0;
5123 #endif
5124 default:
5125 return ____bpf_sys_bpf(cmd, attr, size);
5126 }
5127 }
5128 EXPORT_SYMBOL(kern_sys_bpf);
5129

--
0-DAY CI Kernel Test Service
https://01.org/lkp