From: Willy Tarreau <w@1wt.eu>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Marek Majkowski <marek@cloudflare.com>,
Willem de Bruijn <willemb@google.com>,
Network Development <netdev@vger.kernel.org>
Subject: Re: MSG_ZEROCOPY doesn't work on half-open TCP sockets
Date: Wed, 9 Jan 2019 15:29:13 +0100 [thread overview]
Message-ID: <20190109142913.GF23422@1wt.eu> (raw)
In-Reply-To: <CAF=yD-JPwXWmHeHsaC0EcjVwsQSsPCQm+8V-PUxTU_VrW-pKcA@mail.gmail.com>
On Wed, Jan 09, 2019 at 08:55:14AM -0500, Willem de Bruijn wrote:
> > 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..
>
> An adversarial client only affects its own stream, so the impact is limited.
Sure but it doesn't necessarily do it on purpose either :-) The typical
echo -ne "GET /file HTTP/1.1\r\nHost: foo.example.com\r\n\r\n" | nc host port
is perfectly valid and will not work in this case, possibly forcing the newly
deployed component to toll back.
> Thanks for the report. At first blush it seems like extending the
> check to include state CLOSE_WAIT would resolve the issue
>
> if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) {
> - if (sk->sk_state != TCP_ESTABLISHED) {
> + if ((1 << sk->sk_state) & ~(TCPF_ESTABLISHED |
> TCPF_CLOSE_WAIT)) {
>
> err = -EINVAL;
> goto out_err;
> }
At first glance I think it should do the job.
Willy
prev parent reply other threads:[~2019-01-09 14:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 12:01 MSG_ZEROCOPY doesn't work on half-open TCP sockets Marek Majkowski
2019-01-09 12:48 ` Marek Majkowski
2019-01-09 13:55 ` Willem de Bruijn
2019-01-09 14:29 ` Willy Tarreau [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190109142913.GF23422@1wt.eu \
--to=w@1wt.eu \
--cc=marek@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.