From: Al Viro <viro@zeniv.linux.org.uk>
To: netdev@vger.kernel.org
Subject: [RFC] odd checks in AF_UNIX ->recvmsg()
Date: Wed, 20 Feb 2019 19:47:39 +0000 [thread overview]
Message-ID: <20190220194739.GY2217@ZenIV.linux.org.uk> (raw)
Can ->recvmsg() (or ->splice_read(), for that matter)
overlap with ->release() of the socket it's reading from?
I'd always assumed that to be impossible, but we have this
in unix_stream_read_generic():
redo:
unix_state_lock(sk);
if (sock_flag(sk, SOCK_DEAD)) {
err = -ECONNRESET;
goto unlock;
}
last = skb = skb_peek(&sk->sk_receive_queue);
last_len = last ? last->len : 0;
...
and sk comes from state->socket->sk, i.e. sock->sk of unix_stream_recvmsg()
and unix_stream_splice_read(). IOW, the socket being read from. And
SOCK_DEAD is only set by sock_orphan(), which means that socket would
have to have gone through ->release().
What am I missing and how is that supposed to be triggered? Note that
e.g. shutdown(2) doesn't set SOCK_DEAD - its effects are in ->sk_shutdown
and the same unix_stream_read_generic() does check for those separately.
reply other threads:[~2019-02-20 19:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190220194739.GY2217@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).