Skip to content

Commit 121b45b

Browse files
lmbgregkh
authored andcommitted
bpf: sockmap: Check value of unused args to BPF_PROG_ATTACH
commit 9b2b097 upstream. 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 <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a073671 commit 121b45b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

net/core/sock_map.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog)
7070
struct fd f;
7171
int ret;
7272

73+
if (attr->attach_flags || attr->replace_bpf_fd)
74+
return -EINVAL;
75+
7376
f = fdget(ufd);
7477
map = __bpf_map_get(f);
7578
if (IS_ERR(map))

0 commit comments

Comments
 (0)