Hi Kumar, url: https://github.com/intel-lab-lkp/linux/commits/Kumar-Kartikeya-Dwivedi/Allocated-objects-BPF-linked-lists/20221112-033643 base: e5659e4e19e49f1eac58bb07ce8bc2d78a89fe65 patch link: https://lore.kernel.org/r/20221111193224.876706-12-memxor%40gmail.com patch subject: [PATCH bpf-next v6 11/26] bpf: Allow locking bpf_spin_lock in allocated objects config: x86_64-randconfig-m001 compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@xxxxxxxxx> | Reported-by: Dan Carpenter <error27@xxxxxxxxx> smatch warnings: kernel/bpf/verifier.c:5623 process_spin_lock() error: uninitialized symbol 'rec'. vim +/rec +5623 kernel/bpf/verifier.c d83525ca62cf8e Alexei Starovoitov 2019-01-31 5588 static int process_spin_lock(struct bpf_verifier_env *env, int regno, d83525ca62cf8e Alexei Starovoitov 2019-01-31 5589 bool is_lock) d83525ca62cf8e Alexei Starovoitov 2019-01-31 5590 { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5591 struct bpf_reg_state *regs = cur_regs(env), *reg = ®s[regno]; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5592 struct bpf_verifier_state *cur = env->cur_state; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5593 bool is_const = tnum_is_const(reg->var_off); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5594 u64 val = reg->var_off.value; 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5595 struct bpf_map *map = NULL; 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5596 struct btf_record *rec; 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5597 struct btf *btf = NULL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5598 d83525ca62cf8e Alexei Starovoitov 2019-01-31 5599 if (!is_const) { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5600 verbose(env, d83525ca62cf8e Alexei Starovoitov 2019-01-31 5601 "R%d doesn't have constant offset. bpf_spin_lock has to be at the constant offset\n", d83525ca62cf8e Alexei Starovoitov 2019-01-31 5602 regno); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5603 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5604 } 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5605 if (reg->type == PTR_TO_MAP_VALUE) { 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5606 map = reg->map_ptr; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5607 if (!map->btf) { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5608 verbose(env, d83525ca62cf8e Alexei Starovoitov 2019-01-31 5609 "map '%s' has to have BTF in order to use bpf_spin_lock\n", d83525ca62cf8e Alexei Starovoitov 2019-01-31 5610 map->name); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5611 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5612 } 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5613 rec = map->record; 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5614 } else { 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5615 struct btf_struct_meta *meta; 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5616 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5617 btf = reg->btf; 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5618 meta = btf_find_struct_meta(reg->btf, reg->btf_id); 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5619 if (meta) 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5620 rec = meta->record; No else path. 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5621 } 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5622 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 @5623 if (!btf_record_has_field(rec, BPF_SPIN_LOCK)) { ^^^ 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5624 verbose(env, "%s '%s' has no valid bpf_spin_lock\n", map ? "map" : "local", 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5625 map ? map->name : "kptr"); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5626 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5627 } 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5628 if (rec->spin_lock_off != val + reg->off) { db559117828d24 Kumar Kartikeya Dwivedi 2022-11-04 5629 verbose(env, "off %lld doesn't point to 'struct bpf_spin_lock' that is at %d\n", 425ce908da14d5 Kumar Kartikeya Dwivedi 2022-11-12 5630 val + reg->off, rec->spin_lock_off); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5631 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5632 } d83525ca62cf8e Alexei Starovoitov 2019-01-31 5633 if (is_lock) { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5634 if (cur->active_spin_lock) { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5635 verbose(env, d83525ca62cf8e Alexei Starovoitov 2019-01-31 5636 "Locking two bpf_spin_locks are not allowed\n"); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5637 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5638 } d83525ca62cf8e Alexei Starovoitov 2019-01-31 5639 cur->active_spin_lock = reg->id; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5640 } else { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5641 if (!cur->active_spin_lock) { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5642 verbose(env, "bpf_spin_unlock without taking a lock\n"); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5643 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5644 } d83525ca62cf8e Alexei Starovoitov 2019-01-31 5645 if (cur->active_spin_lock != reg->id) { d83525ca62cf8e Alexei Starovoitov 2019-01-31 5646 verbose(env, "bpf_spin_unlock of different lock\n"); d83525ca62cf8e Alexei Starovoitov 2019-01-31 5647 return -EINVAL; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5648 } d83525ca62cf8e Alexei Starovoitov 2019-01-31 5649 cur->active_spin_lock = 0; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5650 } d83525ca62cf8e Alexei Starovoitov 2019-01-31 5651 return 0; d83525ca62cf8e Alexei Starovoitov 2019-01-31 5652 } -- 0-DAY CI Kernel Test Service https://01.org/lkp