Re: [PATCH bpf-next 1/4] bpf: sockmap: enable map_update_elem from bpf_iter

From: Martin KaFai Lau
Date: Fri Sep 25 2020 - 17:54:25 EST


On Fri, Sep 25, 2020 at 10:56:27AM +0100, Lorenz Bauer wrote:
[ ... ]

> diff --git a/net/core/sock_map.c b/net/core/sock_map.c
> index e1f05e3fa1d0..497e7df466d4 100644
> --- a/net/core/sock_map.c
> +++ b/net/core/sock_map.c
> @@ -610,6 +610,9 @@ static int sock_map_update_elem(struct bpf_map *map, void *key,
> struct sock *sk = (struct sock *)value;
> int ret;
>
> + if (unlikely(!sk))
sk_fullsock(sk) test is also needed.

> + return -EINVAL;

> +
> if (!sock_map_sk_is_suitable(sk))
sk->sk_type is used in sock_map_sk_is_suitable().
sk_type is not in sock_common.