From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751158AbdAQIMm (ORCPT ); Tue, 17 Jan 2017 03:12:42 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:48112 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750855AbdAQILh (ORCPT ); Tue, 17 Jan 2017 03:11:37 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Al Viro Cc: Cong Wang , Dmitry Vyukov , "linux-fsdevel\@vger.kernel.org" , LKML , David Miller , Rainer Weikusat , Hannes Frederic Sowa , netdev , Eric Dumazet , syzkaller References: <20161209013208.GW1555@ZenIV.linux.org.uk> <20161209064144.GZ1555@ZenIV.linux.org.uk> Date: Tue, 17 Jan 2017 21:07:05 +1300 In-Reply-To: <20161209064144.GZ1555@ZenIV.linux.org.uk> (Al Viro's message of "Fri, 9 Dec 2016 06:41:44 +0000") Message-ID: <87wpduaz4m.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1cTOrI-0002gs-Py;;;mid=<87wpduaz4m.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=101.100.131.98;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+q2j2MXzVVHa4awkj+WM3d+4hSbFTkPu8= X-SA-Exim-Connect-IP: 101.100.131.98 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4798] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Al Viro X-Spam-Relay-Country: X-Spam-Timing: total 5305 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.2 (0.1%), b_tie_ro: 2.3 (0.0%), parse: 0.96 (0.0%), extract_message_metadata: 13 (0.3%), get_uri_detail_list: 1.36 (0.0%), tests_pri_-1000: 6 (0.1%), tests_pri_-950: 1.12 (0.0%), tests_pri_-900: 0.96 (0.0%), tests_pri_-400: 22 (0.4%), check_bayes: 21 (0.4%), b_tokenize: 6 (0.1%), b_tok_get_all: 7 (0.1%), b_comp_prob: 2.4 (0.0%), b_tok_touch_all: 2.9 (0.1%), b_finish: 0.65 (0.0%), tests_pri_0: 409 (7.7%), check_dkim_signature: 0.45 (0.0%), check_dkim_adsp: 3.2 (0.1%), tests_pri_500: 4846 (91.3%), poll_dns_idle: 4838 (91.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: fs, net: deadlock between bind/splice on af_unix X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Al Viro 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