]> git.itanic.dy.fi Git - linux-stable/commit
bpf: Restrict bpf_sys_bpf to CAP_PERFMON
authorYiFei Zhu <zhuyifei@google.com>
Tue, 16 Aug 2022 20:55:16 +0000 (20:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Sep 2022 09:23:57 +0000 (11:23 +0200)
commit257f1447d7c245b81e23fa2ee932c737232c29ac
tree707e4499a2084edd1eb048b2a6adb0f2f21b9662
parent10ee118a1756141f8e9c87aa7344ed12b41630a8
bpf: Restrict bpf_sys_bpf to CAP_PERFMON

[ Upstream commit 14b20b784f59bdd95f6f1cfb112c9818bcec4d84 ]

The verifier cannot perform sufficient validation of any pointers passed
into bpf_attr and treats them as integers rather than pointers. The helper
will then read from arbitrary pointers passed into it. Restrict the helper
to CAP_PERFMON since the security model in BPF of arbitrary kernel read is
CAP_BPF + CAP_PERFMON.

Fixes: af2ac3e13e45 ("bpf: Prepare bpf syscall to be used from kernel and user space.")
Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220816205517.682470-1-zhuyifei@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/syscall.c