Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1560333

Re: fs, net: deadlock between bind/splice on af_unix

From ebiederm@xmission.com (Eric W. Biederman)
Newsgroups linux.kernel
Subject Re: fs, net: deadlock between bind/splice on af_unix
Date 2017-01-17 09:20 +0100
Message-ID <t0x9M-4At-17@gated-at.bofh.it> (permalink)
References (1 earlier) <sM9TI-8om-35@gated-at.bofh.it> <sMgVc-4sj-17@gated-at.bofh.it> <sMiki-5ep-11@gated-at.bofh.it> <sMn0B-8kb-1@gated-at.bofh.it> <sMnai-8nx-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Al Viro <viro@ZenIV.linux.org.uk> writes:

> On Thu, Dec 08, 2016 at 10:32:00PM -0800, Cong Wang wrote:
>
>> > Why do we do autobind there, anyway, and why is it conditional on
>> > SOCK_PASSCRED?  Note that e.g. for SOCK_STREAM we can bloody well get
>> > to sending stuff without autobind ever done - just use socketpair()
>> > to create that sucker and we won't be going through the connect()
>> > at all.
>> 
>> In the case Dmitry reported, unix_dgram_sendmsg() calls unix_autobind(),
>> not SOCK_STREAM.
>
> Yes, I've noticed.  What I'm asking is what in there needs autobind triggered
> on sendmsg and why doesn't the same need affect the SOCK_STREAM case?

With respect to the conditionality on SOCK_PASSCRED those are the linux
semantics.  Semantically that is the way the code has behaved since
2.1.15 when support for passing credentials was added to the code.
So I presume someone thought it was a good idea to have a name for
a socket that is sending credentials to another socket.  It certainly
seems reasonable at first glance.

With socketpair the only path that doesn't enforce this with
SOCK_STREAM and SOCK_PASSCRED that is either an oversight or a don't
care because we already know who is at the other end.

I can imagine two possible fixes:
1) Declare that splice is non-sense in the presence of SOCK_PASSCRED.
2) Someone adds a preparation operation that can be called on
   af_unix sockets that will ensure the autobind happens before
   any problematic locks are taken.

Eric

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: fs, net: deadlock between bind/splice on af_unix ebiederm@xmission.com (Eric W. Biederman) - 2017-01-17 09:20 +0100

csiph-web