Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp798717ybk; Fri, 15 May 2020 13:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEHjzoyFq2fTkrI9ZwkJvc/fBj2YotnwBcY9oP6C5EpGQ4wctIzNoZrA2hAko5lAMdH/u6 X-Received: by 2002:a17:906:5004:: with SMTP id s4mr4797059ejj.13.1589576303987; Fri, 15 May 2020 13:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589576303; cv=none; d=google.com; s=arc-20160816; b=RXYcGjHrTmTa2YjsjLgBNcKhr2vYErz20FhoXwLGyQzpDGrXAjlLdmgBj+hesZQ+Df vDeG/GiiwxrdXX+dc2LWwTA6yu9kJzo5KlaxxSQ9LxmzwAuB9IwQgXTvdyvfVH3VXe2S qriJ1KW0RVPoKDNHmEV9QLZoRwPDntUNp739k2rwN1xa8jaolGWxCcGBlLcYQZxW5Am4 SXyNo1qYTe4bvNWdo2uZbQ15+Cn/DKq8D6ivx8H+AnBb8f7IZd/8t6pBw3QUN9eP0L+F PnkdAFXjHxtwkuIhVduAOO1ALVOSv6Y1qhQhyJnXS5PFjCmwlzYJsHnQhzO3UzAVjc3e Wzfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mkXHF99ItSYGo2N3dAgW8W79fmgjivwlWir2kQRzDRc=; b=ZnkXsjPnkgUBifuQmxVyD9scHmiTwkntwmY0Ev3buOAzGczRRtT6uxtLjqUBXfw3EU XF4Fi2xtZoBpSyrlZQK2N9tBIDyHlUKVuLFZF7D3A1IZhciLu9NKQb4edunkqtR+JJjt eOualbwnNf72nHbh1ahXT8V/d8UY6LT24OMh6R8kDZ4wYT9oik60BwT8vgfIj+tb9p1M 6hDyWbGtyxutmSPbfA6dtgXqk2aaaxIEOoICQfvmZClCd2iaLF/GljE9x1Di5PHcbIps UddAMPH0V2pFf4f5rKuRlfN7YKbJAqLt7dNMQgvO4vTs9as4l/+38aTDLWiYb2UYhvqk 6qkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ny24si2013473ejb.445.2020.05.15.13.58.01; Fri, 15 May 2020 13:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgEOU4m (ORCPT + 99 others); Fri, 15 May 2020 16:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgEOU4m (ORCPT ); Fri, 15 May 2020 16:56:42 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D092AC061A0C; Fri, 15 May 2020 13:56:41 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZhNV-009Hh7-7g; Fri, 15 May 2020 20:56:21 +0000 Date: Fri, 15 May 2020 21:56:21 +0100 From: Al Viro To: Olga Kornievskaia Cc: Alexey Gladkov , "Eric W. Biederman" , syzbot , jmorris@namei.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, linux-security-module@vger.kernel.org, serge@hallyn.com, sfr@canb.auug.org.au, syzkaller-bugs@googlegroups.com, linux-fsdevel , ".Tetsuo Handa" Subject: Re: linux-next boot error: general protection fault in tomoyo_get_local_path Message-ID: <20200515205621.GH23230@ZenIV.linux.org.uk> References: <0000000000002f0c7505a5b0e04c@google.com> <72cb7aea-92bd-d71b-2f8a-63881a35fad8@i-love.sakura.ne.jp> <20200515201357.GG23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200515201357.GG23230@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 09:13:57PM +0100, Al Viro wrote: > On Sat, May 16, 2020 at 12:36:28AM +0900, Tetsuo Handa wrote: > > On 2020/05/16 0:18, Tetsuo Handa wrote: [snip] > > A similar bug (racing inode destruction with open() on proc filesystem) was fixed as > > commit 6f7c41374b62fd80 ("tomoyo: Don't use nifty names on sockets."). Then, it might > > not be safe to replace dentry->d_sb->s_fs_info with dentry->d_inode->i_sb->s_fs_info . > > Could you explain why do you want to bother with d_inode() anyway? Anything that > does dentry->d_inode->i_sb can bloody well use dentry->d_sb. And that's never > changed over the struct dentry lifetime - ->d_sb is set on allocation and never > modified afterwards. Incidentally, this r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr, NULL); (in nfs42_ssc_open()) is just plain weird. 1) d->d_inode->i_sb is equal to d->d_sb 2) m->mnt_root->d_sb is equal to m->mnt_sb IOW, the whole thing should be r_ino = nfs_fhget(ss_mnt->mnt_sb, src_fh, &fattr, NULL); Moreover, server = NFS_SERVER(ss_mnt->mnt_root->d_inode); in the same function is again too convoluted for no good reason, seeing that NFS_SERVER(inode) is NFS_SB(inode->i_sb). Something along the lines of nfs: don't obfuscate ->mnt_sb as ->mnt_root->d_inode->i_sb Signed-off-by: Al Viro --- diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 8e5d6223ddd3..1e8ca45bc806 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -317,15 +317,14 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh, { struct nfs_fattr fattr; struct file *filep, *res; - struct nfs_server *server; + struct super_block *sb = ss_mnt->mnt_sb; + struct nfs_server *server = NFS_SB(sb); struct inode *r_ino = NULL; struct nfs_open_context *ctx; struct nfs4_state_owner *sp; char *read_name = NULL; int len, status = 0; - server = NFS_SERVER(ss_mnt->mnt_root->d_inode); - nfs_fattr_init(&fattr); status = nfs4_proc_getattr(server, src_fh, &fattr, NULL, NULL); @@ -341,8 +340,7 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh, goto out; snprintf(read_name, len, SSC_READ_NAME_BODY, read_name_gen++); - r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr, - NULL); + r_ino = nfs_fhget(sb, src_fh, &fattr, NULL); if (IS_ERR(r_ino)) { res = ERR_CAST(r_ino); goto out_free_name;