diff options
author | Lorenz Bauer <lmb@cloudflare.com> | 2020-06-29 11:56:28 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-06-30 19:46:39 +0200 |
commit | bb0de3131f4c60a9bf976681e0fe4d1e55c7a821 (patch) | |
tree | 47c55a8dc2cb7703d467da1e43f35778c192097d /kernel | |
parent | bpf: sockmap: Check value of unused args to BPF_PROG_ATTACH (diff) | |
download | linux-bb0de3131f4c60a9bf976681e0fe4d1e55c7a821.tar.xz linux-bb0de3131f4c60a9bf976681e0fe4d1e55c7a821.zip |
bpf: sockmap: Require attach_bpf_fd when detaching a program
The sockmap code currently ignores the value of attach_bpf_fd when
detaching a program. This is contrary to the usual behaviour of
checking that attach_bpf_fd represents the currently attached
program.
Ensure that attach_bpf_fd is indeed the currently attached
program. It turns out that all sockmap selftests already do this,
which indicates that this is unlikely to cause breakage.
Fixes: 604326b41a6f ("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-5-lmb@cloudflare.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/syscall.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 28c6ef759037..a74fce8ce043 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2893,7 +2893,7 @@ static int bpf_prog_detach(const union bpf_attr *attr) switch (ptype) { case BPF_PROG_TYPE_SK_MSG: case BPF_PROG_TYPE_SK_SKB: - return sock_map_get_from_fd(attr, NULL); + return sock_map_prog_detach(attr, ptype); case BPF_PROG_TYPE_LIRC_MODE2: return lirc_prog_detach(attr); case BPF_PROG_TYPE_FLOW_DISSECTOR: |