Message ID | 20220301065745.1634848-7-memxor@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | Fixes for bad PTR_TO_BTF_ID offset | expand |
Hi Kumar, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on bpf-next/master] url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) 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 s390 cross compiling tool for clang build # apt-get install binutils-s390x-linux-gnu # https://github.com/0day-ci/linux/commit/37a0d686bce3b71b14a17ae57364ec45d1405b9e git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 git checkout 37a0d686bce3b71b14a17ae57364ec45d1405b9e # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash net/bpf/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): writesl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ net/bpf/test_run.c:201:14: warning: no previous prototype for function 'bpf_fentry_test1' [-Wmissing-prototypes] int noinline bpf_fentry_test1(int a) ^ net/bpf/test_run.c:201:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test1(int a) ^ static net/bpf/test_run.c:208:14: warning: no previous prototype for function 'bpf_fentry_test2' [-Wmissing-prototypes] int noinline bpf_fentry_test2(int a, u64 b) ^ net/bpf/test_run.c:208:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test2(int a, u64 b) ^ static net/bpf/test_run.c:213:14: warning: no previous prototype for function 'bpf_fentry_test3' [-Wmissing-prototypes] int noinline bpf_fentry_test3(char a, int b, u64 c) ^ net/bpf/test_run.c:213:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test3(char a, int b, u64 c) ^ static net/bpf/test_run.c:218:14: warning: no previous prototype for function 'bpf_fentry_test4' [-Wmissing-prototypes] int noinline bpf_fentry_test4(void *a, char b, int c, u64 d) ^ net/bpf/test_run.c:218:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test4(void *a, char b, int c, u64 d) ^ static net/bpf/test_run.c:223:14: warning: no previous prototype for function 'bpf_fentry_test5' [-Wmissing-prototypes] int noinline bpf_fentry_test5(u64 a, void *b, short c, int d, u64 e) ^ net/bpf/test_run.c:223:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test5(u64 a, void *b, short c, int d, u64 e) ^ static net/bpf/test_run.c:228:14: warning: no previous prototype for function 'bpf_fentry_test6' [-Wmissing-prototypes] int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f) ^ net/bpf/test_run.c:228:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test6(u64 a, void *b, short c, int d, void *e, u64 f) ^ static net/bpf/test_run.c:237:14: warning: no previous prototype for function 'bpf_fentry_test7' [-Wmissing-prototypes] int noinline bpf_fentry_test7(struct bpf_fentry_test_t *arg) ^ net/bpf/test_run.c:237:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test7(struct bpf_fentry_test_t *arg) ^ static net/bpf/test_run.c:242:14: warning: no previous prototype for function 'bpf_fentry_test8' [-Wmissing-prototypes] int noinline bpf_fentry_test8(struct bpf_fentry_test_t *arg) ^ net/bpf/test_run.c:242:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_fentry_test8(struct bpf_fentry_test_t *arg) ^ static net/bpf/test_run.c:247:14: warning: no previous prototype for function 'bpf_modify_return_test' [-Wmissing-prototypes] int noinline bpf_modify_return_test(int a, int *b) ^ net/bpf/test_run.c:247:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_modify_return_test(int a, int *b) ^ static net/bpf/test_run.c:253:14: warning: no previous prototype for function 'bpf_kfunc_call_test1' [-Wmissing-prototypes] u64 noinline bpf_kfunc_call_test1(struct sock *sk, u32 a, u64 b, u32 c, u64 d) ^ net/bpf/test_run.c:253:1: note: declare 'static' if the function is not intended to be used outside of this translation unit u64 noinline bpf_kfunc_call_test1(struct sock *sk, u32 a, u64 b, u32 c, u64 d) ^ static net/bpf/test_run.c:258:14: warning: no previous prototype for function 'bpf_kfunc_call_test2' [-Wmissing-prototypes] int noinline bpf_kfunc_call_test2(struct sock *sk, u32 a, u32 b) ^ net/bpf/test_run.c:258:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int noinline bpf_kfunc_call_test2(struct sock *sk, u32 a, u32 b) ^ static net/bpf/test_run.c:263:24: warning: no previous prototype for function 'bpf_kfunc_call_test3' [-Wmissing-prototypes] struct sock * noinline bpf_kfunc_call_test3(struct sock *sk) ^ net/bpf/test_run.c:263:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct sock * noinline bpf_kfunc_call_test3(struct sock *sk) ^ static net/bpf/test_run.c:286:1: warning: no previous prototype for function 'bpf_kfunc_call_test_acquire' [-Wmissing-prototypes] bpf_kfunc_call_test_acquire(unsigned long *scalar_ptr) ^ net/bpf/test_run.c:285:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline struct prog_test_ref_kfunc * ^ static net/bpf/test_run.c:294:15: warning: no previous prototype for function 'bpf_kfunc_call_test_release' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) ^ net/bpf/test_run.c:294:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) ^ static >> net/bpf/test_run.c:298:15: warning: no previous prototype for function 'bpf_kfunc_call_memb_release' [-Wmissing-prototypes] noinline void bpf_kfunc_call_memb_release(struct prog_test_member *p) ^ net/bpf/test_run.c:298:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_memb_release(struct prog_test_member *p) ^ static net/bpf/test_run.c:340:15: warning: no previous prototype for function 'bpf_kfunc_call_test_pass_ctx' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb) ^ net/bpf/test_run.c:340:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb) ^ static net/bpf/test_run.c:344:15: warning: no previous prototype for function 'bpf_kfunc_call_test_pass1' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_pass1(struct prog_test_pass1 *p) ^ net/bpf/test_run.c:344:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_pass1(struct prog_test_pass1 *p) ^ static net/bpf/test_run.c:348:15: warning: no previous prototype for function 'bpf_kfunc_call_test_pass2' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_pass2(struct prog_test_pass2 *p) ^ net/bpf/test_run.c:348:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_pass2(struct prog_test_pass2 *p) ^ static net/bpf/test_run.c:352:15: warning: no previous prototype for function 'bpf_kfunc_call_test_fail1' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_fail1(struct prog_test_fail1 *p) ^ net/bpf/test_run.c:352:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_fail1(struct prog_test_fail1 *p) ^ static net/bpf/test_run.c:356:15: warning: no previous prototype for function 'bpf_kfunc_call_test_fail2' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_fail2(struct prog_test_fail2 *p) ^ net/bpf/test_run.c:356:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_fail2(struct prog_test_fail2 *p) ^ static net/bpf/test_run.c:360:15: warning: no previous prototype for function 'bpf_kfunc_call_test_fail3' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_fail3(struct prog_test_fail3 *p) ^ net/bpf/test_run.c:360:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_fail3(struct prog_test_fail3 *p) ^ static net/bpf/test_run.c:364:15: warning: no previous prototype for function 'bpf_kfunc_call_test_mem_len_pass1' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_mem_len_pass1(void *mem, int mem__sz) ^ net/bpf/test_run.c:364:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_mem_len_pass1(void *mem, int mem__sz) ^ static net/bpf/test_run.c:368:15: warning: no previous prototype for function 'bpf_kfunc_call_test_mem_len_fail1' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_mem_len_fail1(void *mem, int len) ^ net/bpf/test_run.c:368:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_mem_len_fail1(void *mem, int len) ^ static net/bpf/test_run.c:372:15: warning: no previous prototype for function 'bpf_kfunc_call_test_mem_len_fail2' [-Wmissing-prototypes] noinline void bpf_kfunc_call_test_mem_len_fail2(u64 *mem, int len) ^ net/bpf/test_run.c:372:10: note: declare 'static' if the function is not intended to be used outside of this translation unit noinline void bpf_kfunc_call_test_mem_len_fail2(u64 *mem, int len) ^ static 36 warnings generated. vim +/bpf_kfunc_call_memb_release +298 net/bpf/test_run.c 297 > 298 noinline void bpf_kfunc_call_memb_release(struct prog_test_member *p) 299 { 300 } 301 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Tue, Mar 01, 2022 at 05:10:31PM IST, kernel test robot wrote: > Hi Kumar, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on bpf-next/master] > > url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) The same warning is emitted on clang for all existing definitions, so I can respin with a fix for the warning like we do for GCC, otherwise it can also be a follow up patch. > [...] -- Kartikeya
On Tue, Mar 1, 2022 at 3:57 AM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote: > > On Tue, Mar 01, 2022 at 05:10:31PM IST, kernel test robot wrote: > > Hi Kumar, > > > > Thank you for the patch! Perhaps something to improve: > > > > [auto build test WARNING on bpf-next/master] > > > > url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > > config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) > > The same warning is emitted on clang for all existing definitions, so I can > respin with a fix for the warning like we do for GCC, otherwise it can also > be a follow up patch. Separate patch is fine. How do you plan on fixing it? What is __diag_ignore equivalent for clang?
On Thu, Mar 03, 2022 at 04:17:25AM IST, Alexei Starovoitov wrote: > On Tue, Mar 1, 2022 at 3:57 AM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote: > > > > On Tue, Mar 01, 2022 at 05:10:31PM IST, kernel test robot wrote: > > > Hi Kumar, > > > > > > Thank you for the patch! Perhaps something to improve: > > > > > > [auto build test WARNING on bpf-next/master] > > > > > > url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > > > config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) > > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) > > > > The same warning is emitted on clang for all existing definitions, so I can > > respin with a fix for the warning like we do for GCC, otherwise it can also > > be a follow up patch. > > Separate patch is fine. > How do you plan on fixing it? > What is __diag_ignore equivalent for clang? Hmm, looks like I'll have to add those in include/linux/compiler-clang.h. Quick local testing suggests it will work with _Pragma("clang diagnostic ignored ..."). -- Kartikeya
On Wed, Mar 2, 2022 at 3:14 PM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote: > > On Thu, Mar 03, 2022 at 04:17:25AM IST, Alexei Starovoitov wrote: > > On Tue, Mar 1, 2022 at 3:57 AM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote: > > > > > > On Tue, Mar 01, 2022 at 05:10:31PM IST, kernel test robot wrote: > > > > Hi Kumar, > > > > > > > > Thank you for the patch! Perhaps something to improve: > > > > > > > > [auto build test WARNING on bpf-next/master] > > > > > > > > url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 > > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > > > > config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) > > > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) > > > > > > The same warning is emitted on clang for all existing definitions, so I can > > > respin with a fix for the warning like we do for GCC, otherwise it can also > > > be a follow up patch. > > > > Separate patch is fine. > > How do you plan on fixing it? > > What is __diag_ignore equivalent for clang? > > Hmm, looks like I'll have to add those in include/linux/compiler-clang.h. Quick > local testing suggests it will work with _Pragma("clang diagnostic ignored ..."). Make a generic llvm/gcc #define for __diag_ignore(GCC, 8, "-Wmissing-prototypes" ? We need it in two places so far.
On Thu, Mar 03, 2022 at 04:44:01AM +0530, Kumar Kartikeya Dwivedi wrote: > On Thu, Mar 03, 2022 at 04:17:25AM IST, Alexei Starovoitov wrote: > > On Tue, Mar 1, 2022 at 3:57 AM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote: > > > > > > On Tue, Mar 01, 2022 at 05:10:31PM IST, kernel test robot wrote: > > > > Hi Kumar, > > > > > > > > Thank you for the patch! Perhaps something to improve: > > > > > > > > [auto build test WARNING on bpf-next/master] > > > > > > > > url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 > > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > > > > config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) > > > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) > > > > > > The same warning is emitted on clang for all existing definitions, so I can > > > respin with a fix for the warning like we do for GCC, otherwise it can also > > > be a follow up patch. > > > > Separate patch is fine. > > How do you plan on fixing it? > > What is __diag_ignore equivalent for clang? > > Hmm, looks like I'll have to add those in include/linux/compiler-clang.h. Quick > local testing suggests it will work with _Pragma("clang diagnostic ignored ..."). I have a diff that mirrors the GCC infrastructure, which should work for this, feel free to copy it: https://lore.kernel.org/r/20210310225240.4epj2mdmzt4vurr3@archlinux-ax161/ If you want to shut up the warning for all supported versions of clang, switch 130000 for 110000 and __diag_clang_11() for __diag_clang_13(). Cheers, Nathan
On Thu, Mar 03, 2022 at 04:56:37AM IST, Nathan Chancellor wrote: > On Thu, Mar 03, 2022 at 04:44:01AM +0530, Kumar Kartikeya Dwivedi wrote: > > On Thu, Mar 03, 2022 at 04:17:25AM IST, Alexei Starovoitov wrote: > > > On Tue, Mar 1, 2022 at 3:57 AM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote: > > > > > > > > On Tue, Mar 01, 2022 at 05:10:31PM IST, kernel test robot wrote: > > > > > Hi Kumar, > > > > > > > > > > Thank you for the patch! Perhaps something to improve: > > > > > > > > > > [auto build test WARNING on bpf-next/master] > > > > > > > > > > url: https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Fixes-for-bad-PTR_TO_BTF_ID-offset/20220301-150010 > > > > > base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master > > > > > config: s390-randconfig-r021-20220301 (https://download.01.org/0day-ci/archive/20220301/202203011937.wMLpkfU3-lkp@intel.com/config) > > > > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) > > > > > > > > The same warning is emitted on clang for all existing definitions, so I can > > > > respin with a fix for the warning like we do for GCC, otherwise it can also > > > > be a follow up patch. > > > > > > Separate patch is fine. > > > How do you plan on fixing it? > > > What is __diag_ignore equivalent for clang? > > > > Hmm, looks like I'll have to add those in include/linux/compiler-clang.h. Quick > > local testing suggests it will work with _Pragma("clang diagnostic ignored ..."). > > I have a diff that mirrors the GCC infrastructure, which should work for > this, feel free to copy it: > > https://lore.kernel.org/r/20210310225240.4epj2mdmzt4vurr3@archlinux-ax161/ > > If you want to shut up the warning for all supported versions of clang, > switch 130000 for 110000 and __diag_clang_11() for __diag_clang_13(). > That's great, Nathan! I'll add your Signed-off-by to it. > Cheers, > Nathan -- Kartikeya
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index f08034500813..21e1c2d64f25 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -265,9 +265,14 @@ struct sock * noinline bpf_kfunc_call_test3(struct sock *sk) return sk; } +struct prog_test_member { + unsigned long c; +}; + struct prog_test_ref_kfunc { int a; int b; + struct prog_test_member memb; struct prog_test_ref_kfunc *next; }; @@ -290,6 +295,10 @@ noinline void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) { } +noinline void bpf_kfunc_call_memb_release(struct prog_test_member *p) +{ +} + struct prog_test_pass1 { int x0; struct { @@ -374,6 +383,7 @@ BTF_ID(func, bpf_kfunc_call_test2) BTF_ID(func, bpf_kfunc_call_test3) BTF_ID(func, bpf_kfunc_call_test_acquire) BTF_ID(func, bpf_kfunc_call_test_release) +BTF_ID(func, bpf_kfunc_call_memb_release) BTF_ID(func, bpf_kfunc_call_test_pass_ctx) BTF_ID(func, bpf_kfunc_call_test_pass1) BTF_ID(func, bpf_kfunc_call_test_pass2) @@ -391,6 +401,7 @@ BTF_SET_END(test_sk_acquire_kfunc_ids) BTF_SET_START(test_sk_release_kfunc_ids) BTF_ID(func, bpf_kfunc_call_test_release) +BTF_ID(func, bpf_kfunc_call_memb_release) BTF_SET_END(test_sk_release_kfunc_ids) BTF_SET_START(test_sk_ret_null_kfunc_ids) diff --git a/tools/testing/selftests/bpf/verifier/calls.c b/tools/testing/selftests/bpf/verifier/calls.c index 0a8ea60c2a80..985183d1310a 100644 --- a/tools/testing/selftests/bpf/verifier/calls.c +++ b/tools/testing/selftests/bpf/verifier/calls.c @@ -115,6 +115,88 @@ { "bpf_kfunc_call_test_release", 5 }, }, }, +{ + "calls: invalid kfunc call: reg->off must be zero when passed to release kfunc", + .insns = { + BPF_MOV64_REG(BPF_REG_1, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8), + BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), + BPF_EXIT_INSN(), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 8), + BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .prog_type = BPF_PROG_TYPE_SCHED_CLS, + .result = REJECT, + .errstr = "R1 with ref_obj_id=2 must have zero offset when passed to release kfunc", + .fixup_kfunc_btf_id = { + { "bpf_kfunc_call_test_acquire", 3 }, + { "bpf_kfunc_call_memb_release", 8 }, + }, +}, +{ + "calls: invalid kfunc call: PTR_TO_BTF_ID with negative offset", + .insns = { + BPF_MOV64_REG(BPF_REG_1, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8), + BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), + BPF_EXIT_INSN(), + BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -4), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .prog_type = BPF_PROG_TYPE_SCHED_CLS, + .fixup_kfunc_btf_id = { + { "bpf_kfunc_call_test_acquire", 3 }, + { "bpf_kfunc_call_test_release", 8 }, + }, + .result_unpriv = REJECT, + .result = REJECT, + .errstr = "negative offset ptr_ ptr R1 off=-4 disallowed", +}, +{ + "calls: invalid kfunc call: PTR_TO_BTF_ID with variable offset", + .insns = { + BPF_MOV64_REG(BPF_REG_1, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8), + BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), + BPF_EXIT_INSN(), + BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_0, 4), + BPF_JMP_IMM(BPF_JLE, BPF_REG_2, 4, 3), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + BPF_JMP_IMM(BPF_JGE, BPF_REG_2, 0, 3), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_2), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .prog_type = BPF_PROG_TYPE_SCHED_CLS, + .fixup_kfunc_btf_id = { + { "bpf_kfunc_call_test_acquire", 3 }, + { "bpf_kfunc_call_test_release", 9 }, + { "bpf_kfunc_call_test_release", 13 }, + { "bpf_kfunc_call_test_release", 17 }, + }, + .result_unpriv = REJECT, + .result = REJECT, + .errstr = "variable ptr_ access var_off=(0x0; 0x7) disallowed", +}, { "calls: basic sanity", .insns = {
Include a few verifier selftests that test against the problems being fixed by previous commits, i.e. release kfunc always require PTR_TO_BTF_ID fixed and var_off to be 0, and negative offset is not permitted and returns a helpful error message. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> --- net/bpf/test_run.c | 11 +++ tools/testing/selftests/bpf/verifier/calls.c | 82 ++++++++++++++++++++ 2 files changed, 93 insertions(+)