]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
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)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:20:35 +0000 (17:20 +0200)
BugLink: https://bugs.launchpad.net/bugs/2037005
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
kernel/bpf/syscall.c

index c94910d6a4431547f2000610579248872e6efaa6..f193b8f2a74d0b565a46a85e3d71ba43bb2aaf28 100644 (file)
@@ -5306,7 +5306,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;
 }