]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Add __force annotations to silence sparse warnings
authorMykyta Yatsenko <yatsenko@meta.com>
Thu, 15 Jan 2026 18:45:09 +0000 (18:45 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 16 Jan 2026 22:21:11 +0000 (14:21 -0800)
commit1700147697618a57ed0a2a97d9a477d131b8fc54
tree18d92ac11f4a29ad81134600cf3ca151a4082b52
parent2acbd053c8463c005a0671b2d14a78f38be77c5c
bpf: Add __force annotations to silence sparse warnings

Add __force annotations to casts that convert between __user and kernel
address spaces. These casts are intentional:

- In bpf_send_signal_common(), the value is stored in si_value.sival_ptr
  which is typed as void __user *, but the value comes from a BPF
  program parameter.

- In the bpf_*_dynptr() kfuncs, user pointers are cast to const void *
  before being passed to copy helper functions that correctly handle
  the user address space through copy_from_user variants.

Without __force, sparse reports:
  warning: cast removes address space '__user' of expression

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260115184509.3585759-1-mykyta.yatsenko5@gmail.com
Closes: https://lore.kernel.org/oe-kbuild-all/202601131740.6C3BdBaB-lkp@intel.com/
kernel/trace/bpf_trace.c