[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <150833588223.3588.4249180141887196078.stgit@john-XPS-13-9360>
Date: Wed, 18 Oct 2017 07:11:22 -0700
From: John Fastabend <john.r.fastabend@...il.com>
To: alexei.starovoitov@...il.com, davem@...emloft.net
Cc: netdev@...r.kernel.org, borkmann@...earbox.net
Subject: [net PATCH 4/5] bpf: require CAP_NET_ADMIN when using sockmap maps
From: John Fastabend <john.fastabend@...il.com>
Restrict sockmap to CAP_NET_ADMIN.
Signed-off-by: John Fastabend <john.fastabend@...il.com>
Acked-by: Daniel Borkmann <daniel@...earbox.net>
---
kernel/bpf/sockmap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index beaabb2..2b6eb35 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -486,6 +486,9 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
int err = -EINVAL;
u64 cost;
+ if (!capable(CAP_NET_ADMIN))
+ return ERR_PTR(-EPERM);
+
/* check sanity of attributes */
if (attr->max_entries == 0 || attr->key_size != 4 ||
attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)
Powered by blists - more mailing lists