From: Chenbo Feng <chenbofeng.kernel@gmail.com>
To: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Cc: Lorenzo Colitti <lorenzo@google.com>, Chenbo Feng <fengc@google.com>
Subject: [PATCH net-next 2/2] bpf: Remove the capability check for cgroup skb eBPF program
Date: Wed, 31 May 2017 11:06:53 -0700 [thread overview]
Message-ID: <1496254013-18719-2-git-send-email-chenbofeng.kernel@gmail.com> (raw)
In-Reply-To: <1496254013-18719-1-git-send-email-chenbofeng.kernel@gmail.com>
From: Chenbo Feng <fengc@google.com>
Currently loading a cgroup skb eBPF program require a CAP_SYS_ADMIN
capability while attaching the program to a cgroup only requires the
user have CAP_NET_ADMIN privilege. We can escape the capability
check when load the program just like socket filter program to make
the capability requirement consistent.
Signed-off-by: Chenbo Feng <fengc@google.com>
---
kernel/bpf/syscall.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 265a0d8..021c0b4 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -815,7 +815,9 @@ static int bpf_prog_load(union bpf_attr *attr)
attr->kern_version != LINUX_VERSION_CODE)
return -EINVAL;
- if (type != BPF_PROG_TYPE_SOCKET_FILTER && !capable(CAP_SYS_ADMIN))
+ if (type != BPF_PROG_TYPE_SOCKET_FILTER
+ && type != BPF_PROG_TYPE_CGROUP_SKB
+ && !capable(CAP_SYS_ADMIN))
return -EPERM;
/* plain bpf_prog allocation */
--
2.7.4
next prev parent reply other threads:[~2017-05-31 18:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 18:06 [PATCH net-next 1/2] bpf: Allow CGROUP_SKB eBPF program to access sk_buff Chenbo Feng
2017-05-31 18:06 ` Chenbo Feng [this message]
2017-06-01 0:17 ` [PATCH net-next 2/2] bpf: Remove the capability check for cgroup skb eBPF program YUAN Linyu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496254013-18719-2-git-send-email-chenbofeng.kernel@gmail.com \
--to=chenbofeng.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=fengc@google.com \
--cc=lorenzo@google.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.