Re: [PATCH] ext4: fix #11321: create /proc/ext4/*/stats et al more carefully

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 09, 2008 at 12:12:03AM -0700, Andrew Morton wrote:
> On Tue, 9 Sep 2008 11:06:30 +0400 Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
> 
> > On Mon, Sep 08, 2008 at 10:39:51AM -0400, Theodore Tso wrote:
> > > Here's what I've checked into the ext4 patch queue for submission to
> > > mainline at the next merge window.  I've added a bit more error
> > > checking in case proc_mkdir() fails and returns NULL.
> > 
> > Hopefully, Andrew, will pick up original non-broken patch.
> 
> What does this mean??

Alexey's trying to bypass the ext4 maintainers.  :-)

Alexey, both of the problems which you pointed out I noticed last
night and have already been fixed and commited to the ext4 patch
queue.  Please see attached.  This patch *is* better than your
original one since using strdup is better than open coding it in C.

Andrew, note that some of the patches in the upcoming ext4 patch set
which I am preparing for -mm and linux-next submission depend on a the
percpu cleanup patch which is in already in -mm.  I've left it in the
ext4 series file since the patchset won't apply against mainline
without it, but I've left comments in the series file that should make
this clear.

I'm not sure how you are managing -mm these days, but it looks like
you are using git more, and so if you are pulling in changes in via
linux-next, git will do the right thing and drop the duplicated patch.
There is a similar issue with the FIEMAP patches and some ext3
patches, but the FIEMAP patches will get dropped since Eric has
promised to get on Mark Fasheh's case to submit for merging or to
submit them yourself, and the ext3 patches I will submit to you
separately.

Regards,

						- Ted

ext4: fix #11321: create /proc/ext4/*/stats more carefully

From: Alexey Dobriyan <adobriyan@xxxxxxxxx>

ext4 creates per-suberblock directory in /proc/ext4/ . Name used as
basis is taken from bdevname, which, surprise, can contain slash.

However, proc while allowing to use proc_create("a/b", parent) form of
PDE creation, assumes that parent/a was already created.

bdevname in question is 'cciss/c0d0p9', directory is not created and all
this stuff goes directly into /proc (which is real bug).

Warning comes when _second_ partition is mounted.

http://bugzilla.kernel.org/show_bug.cgi?id=11321

Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
Signed-off-by: "Theodore Ts'o" <tytso@xxxxxxx>
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 2721643..78d628b 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2785,14 +2785,20 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
 	mode_t mode = S_IFREG | S_IRUGO | S_IWUSR;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct proc_dir_entry *proc;
-	char devname[64];
+	char devname[64], *p;
 
 	if (proc_root_ext4 == NULL) {
 		sbi->s_mb_proc = NULL;
 		return -EINVAL;
 	}
 	bdevname(sb->s_bdev, devname);
+	p = devname;
+	while ((p = strchr(p, '/')))
+		*p = '!';
+
 	sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4);
+	if (!sbi->s_mb_proc)
+		goto err_create_dir;
 
 	MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats);
 	MB_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, max_to_scan);
@@ -2804,7 +2810,6 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
 	return 0;
 
 err_out:
-	printk(KERN_ERR "EXT4-fs: Unable to create %s\n", devname);
 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
 	remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc);
 	remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc);
@@ -2813,6 +2818,8 @@ err_out:
 	remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_mb_proc);
 	remove_proc_entry(devname, proc_root_ext4);
 	sbi->s_mb_proc = NULL;
+err_create_dir:
+	printk(KERN_ERR "EXT4-fs: Unable to create %s\n", devname);
 
 	return -ENOMEM;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux