diff options
author | Chenbo Feng <fengc@google.com> | 2018-03-19 17:57:27 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-28 18:40:17 +0200 |
commit | c9ea2f8af67399904fe9c72ab5192a0c0ae7f2bf (patch) | |
tree | 1710af4664f3eb4f8d529a0fda0de8b9fdc214fa | |
parent | cbb5420a2fc021a8827bdf06ec38828bf1b43dc8 (diff) | |
download | linux-stable-c9ea2f8af67399904fe9c72ab5192a0c0ae7f2bf.tar.gz linux-stable-c9ea2f8af67399904fe9c72ab5192a0c0ae7f2bf.tar.bz2 linux-stable-c9ea2f8af67399904fe9c72ab5192a0c0ae7f2bf.zip |
bpf: skip unnecessary capability check
commit 0fa4fe85f4724fff89b09741c437cbee9cf8b008 upstream.
The current check statement in BPF syscall will do a capability check
for CAP_SYS_ADMIN before checking sysctl_unprivileged_bpf_disabled. This
code path will trigger unnecessary security hooks on capability checking
and cause false alarms on unprivileged process trying to get CAP_SYS_ADMIN
access. This can be resolved by simply switch the order of the statement
and CAP_SYS_ADMIN is not required anyway if unprivileged bpf syscall is
allowed.
Signed-off-by: Chenbo Feng <fengc@google.com>
Acked-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | kernel/bpf/syscall.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 424accd20c2d..dc19b6e210e6 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -673,7 +673,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz union bpf_attr attr = {}; int err; - if (!capable(CAP_SYS_ADMIN) && sysctl_unprivileged_bpf_disabled) + if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN)) return -EPERM; if (!access_ok(VERIFY_READ, uattr, 1)) |