Re: net/netfilter/nf_bpf_link.c:186:33: warning: bitwise operation between different enumeration types ('enum bpf_reg_type' and 'enum bpf_type_flag')

From: Nathan Chancellor
Date: Thu Feb 29 2024 - 22:51:08 EST


Hi all,

On Fri, Mar 01, 2024 at 08:57:56AM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 87adedeba51a822533649b143232418b9e26d08b
> commit: fd9c663b9ad67dedfc9a3fd3429ddd3e83782b4d bpf: minimal support for programs hooked into netfilter framework
> date: 10 months ago
> config: riscv-defconfig (https://download.01.org/0day-ci/archive/20240301/202403010842.hhJY5TFK-lkp@xxxxxxxxx/config)
> compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project edd4aee4dd9b5b98b2576a6f783e4086173d902a)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240301/202403010842.hhJY5TFK-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202403010842.hhJY5TFK-lkp@xxxxxxxxx/
>
> All warnings (new ones prefixed by >>):

<snip>

While this change may introduce an instance of this warning, it is
actually a change on the clang side that causes this and I am still
looking for input on what to do about it:

https://github.com/ClangBuiltLinux/linux/issues/2002

I think this report can just be ignored for now. The Intel folks may
want to consider sending -Wenum-enum-conversion and
-Wenum-compare-conditional reports to our mailing list only until we can
sort this out. Sorry for the noise.

Cheers,
Nathan

> >> net/netfilter/nf_bpf_link.c:186:33: warning: bitwise operation between different enumeration types ('enum bpf_reg_type' and 'enum bpf_type_flag') [-Wenum-enum-conversion]
> 186 | info->reg_type = PTR_TO_BTF_ID | PTR_TRUSTED;
> | ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
> 22 warnings generated.
>
>
> vim +186 net/netfilter/nf_bpf_link.c
>
> 170
> 171 static bool nf_ptr_to_btf_id(struct bpf_insn_access_aux *info, const char *name)
> 172 {
> 173 struct btf *btf;
> 174 s32 type_id;
> 175
> 176 btf = bpf_get_btf_vmlinux();
> 177 if (IS_ERR_OR_NULL(btf))
> 178 return false;
> 179
> 180 type_id = btf_find_by_name_kind(btf, name, BTF_KIND_STRUCT);
> 181 if (WARN_ON_ONCE(type_id < 0))
> 182 return false;
> 183
> 184 info->btf = btf;
> 185 info->btf_id = type_id;
> > 186 info->reg_type = PTR_TO_BTF_ID | PTR_TRUSTED;
> 187 return true;
> 188 }
> 189
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>