From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752876AbdCIH3f (ORCPT ); Thu, 9 Mar 2017 02:29:35 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:60662 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbdCIH3e (ORCPT ); Thu, 9 Mar 2017 02:29:34 -0500 Date: Wed, 08 Mar 2017 23:06:25 -0800 (PST) Message-Id: <20170308.230625.719131946756053988.davem@davemloft.net> To: dhowells@redhat.com Cc: netdev@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH net] net: Work around lockdep limitation in sockets that use sockets From: David Miller In-Reply-To: <148881267372.2618.822975702493802450.stgit@warthog.procyon.org.uk> References: <148881267372.2618.822975702493802450.stgit@warthog.procyon.org.uk> X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 08 Mar 2017 23:06:28 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells Date: Mon, 06 Mar 2017 15:04:44 +0000 > Fix the general case by: > > (1) Double up all the locking keys used in sockets so that one set are > used if the socket is created by userspace and the other set is used > if the socket is created by the kernel. > > (2) Store the kern parameter passed to sk_alloc() in a variable in the > sock struct (sk_kern_sock). This informs sock_lock_init(), > sock_init_data() and sk_clone_lock() as to the lock keys to be used. > > Note that the child created by sk_clone_lock() inherits the parent's > kern setting. > > (3) Add a 'kern' parameter to ->accept() that is analogous to the one > passed in to ->create() that distinguishes whether kernel_accept() or > sys_accept4() was the caller and can be passed to sk_alloc(). > > Note that a lot of accept functions merely dequeue an already > allocated socket. I haven't touched these as the new socket already > exists before we get the parameter. > > Note also that there are a couple of places where I've made the accepted > socket unconditionally kernel-based: > > irda_accept() > rds_rcp_accept_one() > tcp_accept_from_sock() > > because they follow a sock_create_kern() and accept off of that. I guess this is fine, but I think you can use one of the two "sk_padding" bits in struct sock instead of making the structure larger.