tree:
https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git timer
head: eb86df61cd52ea2e05357f8ae2b77e9bf6d63463
commit: eb86df61cd52ea2e05357f8ae2b77e9bf6d63463 [4/4] bpf: Implement verifier support for
validation of async callbacks.
config: x86_64-randconfig-a002-20210622 (attached as .config)
compiler: clang version 13.0.0 (
https://github.com/llvm/llvm-project
b259740801d3515810ecc15bf0c24b0d476a1608)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
#
https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/commit/?id=eb...
git remote add ast
https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git
git fetch --no-tags ast timer
git checkout eb86df61cd52ea2e05357f8ae2b77e9bf6d63463
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> kernel/bpf/helpers.c:1022:6: warning: variable 'ret' set
but not used [-Wunused-but-set-variable]
int ret;
^
1 warning generated.
vim +/ret +1022 kernel/bpf/helpers.c
7e26a76313f427 Alexei Starovoitov 2021-05-17 1011
7e26a76313f427 Alexei Starovoitov 2021-05-17 1012 static enum hrtimer_restart
bpf_timer_cb(struct hrtimer *hrtimer)
7e26a76313f427 Alexei Starovoitov 2021-05-17 1013 {
7e26a76313f427 Alexei Starovoitov 2021-05-17 1014 struct bpf_hrtimer *t =
container_of(hrtimer, struct bpf_hrtimer, timer);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1015 struct bpf_map *map = t->map;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1016 void *value = t->value;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1017 struct bpf_timer_kern *timer = value
+ map->timer_off;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1018 struct bpf_prog *prog;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1019 void *callback_fn;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1020 void *key;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1021 u32 idx;
7e26a76313f427 Alexei Starovoitov 2021-05-17 @1022 int ret;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1023
7e26a76313f427 Alexei Starovoitov 2021-05-17 1024
____bpf_spin_lock(&timer->lock);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1025 /* callback_fn and prog need to
match. They're updated together
7e26a76313f427 Alexei Starovoitov 2021-05-17 1026 * and have to be read under lock.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1027 */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1028 prog = t->prog;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1029 callback_fn = t->callback_fn;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1030
7e26a76313f427 Alexei Starovoitov 2021-05-17 1031 /* wrap bpf subprog invocation with
prog->refcnt++ and -- to make
7e26a76313f427 Alexei Starovoitov 2021-05-17 1032 * sure that refcnt doesn't
become zero when subprog is executing.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1033 * Do it under lock to make sure that
bpf_timer_start doesn't drop
7e26a76313f427 Alexei Starovoitov 2021-05-17 1034 * prev prog refcnt to zero before
timer_cb has a chance to bump it.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1035 */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1036 bpf_prog_inc(prog);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1037
____bpf_spin_unlock(&timer->lock);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1038
7e26a76313f427 Alexei Starovoitov 2021-05-17 1039 /* bpf_timer_cb() runs in
hrtimer_run_softirq. It doesn't migrate and
7e26a76313f427 Alexei Starovoitov 2021-05-17 1040 * cannot be preempted by another
bpf_timer_cb() on the same cpu.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1041 * Remember the timer this callback
is servicing to prevent
7e26a76313f427 Alexei Starovoitov 2021-05-17 1042 * deadlock if callback_fn() calls
bpf_timer_cancel() on the same timer.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1043 */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1044 this_cpu_write(hrtimer_running, t);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1045 if (map->map_type ==
BPF_MAP_TYPE_ARRAY) {
7e26a76313f427 Alexei Starovoitov 2021-05-17 1046 struct bpf_array *array =
container_of(map, struct bpf_array, map);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1047
7e26a76313f427 Alexei Starovoitov 2021-05-17 1048 /* compute the key */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1049 idx = ((char *)value -
array->value) / array->elem_size;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1050 key = &idx;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1051 } else { /* hash or lru */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1052 key = value -
round_up(map->key_size, 8);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1053 }
7e26a76313f427 Alexei Starovoitov 2021-05-17 1054
7e26a76313f427 Alexei Starovoitov 2021-05-17 1055 ret =
BPF_CAST_CALL(callback_fn)((u64)(long)map,
7e26a76313f427 Alexei Starovoitov 2021-05-17 1056 (u64)(long)key,
7e26a76313f427 Alexei Starovoitov 2021-05-17 1057 (u64)(long)value, 0, 0);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1058 bpf_prog_put(prog);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1059
7e26a76313f427 Alexei Starovoitov 2021-05-17 1060 this_cpu_write(hrtimer_running,
NULL);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1061 return HRTIMER_NORESTART;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1062 }
7e26a76313f427 Alexei Starovoitov 2021-05-17 1063
:::::: The code at line 1022 was first introduced by commit
:::::: 7e26a76313f4274c6013a7565411f3f7b6773b29 bpf: Introduce bpf_timer
:::::: TO: Alexei Starovoitov <ast(a)kernel.org>
:::::: CC: Alexei Starovoitov <ast(a)kernel.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org