[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ8uoz1sb=RWNbdAYSduqL5ME7OwWMV3aEwgPhgN0v=4mCSjwQ@mail.gmail.com>
Date: Mon, 7 Dec 2020 10:01:41 +0100
From: Magnus Karlsson <magnus.karlsson@...il.com>
To: Björn Töpel <bjorn.topel@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>,
Björn Töpel <bjorn.topel@...el.com>,
"Karlsson, Magnus" <magnus.karlsson@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>,
kernel test robot <oliver.sang@...el.com>
Subject: Re: [PATCH bpf-next] xsk: Validate socket state in xsk_recvmsg, prior
touching socket members
On Mon, Dec 7, 2020 at 9:22 AM Björn Töpel <bjorn.topel@...il.com> wrote:
>
> From: Björn Töpel <bjorn.topel@...el.com>
>
> In AF_XDP the socket state needs to be checked, prior touching the
> members of the socket. This was not the case for the recvmsg
> implementation. Fix that by moving the xsk_is_bound() call.
>
> Reported-by: kernel test robot <oliver.sang@...el.com>
> Fixes: 45a86681844e ("xsk: Add support for recvmsg()")
> Signed-off-by: Björn Töpel <bjorn.topel@...el.com>
> ---
> net/xdp/xsk.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Acked-by: Magnus Karlsson <magnus.karlsson@...el.com>
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 56c46e5f57bc..e28c6825e089 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -554,12 +554,12 @@ static int xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int fl
> struct sock *sk = sock->sk;
> struct xdp_sock *xs = xdp_sk(sk);
>
> + if (unlikely(!xsk_is_bound(xs)))
> + return -ENXIO;
> if (unlikely(!(xs->dev->flags & IFF_UP)))
> return -ENETDOWN;
> if (unlikely(!xs->rx))
> return -ENOBUFS;
> - if (unlikely(!xsk_is_bound(xs)))
> - return -ENXIO;
> if (unlikely(need_wait))
> return -EOPNOTSUPP;
>
>
> base-commit: 34da87213d3ddd26643aa83deff7ffc6463da0fc
> --
> 2.27.0
>
Powered by blists - more mailing lists