Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753998AbbKBTHq (ORCPT ); Mon, 2 Nov 2015 14:07:46 -0500 Received: from smtprelay0193.hostedemail.com ([216.40.44.193]:54958 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752544AbbKBTHo (ORCPT ); Mon, 2 Nov 2015 14:07:44 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2890:2901:2911:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:4321:4425:5007:6261:7875:10004:10400:10848:10967:11026:11232:11658:11914:12043:12517:12519:12555:12740:14093:14096:14097:21067:21080:21250:30012:30029:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: cats69_25fd0e5815f14 X-Filterd-Recvd-Size: 3190 Date: Mon, 2 Nov 2015 14:07:39 -0500 From: Steven Rostedt To: Daniel Borkmann Cc: viro@ZenIV.linux.org.uk, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tracefs, debugfs: fix refcount imbalance in start_creating Message-ID: <20151102140739.6e0d0d46@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2470 Lines: 73 On Fri, 9 Oct 2015 20:30:10 +0200 Daniel Borkmann wrote: > In tracefs' start_creating(), we pin the file system to safely access > its root. When we failed to create a file, we unpin the file system via > failed_creating() to release the mount count and eventually the reference > of the vfsmount. > > However, when we run into an error during lookup_one_len() when still > in start_creating(), we only release the parent's mutex but not so the > reference on the mount. > > F.e., in securityfs, after doing simple_pin_fs() when lookup_one_len() > fails there, we infact do simple_release_fs(). This seems necessary here > as well. The same also accounts for debugfs as the start_creating() code > was probably taken from there. Noticed during code review. > > Fixes: 4282d60689d4 ("tracefs: Add new tracefs file system") > Fixes: 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off") > Signed-off-by: Daniel Borkmann > Cc: Steven Rostedt > --- > fs/debugfs/inode.c | 6 +++++- > fs/tracefs/inode.c | 6 +++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c > index c711be8..9c8d233 100644 > --- a/fs/debugfs/inode.c > +++ b/fs/debugfs/inode.c > @@ -271,8 +271,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) > dput(dentry); > dentry = ERR_PTR(-EEXIST); > } > - if (IS_ERR(dentry)) > + > + if (IS_ERR(dentry)) { > mutex_unlock(&d_inode(parent)->i_mutex); > + simple_release_fs(&debugfs_mount, &debugfs_mount_count); > + } > + > return dentry; > } > > diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c > index cbc8d5d..c66f242 100644 > --- a/fs/tracefs/inode.c > +++ b/fs/tracefs/inode.c > @@ -340,8 +340,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) > dput(dentry); > dentry = ERR_PTR(-EEXIST); > } > - if (IS_ERR(dentry)) > + > + if (IS_ERR(dentry)) { > mutex_unlock(&parent->d_inode->i_mutex); > + simple_release_fs(&tracefs_mount, &tracefs_mount_count); > + } > + Acked-by: Steven Rostedt -- Steve > return dentry; > } > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/