lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 24 Feb 2020 22:01:25 -0800
From:   Eric Dumazet <edumazet@...gle.com>
To:     Arjun Roy <arjunroy.kdev@...il.com>
Cc:     David Miller <davem@...emloft.net>,
        netdev <netdev@...r.kernel.org>, Arjun Roy <arjunroy@...gle.com>,
        Soheil Hassas Yeganeh <soheil@...gle.com>,
        Willem de Bruijn <willemb@...gle.com>
Subject: Re: [PATCH net-next] tcp-zerocopy: Update returned getsockopt() optlen.

On Mon, Feb 24, 2020 at 9:58 PM Arjun Roy <arjunroy.kdev@...il.com> wrote:
>
> From: Arjun Roy <arjunroy@...gle.com>
>
> TCP receive zerocopy currently does not update the returned optlen for
> getsockopt(). Thus, userspace cannot properly determine if all the
> fields are set in the passed-in struct. This patch sets the optlen
> before return, in keeping with the expected operation of getsockopt().
>
> Signed-off-by: Arjun Roy <arjunroy@...gle.com>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Signed-off-by: Soheil Hassas Yeganeh <soheil@...gle.com>
> Signed-off-by: Willem de Bruijn <willemb@...gle.com>

Please add a proper Fixes: tag :)

Thanks.

>
> ---
>  net/ipv4/tcp.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 600deb39f17de..fb9894d3d30e9 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -4148,8 +4148,12 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
>  zerocopy_rcv_inq:
>                 zc.inq = tcp_inq_hint(sk);
>  zerocopy_rcv_out:
> -               if (!err && copy_to_user(optval, &zc, len))
> -                       err = -EFAULT;
> +               if (!err) {
> +                       if (put_user(len, optlen))
> +                               return -EFAULT;
> +                       if (copy_to_user(optval, &zc, len))
> +                               return -EFAULT;
> +               }
>                 return err;
>         }
>  #endif
> --
> 2.25.0.265.gbab2e86ba0-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ