summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorKui-Feng Lee <thinker.li@gmail.com>2023-05-02 11:14:18 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-27 08:56:48 +0200
commitc7f54ef43499f9b10771459058f1361d37b3e3e1 (patch)
tree643bdaaa27ef5f14ed6879d82e2cb2b88de77f11 /kernel
parent32ca096e712a78b2f0d2e48d33dc0caaba9f9866 (diff)
downloadlinux-c7f54ef43499f9b10771459058f1361d37b3e3e1.tar.gz
linux-c7f54ef43499f9b10771459058f1361d37b3e3e1.tar.bz2
linux-c7f54ef43499f9b10771459058f1361d37b3e3e1.zip
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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/syscall.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index f1c8733f76b8..5524fcf6fb2a 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -5394,7 +5394,8 @@ static int bpf_unpriv_handler(struct ctl_table *table, int write,
*(int *)table->data = unpriv_enable;
}
- unpriv_ebpf_notify(unpriv_enable);
+ if (write)
+ unpriv_ebpf_notify(unpriv_enable);
return ret;
}