Skip to content

Commit

Permalink
bpf: sockmap: Check value of unused args to BPF_PROG_ATTACH
Browse files Browse the repository at this point in the history
Using BPF_PROG_ATTACH on a sockmap program currently understands no
flags or replace_bpf_fd, but accepts any value. Return EINVAL instead.

Fixes: 604326b ("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
  • Loading branch information
Lorenz Bauer authored and Alexei Starovoitov committed Jun 30, 2020
1 parent 4ac2add commit 9b2b097
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/core/sock_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 9b2b097

Please sign in to comment.