diff options
author | Lorenz Bauer <lmb@cloudflare.com> | 2020-09-28 10:08:02 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-09-28 16:40:46 -0700 |
commit | 6550f2dddfab02a5b948369eeeaedfbc4ae3cc16 (patch) | |
tree | 30313e28f6393c2d0d7a65ceca78c9f6a1a81dc3 /kernel | |
parent | efa90b50934c93647e41da23d87e5d8b670014d4 (diff) | |
download | lwn-6550f2dddfab02a5b948369eeeaedfbc4ae3cc16.tar.gz lwn-6550f2dddfab02a5b948369eeeaedfbc4ae3cc16.zip |
bpf: sockmap: Enable map_update_elem from bpf_iter
Allow passing a pointer to a BTF struct sock_common* when updating
a sockmap or sockhash. Since BTF pointers can fault and therefore be
NULL at runtime we need to add an additional !sk check to
sock_map_update_elem. Since we may be passed a request or timewait
socket we also need to check sk_fullsock. Doing this allows calling
map_update_elem on sockmap from bpf_iter context, which uses
BTF pointers.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200928090805.23343-2-lmb@cloudflare.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/verifier.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index b25ba989c2dc..cc9c90d74dc1 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -3943,7 +3943,7 @@ static int resolve_map_arg_type(struct bpf_verifier_env *env, case BPF_MAP_TYPE_SOCKMAP: case BPF_MAP_TYPE_SOCKHASH: if (*arg_type == ARG_PTR_TO_MAP_VALUE) { - *arg_type = ARG_PTR_TO_SOCKET; + *arg_type = ARG_PTR_TO_BTF_ID_SOCK_COMMON; } else { verbose(env, "invalid arg_type for sockmap/sockhash\n"); return -EINVAL; |