Commit 9d1f716f authored by Manfred Spraul's avatar Manfred Spraul Committed by Linus Torvalds

[PATCH] `i_version' initialization fix

Ahm.

No. It must be i_version = 1

Otherwise there is a trivial bug:
    mkdir("dir");
    <force the directory out of dcache>
    dir = open("dir");
    lseek(dir,1,SEEK_SET);
    readdir();

lseek sets f_version to 0, and readdir() trusts f_pos, because i_version
is 0, too. This applies to all filesystems.

The ext2 patch already sets i_version to 1.
parent c93c0f1e
...@@ -92,7 +92,7 @@ static struct inode *affs_alloc_inode(struct super_block *sb) ...@@ -92,7 +92,7 @@ static struct inode *affs_alloc_inode(struct super_block *sb)
ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL); ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL);
if (!ei) if (!ei)
return NULL; return NULL;
ei->vfs_inode.i_version = 0; ei->vfs_inode.i_version = 1;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -434,7 +434,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb) ...@@ -434,7 +434,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
ei->i_acl = EXT3_ACL_NOT_CACHED; ei->i_acl = EXT3_ACL_NOT_CACHED;
ei->i_default_acl = EXT3_ACL_NOT_CACHED; ei->i_default_acl = EXT3_ACL_NOT_CACHED;
#endif #endif
ei->vfs_inode.i_version = 0; ei->vfs_inode.i_version = 1;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -119,7 +119,7 @@ struct inode *fat_build_inode(struct super_block *sb, ...@@ -119,7 +119,7 @@ struct inode *fat_build_inode(struct super_block *sb,
if (!inode) if (!inode)
goto out; goto out;
inode->i_ino = iunique(sb, MSDOS_ROOT_INO); inode->i_ino = iunique(sb, MSDOS_ROOT_INO);
inode->i_version = 0; inode->i_version = 1;
*res = fat_fill_inode(inode, de); *res = fat_fill_inode(inode, de);
if (*res < 0) { if (*res < 0) {
iput(inode); iput(inode);
...@@ -970,7 +970,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, ...@@ -970,7 +970,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
if (!root_inode) if (!root_inode)
goto out_fail; goto out_fail;
root_inode->i_ino = MSDOS_ROOT_INO; root_inode->i_ino = MSDOS_ROOT_INO;
root_inode->i_version = 0; root_inode->i_version = 1;
error = fat_read_root(root_inode); error = fat_read_root(root_inode);
if (error < 0) if (error < 0)
goto out_fail; goto out_fail;
......
...@@ -166,7 +166,7 @@ static struct inode *hpfs_alloc_inode(struct super_block *sb) ...@@ -166,7 +166,7 @@ static struct inode *hpfs_alloc_inode(struct super_block *sb)
ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_KERNEL); ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_KERNEL);
if (!ei) if (!ei)
return NULL; return NULL;
ei->vfs_inode.i_version = 0; ei->vfs_inode.i_version = 1;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -495,7 +495,7 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -495,7 +495,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
* This is for checking whether an inode has changed w.r.t. a file so * This is for checking whether an inode has changed w.r.t. a file so
* that the file can be updated if necessary (compare with f_version). * that the file can be updated if necessary (compare with f_version).
*/ */
vi->i_version = 0; vi->i_version = 1;
vi->i_uid = vol->uid; vi->i_uid = vol->uid;
vi->i_gid = vol->gid; vi->i_gid = vol->gid;
......
...@@ -1006,7 +1006,7 @@ static struct inode *ufs_alloc_inode(struct super_block *sb) ...@@ -1006,7 +1006,7 @@ static struct inode *ufs_alloc_inode(struct super_block *sb)
ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL); ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL);
if (!ei) if (!ei)
return NULL; return NULL;
ei->vfs_inode.i_version = 0; ei->vfs_inode.i_version = 1;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment