From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751376AbdBFHWg (ORCPT ); Mon, 6 Feb 2017 02:22:36 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33235 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbdBFHWe (ORCPT ); Mon, 6 Feb 2017 02:22:34 -0500 MIME-Version: 1.0 In-Reply-To: <20170131181411.cq3o7yxrnhq6thpt@dhcp-1-212.brq.redhat.com> References: <20161209013208.GW1555@ZenIV.linux.org.uk> <20161209064144.GZ1555@ZenIV.linux.org.uk> <20170126232912.rgh6undqxd4tofqj@dhcp-1-212.brq.redhat.com> <20170127064143.ddyt43iglu2odlld@dhcp-1-212.brq.redhat.com> <20170131181411.cq3o7yxrnhq6thpt@dhcp-1-212.brq.redhat.com> From: Cong Wang Date: Sun, 5 Feb 2017 23:22:12 -0800 Message-ID: Subject: Re: fs, net: deadlock between bind/splice on af_unix To: Mateusz Guzik Cc: Dmitry Vyukov , 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 Tue, Jan 31, 2017 at 10:14 AM, Mateusz Guzik wrote: > On Mon, Jan 30, 2017 at 10:44:03PM -0800, Cong Wang wrote: >> Mind being more specific? > > Consider 2 threads which bind the same socket, but with different paths. > > Currently exactly one file will get created, the one used to bind. > > With your patch both threads can succeed creating their respective > files, but only one will manage to bind. The other one must error out, > but it already created a file it is unclear what to do with. In this case, it simply puts the path back: err = -EINVAL; if (u->addr) goto out_up; [...] out_up: mutex_unlock(&u->bindlock); out_put: if (err) path_put(&path); out: return err; Which is what unix_release_sock() does too: if (path.dentry) path_put(&path);