aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-05-31 23:46:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-09 11:33:04 -0400
commiteeb7cb57cf619ae9ab8210b21b49820ed40a472f (patch)
treeaef576ca6a445f87ba08089b2f06774dc6eee200 /fs
parent801bdd926b6229da233f6db25770c9e817f98d4e (diff)
ext4: don't trash state flags in EXT4_IOC_SETFLAGS
commit 79906964a187c405db72a3abc60eb9b50d804fbc upstream. In commit 353eb83c we removed i_state_flags with 64-bit longs, But when handling the EXT4_IOC_SETFLAGS ioctl, we replace i_flags directly, which trashes the state flags which are stored in the high 32-bits of i_flags on 64-bit platforms. So use the the ext4_{set,clear}_inode_flags() functions which use atomic bit manipulation functions instead. Reported-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ioctl.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 808c554e773..892427d8d35 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -35,7 +35,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35 handle_t *handle = NULL; 35 handle_t *handle = NULL;
36 int err, migrate = 0; 36 int err, migrate = 0;
37 struct ext4_iloc iloc; 37 struct ext4_iloc iloc;
38 unsigned int oldflags; 38 unsigned int oldflags, mask, i;
39 unsigned int jflag; 39 unsigned int jflag;
40 40
41 if (!inode_owner_or_capable(inode)) 41 if (!inode_owner_or_capable(inode))
@@ -112,8 +112,14 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
112 if (err) 112 if (err)
113 goto flags_err; 113 goto flags_err;
114 114
115 flags = flags & EXT4_FL_USER_MODIFIABLE; 115 for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {
116 flags |= oldflags & ~EXT4_FL_USER_MODIFIABLE; 116 if (!(mask & EXT4_FL_USER_MODIFIABLE))
117 continue;
118 if (mask & flags)
119 ext4_set_inode_flag(inode, i);
120 else
121 ext4_clear_inode_flag(inode, i);
122 }
117 ei->i_flags = flags; 123 ei->i_flags = flags;
118 124
119 ext4_set_inode_flags(inode); 125 ext4_set_inode_flags(inode);