bpf: Print a warning only if writing to unprivileged_bpf_disabled.
authorKui-Feng Lee <thinker.li@gmail.com>
Tue, 2 May 2023 18:14:18 +0000 (11:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:50:34 +0000 (08:50 +0200)
commit10fa03a9c1bcdbd20f8f538542a3d902f9f22f3c
tree04b9e606736bd4c35c189062398c5e4a82653fad
parent8d1342108c2bf11aaaf293becfc010ecdb6170d9
bpf: Print a warning only if writing to unprivileged_bpf_disabled.

[ Upstream commit fedf99200ab086c42a572fca1d7266b06cdc3e3f ]

Only print the warning message if you are writing to
"/proc/sys/kernel/unprivileged_bpf_disabled".

The kernel may print an annoying warning when you read
"/proc/sys/kernel/unprivileged_bpf_disabled" saying

  WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible
  via Spectre v2 BHB attacks!

However, this message is only meaningful when the feature is
disabled or enabled.

Signed-off-by: Kui-Feng Lee <kuifeng@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20230502181418.308479-1-kuifeng@meta.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/syscall.c