Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1539130
| From | Cong Wang <xiyou.wangcong@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: fs, net: deadlock between bind/splice on af_unix |
| Date | 2016-12-09 07:40 +0100 |
| Message-ID | <sMn0B-8kb-1@gated-at.bofh.it> (permalink) |
| References | <sM8bg-7j1-33@gated-at.bofh.it> <sM9TI-8om-35@gated-at.bofh.it> <sMgVc-4sj-17@gated-at.bofh.it> <sMiki-5ep-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Dec 8, 2016 at 5:32 PM, Al Viro <viro@zeniv.linux.org.uk> wrote: > On Thu, Dec 08, 2016 at 04:08:27PM -0800, Cong Wang wrote: >> On Thu, Dec 8, 2016 at 8:30 AM, Dmitry Vyukov <dvyukov@google.com> wrote: >> > Chain exists of: >> > Possible unsafe locking scenario: >> > >> > CPU0 CPU1 >> > ---- ---- >> > lock(sb_writers#5); >> > lock(&u->bindlock); >> > lock(sb_writers#5); >> > lock(&pipe->mutex/1); >> >> This looks false positive, probably just needs lockdep_set_class() >> to set keys for pipe->mutex and unix->bindlock. > > I'm afraid that it's not a false positive at all. Right, I was totally misled by the scenario output of lockdep, the stack traces actually are much more reasonable. The deadlock scenario is easy actually, comparing with the netlink one which has 4 locks involved, it is: unix_bind() path: u->bindlock ==> sb_writer do_splice() path: sb_writer ==> pipe->mutex ==> u->bindlock *** DEADLOCK *** > > 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. I guess some lock, perhaps the u->bindlock could be dropped before acquiring the next one (sb_writer), but I need to double check.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
fs, net: deadlock between bind/splice on af_unix Dmitry Vyukov <dvyukov@google.com> - 2016-12-08 15:50 +0100
Re: fs, net: deadlock between bind/splice on af_unix Dmitry Vyukov <dvyukov@google.com> - 2016-12-08 17:40 +0100
Re: fs, net: deadlock between bind/splice on af_unix Cong Wang <xiyou.wangcong@gmail.com> - 2016-12-09 01:10 +0100
Re: fs, net: deadlock between bind/splice on af_unix Al Viro <viro@ZenIV.linux.org.uk> - 2016-12-09 02:40 +0100
Re: fs, net: deadlock between bind/splice on af_unix Cong Wang <xiyou.wangcong@gmail.com> - 2016-12-09 07:40 +0100
Re: fs, net: deadlock between bind/splice on af_unix Al Viro <viro@ZenIV.linux.org.uk> - 2016-12-09 07:50 +0100
csiph-web