From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752254AbcAFOqO (ORCPT ); Wed, 6 Jan 2016 09:46:14 -0500 Received: from tiger.mobileactivedefense.com ([217.174.251.109]:40219 "EHLO tiger.mobileactivedefense.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751892AbcAFOqL (ORCPT ); Wed, 6 Jan 2016 09:46:11 -0500 From: Rainer Weikusat To: Hannes Frederic Sowa Cc: Rainer Weikusat , David Miller , dvyukov@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, viro@ZenIV.linux.org.uk Subject: Re: [PATCH] af_unix: Fix splice-bind deadlock In-Reply-To: <1451949906.2606240.482870994.43973946@webmail.messagingengine.com> (Hannes Frederic Sowa's message of "Tue, 05 Jan 2016 00:25:06 +0100") References: <87y4cftztp.fsf@doppelsaurus.mobileactivedefense.com> <56826754.2060003@stressinduktion.org> <87ege2xve5.fsf@doppelsaurus.mobileactivedefense.com> <87ziwmk0b7.fsf@doppelsaurus.mobileactivedefense.com> <1451949906.2606240.482870994.43973946@webmail.messagingengine.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Date: Wed, 06 Jan 2016 14:45:55 +0000 Message-ID: <87ziwizrz0.fsf@doppelsaurus.mobileactivedefense.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (tiger.mobileactivedefense.com [217.174.251.109]); Wed, 06 Jan 2016 14:46:03 +0000 (GMT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hannes Frederic Sowa writes: > On Sun, Jan 3, 2016, at 19:03, Rainer Weikusat wrote: [reorder i_mutex and readlock locking] > I was concerned because of the comment in skb_socket_splice: > > /* Drop the socket lock, otherwise we have reverse > * locking dependencies between sk_lock and i_mutex > * here as compared to sendfile(). We enter here > * with the socket lock held, and splice_to_pipe() will > * grab the pipe inode lock. For sendfile() emulation, > * we call into ->sendpage() with the i_mutex lock held > * and networking will grab the socket lock. > */ AFAICT, this comment is "a bit misleading": sendfile (from file to socket) is internally implemented as 'splice from file to pipe' + 'splice from pipe to socket'. The later acquires the pipe lock of the pipe and then invokes the sendpage method of the socket which acquires the appropiate socket lock (for an AF_UNIX socket, it's u->readlock). But 'pipe lock' and 'i_mutex' are two completely different things: The former is the mutex in a struct pipe_inode_info (pipe_fs_u.h), the latter is the i_mutex in a struct inode (fs.h). "Code explains comment" :-)