Commit 8adcceba authored by Daeho Jeong's avatar Daeho Jeong Committed by Ben Hutchings

ext4: reinforce check of i_dtime when clearing high fields of uid and gid

commit 93e3b4e6 upstream.

Now, ext4_do_update_inode() clears high 16-bit fields of uid/gid
of deleted and evicted inode to fix up interoperability with old
kernels. However, it checks only i_dtime of an inode to determine
whether the inode was deleted and evicted, and this is very risky,
because i_dtime can be used for the pointer maintaining orphan inode
list, too. We need to further check whether the i_dtime is being
used for the orphan inode list even if the i_dtime is not NULL.

We found that high 16-bit fields of uid/gid of inode are unintentionally
and permanently cleared when the inode truncation is just triggered,
but not finished, and the inode metadata, whose high uid/gid bits are
cleared, is written on disk, and the sudden power-off follows that
in order.
Signed-off-by: default avatarDaeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: default avatarHobin Woo <hobin.woo@samsung.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent e5ff0240
...@@ -4093,14 +4093,14 @@ static int ext4_do_update_inode(handle_t *handle, ...@@ -4093,14 +4093,14 @@ static int ext4_do_update_inode(handle_t *handle,
* Fix up interoperability with old kernels. Otherwise, old inodes get * Fix up interoperability with old kernels. Otherwise, old inodes get
* re-used with the upper 16 bits of the uid/gid intact * re-used with the upper 16 bits of the uid/gid intact
*/ */
if (!ei->i_dtime) { if (ei->i_dtime && list_empty(&ei->i_orphan)) {
raw_inode->i_uid_high = 0;
raw_inode->i_gid_high = 0;
} else {
raw_inode->i_uid_high = raw_inode->i_uid_high =
cpu_to_le16(high_16_bits(inode->i_uid)); cpu_to_le16(high_16_bits(inode->i_uid));
raw_inode->i_gid_high = raw_inode->i_gid_high =
cpu_to_le16(high_16_bits(inode->i_gid)); cpu_to_le16(high_16_bits(inode->i_gid));
} else {
raw_inode->i_uid_high = 0;
raw_inode->i_gid_high = 0;
} }
} else { } else {
raw_inode->i_uid_low = raw_inode->i_uid_low =
......
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