]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bpf: sockmap: Check value of unused args to BPF_PROG_ATTACH
authorLorenz Bauer <lmb@cloudflare.com>
Mon, 29 Jun 2020 09:56:27 +0000 (10:56 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 30 Jun 2020 17:46:39 +0000 (10:46 -0700)
Using BPF_PROG_ATTACH on a sockmap program currently understands no
flags or replace_bpf_fd, but accepts any value. Return EINVAL instead.

Fixes: 38506f4bbc9d ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200629095630.7933-4-lmb@cloudflare.com
net/core/sock_map.c

index 4059f94e9bb5bf7316227984151052b47e321b47..58016a5c63ff8a00ece1080e61222a435558d3a3 100644 (file)
@@ -70,6 +70,9 @@ int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog)
        struct fd f;
        int ret;
 
+       if (attr->attach_flags || attr->replace_bpf_fd)
+               return -EINVAL;
+
        f = fdget(ufd);
        map = __bpf_map_get(f);
        if (IS_ERR(map))