public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sysfs: Take sysfs_mutex when fetching the root inode.
@ 2009-01-21 19:55 Eric W. Biederman
  2009-01-22 16:49 ` [PATCH] sysfs: Reference sysfs_dirent from sysfs inodes Eric W. Biederman
  2009-01-23  6:28 ` [PATCH] sysfs: Take sysfs_mutex when fetching the root inode Tejun Heo
  0 siblings, 2 replies; 7+ messages in thread
From: Eric W. Biederman @ 2009-01-21 19:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Al Viro, Tejun Heo, Cornelia Huck, Andrew Morton


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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-02 17:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-21 19:55 [PATCH] sysfs: Take sysfs_mutex when fetching the root inode Eric W. Biederman
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox