Re: [PATCH] make last_inode counter in new_inode 32-bit on kernels that offer x86 compatability

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

 



On Tue, 2006-11-07 at 18:56 +0100, Jörn Engel wrote:
> Things are getting more interesting.  simple_fill_super() looked like
> a bug waiting to happen.  It is fairly hard to trigger, but still.
> This should fix it, although in a fairly crude manner.
> 
> The other callers were save - it is hard to have the root inode
> collide with anything existing.
> 
> Jörn
> 

Jörn,
  How about this patch instead here? I don't think anything depends on
i_ino being any certain value for these files, and this seems less
"magic-numbery". This should also mostly prevent us from assigning out
i_ino=0.

Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>

diff --git a/fs/libfs.c b/fs/libfs.c
index bd08e0e..506268e 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -373,6 +373,8 @@ int simple_fill_super(struct super_block
 	inode = new_inode(s);
 	if (!inode)
 		return -ENOMEM;
+	/* ino must not collide with any ino assigned in the loop below */
+	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
 	inode->i_uid = inode->i_gid = 0;
 	inode->i_blocks = 0;
@@ -385,7 +387,7 @@ int simple_fill_super(struct super_block
 		iput(inode);
 		return -ENOMEM;
 	}
-	for (i = 0; !files->name || files->name[0]; i++, files++) {
+	for (i = 2; !files->name || files->name[0]; i++, files++) {
 		if (!files->name)
 			continue;
 		dentry = d_alloc_name(root, files->name);


-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux