From mboxrd@z Thu Jan 1 00:00:00 1970 From: Luis Chamberlain Date: Thu, 16 Apr 2020 06:44:05 +0000 Subject: [Ocfs2-devel] [PATCH 1/8] apparmor: just use vfs_kern_mount to make .null In-Reply-To: <20200414124304.4470-2-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> <20200414124304.4470-2-eesposit@redhat.com> Message-ID: <20200416064405.GP11244@42.do-not-panic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Emanuele Giuseppe Esposito , Goldwyn Rodrigues Cc: Song Liu , linux-usb@vger.kernel.org, bpf@vger.kernel.org, "Rafael J. Wysocki" , David Airlie , Heiko Carstens , Alexei Starovoitov , dri-devel@lists.freedesktop.org, "J. Bruce Fields" , Joseph Qi , Hugh Dickins , Paul Mackerras , John Johansen , linux-s390@vger.kernel.org, ocfs2-devel@oss.oracle.com, Christoph Hellwig , Andrew Donnellan , Matthew Garrett , linux-efi@vger.kernel.org, Arnd Bergmann , Daniel Borkmann , Christian Borntraeger , linux-rdma@vger.kernel.org, Michael Ellerman , Mark Fasheh , Anton Vorontsov , John Fastabend , James Morris , Ard Biesheuvel , Jason Gunthorpe , Doug Ledford , oprofile-list@lists.sf.net, Yonghong Song , Ian Kent , Andrii Nakryiko , Alexey Dobriyan , "Serge E. Hallyn" , netdev@vger.kernel.org, Robert Richter , Thomas Zimmermann , Vasily Gorbik , Tony Luck , Kees Cook , "James E.J. Bottomley" , autofs@vger.kernel.org, Mike Marciniszyn , linux-fsdevel@vger.kernel.org, "Manoj N. Kumar" , Uma Krishnan , Jakub Kicinski , KP Singh , Trond Myklebust , "Matthew R. Ochs" , "David S. Miller" , Felipe Balbi , linux-nfs@vger.kernel.org, Iurii Zaikin , linux-scsi@vger.kernel.org, "Martin K. Petersen" , linux-mm@kvack.org, Greg Kroah-Hartman , Dennis Dalessandro , Miklos Szeredi , linux-kernel@vger.kernel.org, Anna Schumaker , linux-security-module@vger.kernel.org, Chuck Lever , Jeremy Kerr , Colin Cross , Frederic Barrat , Paolo Bonzini , Andrew Morton , Mike Kravetz , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , Joel Becker , Alexander Viro On Tue, Apr 14, 2020 at 02:42:55PM +0200, Emanuele Giuseppe Esposito wrote: > aa_mk_null_file is using simple_pin_fs/simple_release_fs with local > variables as arguments, for what would amount to a simple > vfs_kern_mount/mntput pair if everything was inlined. Just use > the normal filesystem API since the reference counting is not needed > here. *Why* is refcounting not needed here? Luis > > Signed-off-by: Emanuele Giuseppe Esposito > --- > security/apparmor/apparmorfs.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c > index 280741fc0f5f..828bb1eb77ea 100644 > --- a/security/apparmor/apparmorfs.c > +++ b/security/apparmor/apparmorfs.c > @@ -2525,14 +2525,14 @@ struct path aa_null; > > static int aa_mk_null_file(struct dentry *parent) > { > - struct vfsmount *mount = NULL; > + struct file_system_type *type = parent->d_sb->s_type; > + struct vfsmount *mount; > struct dentry *dentry; > struct inode *inode; > - int count = 0; > - int error = simple_pin_fs(parent->d_sb->s_type, &mount, &count); > > - if (error) > - return error; > + mount = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL); > + if (IS_ERR(mount)) > + return PTR_ERR(mount); > > inode_lock(d_inode(parent)); > dentry = lookup_one_len(NULL_FILE_NAME, parent, strlen(NULL_FILE_NAME)); > @@ -2561,7 +2561,7 @@ static int aa_mk_null_file(struct dentry *parent) > dput(dentry); > out: > inode_unlock(d_inode(parent)); > - simple_release_fs(&mount, &count); > + mntput(mount); > return error; > } > > -- > 2.25.2 >