Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754274AbdLSPoK (ORCPT ); Tue, 19 Dec 2017 10:44:10 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:34202 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754230AbdLSPoG (ORCPT ); Tue, 19 Dec 2017 10:44:06 -0500 Date: Tue, 19 Dec 2017 15:44:01 +0000 From: Al Viro To: Giuseppe Scrivano Cc: Andrew Morton , LKML , alexander.deucher@amd.com, broonie@kernel.org, chris@chris-wilson.co.uk, David Miller , deepa.kernel@gmail.com, Greg KH , luc.vanoostenryck@gmail.com, lucien xin , Ingo Molnar , Neil Horman , syzkaller-bugs@googlegroups.com, Vladislav Yasevich Subject: Re: [PATCH linux-next] mqueue: fix IPC namespace use-after-free Message-ID: <20171219154400.GS21978@ZenIV.linux.org.uk> References: <20171219101440.19736-1-gscrivan@redhat.com> <20171219114819.GQ21978@ZenIV.linux.org.uk> <20171219153225.GA14771@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171219153225.GA14771@ZenIV.linux.org.uk> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1260 Lines: 38 On Tue, Dec 19, 2017 at 03:32:25PM +0000, Al Viro wrote: > + m = mq_internal_mount(); > + if (IS_ERR(m)) > + return ERR_CAST(m); > + atomic_inc(&m->mnt_sb->s_active); > + down_write(&m->mnt_sb->s_umount); > + return dget(m->mnt_root); Note: this is stripped down mount_subtree(m, ""), of course; it might make sense to recognize that case and bypass the create_mnt_ns/vfs_path_lookup/put_mnt_ns business in mount_subtree() when the relative pathname is empty, replacing it with path.mnt = mntget(mnt); path.dentry = dget(mnt->mnt_root); in such case. That'd allow to simply call mount_subtree() here. It would work as-is, but it's ridiculously heavy for such use right now. > static int __init init_mqueue_fs(void) > { > + struct vfsmount *m; > int error; > > mqueue_inode_cachep = kmem_cache_create("mqueue_inode_cache", > @@ -1577,6 +1606,10 @@ static int __init init_mqueue_fs(void) > if (error) > goto out_filesystem; > > + m = kern_mount_data(&mqueue_fs_type, &init_ipc_ns); > + if (IS_ERR(m)) > + goto out_filesystem; > + init_ipc_ns.mq_mnt = m; > return 0; > > out_filesystem: Unrelated issue, but register_filesystem() should be the last thing module_init() of a filesystem driver does. It's a separate story, in any case...