From: ebiederm@xmission.com (Eric W. Biederman)
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: <linux-kernel@vger.kernel.org>, Al Viro <viro@ZenIV.linux.org.uk>,
Tejun Heo <tj@kernel.org>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] sysfs: Take sysfs_mutex when fetching the root inode.
Date: Wed, 21 Jan 2009 11:55:11 -0800 [thread overview]
Message-ID: <m13afch1sw.fsf@fess.ebiederm.org> (raw)
sysfs_get_inode ultimately calls sysfs_count_nlink when the a
directory inode is fectched. sysfs_count_nlink needs to be
called under the sysfs_mutex to guard against the unlikely
but possible scenario that the root directory is changing
as we are counting the number entries in it, and just in
general to be consistent.
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
fs/sysfs/mount.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index ab343e3..f3e34fd 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -53,7 +53,9 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
sysfs_sb = sb;
/* get root inode, initialize and unlock it */
+ mutex_lock(&sysfs_mutex);
inode = sysfs_get_inode(&sysfs_root);
+ mutex_unlock(&sysfs_mutex);
if (!inode) {
pr_debug("sysfs: could not get root inode\n");
return -ENOMEM;
--
1.5.6.3
next reply other threads:[~2009-01-21 19:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-21 19:55 Eric W. Biederman [this message]
2009-01-22 16:49 ` [PATCH] sysfs: Reference sysfs_dirent from sysfs inodes Eric W. Biederman
2009-01-23 6:33 ` Tejun Heo
2009-01-27 23:44 ` Andrew Morton
2009-01-28 0:47 ` Tejun Heo
2009-02-02 17:03 ` Eric W. Biederman
2009-01-23 6:28 ` [PATCH] sysfs: Take sysfs_mutex when fetching the root inode Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m13afch1sw.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=cornelia.huck@de.ibm.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox