From: Kui-Feng Lee Date: Tue, 2 May 2023 18:14:18 +0000 (-0700) Subject: bpf: Print a warning only if writing to unprivileged_bpf_disabled. X-Git-Tag: v6.1.52~1028 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10fa03a9c1bcdbd20f8f538542a3d902f9f22f3c;p=platform%2Fkernel%2Flinux-starfive.git 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 Signed-off-by: Andrii Nakryiko Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20230502181418.308479-1-kuifeng@meta.com Signed-off-by: Sasha Levin --- diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 8633ec4..0c44a71 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5289,7 +5289,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; }