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


Groups > linux.kernel > #1563985

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

From Dmitry Vyukov <dvyukov@google.com>
Newsgroups linux.kernel
Subject Re: fs, net: deadlock between bind/splice on af_unix
Date 2017-01-21 00:00 +0100
Message-ID <t1Qk2-4MH-15@gated-at.bofh.it> (permalink)
References (5 earlier) <sMnai-8nx-13@gated-at.bofh.it> <t0bVE-6TE-13@gated-at.bofh.it> <t0Juh-3NG-3@gated-at.bofh.it> <t0UJ3-2cD-1@gated-at.bofh.it> <t1zsR-2DW-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jan 20, 2017 at 5:57 AM, Cong Wang <xiyou.wangcong@gmail.com> 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?
>>>>>
>>>>>> I guess some lock, perhaps the u->bindlock could be dropped before
>>>>>> acquiring the next one (sb_writer), but I need to double check.
>>>>>
>>>>> Bad idea, IMO - do you *want* autobind being able to come through while
>>>>> bind(2) is busy with mknod?
>>>>
>>>>
>>>> Ping. This is still happening on HEAD.
>>>>
>>>
>>> Thanks for your reminder. Mind to give the attached patch (compile only)
>>> a try? I take another approach to fix this deadlock, which moves the
>>> unix_mknod() out of unix->bindlock. Not sure if there is any unexpected
>>> impact with this way.
>>
>>
>> I instantly hit:
>>
>
> Oh, sorry about it, I forgot to initialize struct path...
>
> Attached is the updated version, I just did a boot test, no crash at least. ;)
>
> Thanks!

This works! I did not see the deadlock warning, nor any other related crashes.

Tested-by: Dmitry Vyukov <dvyukov@google.com>

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


Thread

Re: fs, net: deadlock between bind/splice on af_unix Cong Wang <xiyou.wangcong@gmail.com> - 2017-01-17 22:30 +0100
  Re: fs, net: deadlock between bind/splice on af_unix Dmitry Vyukov <dvyukov@google.com> - 2017-01-18 10:30 +0100
    Re: fs, net: deadlock between bind/splice on af_unix Cong Wang <xiyou.wangcong@gmail.com> - 2017-01-20 06:00 +0100
      Re: fs, net: deadlock between bind/splice on af_unix Dmitry Vyukov <dvyukov@google.com> - 2017-01-21 00:00 +0100
        Re: fs, net: deadlock between bind/splice on af_unix Cong Wang <xiyou.wangcong@gmail.com> - 2017-01-23 20:10 +0100
  Re: fs, net: deadlock between bind/splice on af_unix Mateusz Guzik <mguzik@redhat.com> - 2017-01-27 00:40 +0100
    Re: fs, net: deadlock between bind/splice on af_unix Cong Wang <xiyou.wangcong@gmail.com> - 2017-01-27 06:20 +0100
      Re: fs, net: deadlock between bind/splice on af_unix Mateusz Guzik <mguzik@redhat.com> - 2017-01-27 07:50 +0100

csiph-web