aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-05-31 23:46:01 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-05-31 23:46:01 -0400
commit79906964a187c405db72a3abc60eb9b50d804fbc (patch)
treebb9cec1905d268cda5d46a95b993e0a173c226c4 /fs/ext4
parent9660755100ae7677d65772a28e16d475a2ee9eab (diff)
ext4: don't trash state flags in EXT4_IOC_SETFLAGS
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> Cc: stable@kernel.org
Diffstat (limited to 'fs/ext4')
-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 feba55a225a6..8ad112ae0ade 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -38,7 +38,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38 handle_t *handle = NULL; 38 handle_t *handle = NULL;
39 int err, migrate = 0; 39 int err, migrate = 0;
40 struct ext4_iloc iloc; 40 struct ext4_iloc iloc;
41 unsigned int oldflags; 41 unsigned int oldflags, mask, i;
42 unsigned int jflag; 42 unsigned int jflag;
43 43
44 if (!inode_owner_or_capable(inode)) 44 if (!inode_owner_or_capable(inode))
@@ -115,8 +115,14 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
115 if (err) 115 if (err)
116 goto flags_err; 116 goto flags_err;
117 117
118 flags = flags & EXT4_FL_USER_MODIFIABLE; 118 for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {
119 flags |= oldflags & ~EXT4_FL_USER_MODIFIABLE; 119 if (!(mask & EXT4_FL_USER_MODIFIABLE))
120 continue;
121 if (mask & flags)
122 ext4_set_inode_flag(inode, i);
123 else
124 ext4_clear_inode_flag(inode, i);
125 }
120 ei->i_flags = flags; 126 ei->i_flags = flags;
121 127
122 ext4_set_inode_flags(inode); 128 ext4_set_inode_flags(inode);