Skip to content

Commit 93e3b4e

Browse files
daehojeongtytso
authored andcommitted
ext4: reinforce check of i_dtime when clearing high fields of uid and gid
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. Cc: stable@vger.kernel.org Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com> Signed-off-by: Hobin Woo <hobin.woo@samsung.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 8913f34 commit 93e3b4e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎fs/ext4/inode.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4814,14 +4814,14 @@ static int ext4_do_update_inode(handle_t *handle,
48144814
* Fix up interoperability with old kernels. Otherwise, old inodes get
48154815
* re-used with the upper 16 bits of the uid/gid intact
48164816
*/
4817-
if (!ei->i_dtime) {
4817+
if (ei->i_dtime && list_empty(&ei->i_orphan)) {
4818+
raw_inode->i_uid_high = 0;
4819+
raw_inode->i_gid_high = 0;
4820+
} else {
48184821
raw_inode->i_uid_high =
48194822
cpu_to_le16(high_16_bits(i_uid));
48204823
raw_inode->i_gid_high =
48214824
cpu_to_le16(high_16_bits(i_gid));
4822-
} else {
4823-
raw_inode->i_uid_high = 0;
4824-
raw_inode->i_gid_high = 0;
48254825
}
48264826
} else {
48274827
raw_inode->i_uid_low = cpu_to_le16(fs_high2lowuid(i_uid));

0 commit comments

Comments
 (0)