Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031833AbbKDXB4 (ORCPT ); Wed, 4 Nov 2015 18:01:56 -0500 Received: from www62.your-server.de ([213.133.104.62]:33975 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030385AbbKDXBy (ORCPT ); Wed, 4 Nov 2015 18:01:54 -0500 From: Daniel Borkmann To: gregkh@linuxfoundation.org Cc: rostedt@goodmis.org, viro@ZenIV.linux.org.uk, linux-kernel@vger.kernel.org, Daniel Borkmann Subject: [PATCH v2] debugfs: fix refcount imbalance in start_creating Date: Thu, 5 Nov 2015 00:01:51 +0100 Message-Id: <1d40118f3f42ca1e907cd7d4a254e53f4daa639d.1446672826.git.daniel@iogearbox.net> X-Mailer: git-send-email 1.9.3 X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1679 Lines: 48 In debugfs' 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. Looks like it was done in the past, but after splitting portions of __create_file() into start_creating() and end_creating() via 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off"), this seemed missed. Noticed during code review. Fixes: 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off") Signed-off-by: Daniel Borkmann --- v1 -> v2: - Split original patch into two patches (tracefs and debugfs) fs/debugfs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } -- 1.9.3 -- 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/