PROBLEM: Corrupt inode flags when remove ATTR_SYS flag on fat file system mounted with “sys_immutable” mount option.
Hello,
Inode flags are corrupted when removing ATTR_SYS flag by FAT_IOCTL_SET_ATTRIBUTES ioctl on fat file system mounted with “sys_immutable” mount option. In this case S_IMMUTABLE flag must be removed from inode flags, but actually removed all other flags except S_IMMUTABLE. This problem observed on 2.6.34 kernel, but it seems still exist( after examine of 2.6.39 kernel source code ).
The problem in fat_ioctl_set_attributes function( fs/fat/file.c ). This function contains following code(2.6.39 kernel):
101 if (sbi->options.sys_immutable) {
102 if (attr & ATTR_SYS)
103 inode->i_flags |= S_IMMUTABLE;
104 else
105 inode->i_flags &= S_IMMUTABLE;
106 }
Instead of removing S_IMMUTABLE flag from inode flags on line 105 function removes all other flags from inode flags. I think that line 105 must be following:
105 inode->i_flags &= ~S_IMMUTABLE;
Regards,
Dmitry
Quoted 12 lines · On Tue, 31 May 2011 12:27:24 +0400 Dmitry Dmitriev <[email protected]> wrote:
Hello,
Inode flags are corrupted when removing
ATTR_SYSflag byFAT_IOCTL_SET_ATTRIBUTESioctl on fat file system mounted with___sys_immutable___mount option. In this caseS_IMMUTABLEflag must be removed from inode flags, but actually removed all other flags exceptS_IMMUTABLE. This problem observed on 2.6.34 kernel, but it seems still exist( after examine of 2.6.39 kernel source code ).The problem in
fat_ioctl_set_attributesfunction(fs/fat/file.c). This function contains following code(2.6.39 kernel):
101 if (sbi->options.sys_immutable) {
102 if (attr &ATTR_SYS)
103inode->i_flags|=S_IMMUTABLE;
104 else
105inode->i_flags&=S_IMMUTABLE;
106 }
Quoted 4 lines
Instead of removing
S_IMMUTABLEflag from inode flags on line 105 function removes all other flags from inode flags. I think that line 105 must be following:105
inode->i_flags&= ~S_IMMUTABLE;
Thank, I queued this:
From: Andrew Morton <[email protected]>
Inode flags are corrupted when removing ATTR_SYS flag by FAT_IOCTL_SET_ATTRIBUTES ioctl on fat file system mounted with `sys_immutable' mount option.
Fix fat-fingered bitop from 21bea495943f9532 ("fat: split fat_generic_ioctl").
---
fs/fat/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/file.c renamed from fs/fat/file.c~fs-fat-filec-fix-clearing-of-s_immutable +1 -1
@@ -102,7 +102,7 @@ static int fat_ioctl_set_attributes(struif (attr &ATTR_SYS ) inode->i_flags |=S_IMMUTABLE ;else - inode->i_flags &=S_IMMUTABLE ; + inode->i_flags &= ~S_IMMUTABLE ; }fat_save_attrs (inode, attr);
_