From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590AbdATWxc (ORCPT ); Fri, 20 Jan 2017 17:53:32 -0500 Received: from mail-ua0-f178.google.com ([209.85.217.178]:35503 "EHLO mail-ua0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbdATWx2 (ORCPT ); Fri, 20 Jan 2017 17:53:28 -0500 MIME-Version: 1.0 In-Reply-To: References: <20161209013208.GW1555@ZenIV.linux.org.uk> <20161209064144.GZ1555@ZenIV.linux.org.uk> From: Dmitry Vyukov Date: Fri, 20 Jan 2017 23:52:17 +0100 Message-ID: Subject: Re: fs, net: deadlock between bind/splice on af_unix To: Cong Wang Cc: Al Viro , "linux-fsdevel@vger.kernel.org" , LKML , David Miller , Rainer Weikusat , Hannes Frederic Sowa , netdev , Eric Dumazet , syzkaller Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 20, 2017 at 5:57 AM, 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? >>>>> >>>>>> 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