From: John Fastabend Date: Wed, 18 Oct 2017 14:11:44 +0000 (-0700) Subject: bpf: require CAP_NET_ADMIN when using devmap X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9ef2a8cd5c0dcb8e1f1534615c56eb13b630c363;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git bpf: require CAP_NET_ADMIN when using devmap Devmap is used with XDP which requires CAP_NET_ADMIN so lets also make CAP_NET_ADMIN required to use the map. Signed-off-by: John Fastabend Acked-by: Daniel Borkmann Acked-by: Alexei Starovoitov Signed-off-by: David S. Miller --- diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index 920428d84da2..52e0548ba548 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -78,6 +78,9 @@ static struct bpf_map *dev_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)