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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 9 Jan 2019 13:48:28 +0100
From:   Marek Majkowski <marek@...udflare.com>
To:     Willem de Bruijn <willemb@...gle.com>, netdev@...r.kernel.org
Subject: Re: MSG_ZEROCOPY doesn't work on half-open TCP sockets

I got it slightly wrong, and it's even worse than this. As far as I
understand it, the current semantics of MSG_ZEROCOPY on TCP make it
close to unusable. The problem is that the remote party can move your
MSG_ZEROCOPY socket from ESTABLISHED to CLOSE_WAIT without your
involvement. This will mean that even though the program can still
send() data to the socket, MSG_ZEROCOPY operations will fail with
EINVAL.

In other words: because the socket needs to be ESTABLISHED for
MSG_ZEROCOPY to work, and because remote party can send FIN and move
the socket to CLOSE_WAIT, a sending party must implement a fallback
from EINVAL return code on the transmission code. An adversarial
client who does shutdown(SHUT_WR), will trigger EINVAL in the sender..

Marek

On Wed, Jan 9, 2019 at 1:01 PM Marek Majkowski <marek@...udflare.com> wrote:
>
> Hi,
>
> Current implementation of MSG_ZEROCOPY for TCP requires the socket to
> be ESTABLISHED:
> https://elixir.bootlin.com/linux/v5.0-rc1/source/net/ipv4/tcp.c#L1188
>
> if (sk->sk_state != TCP_ESTABLISHED) {
>     err = -EINVAL;
>     goto out_err;
> }
>
> In TCP it's totally fine to have half-open sockets, for example:
>
> shutdown(5, SHUT_RD)
>
> Moves the socket from ESTABLISHED to CLOSE_WAIT. In such TCP state
> it's possible to continue sending data. This is not supported by
> MSG_ZEROCOPY, which will fail with EINVAL in such case. I think it's a
> bug.
>
> Marek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ