ext4: reinforce check of i_dtime when clearing high fields of uid and gid
authorDaeho Jeong <daeho.jeong@samsung.com>
Tue, 6 Sep 2016 02:56:10 +0000 (22:56 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 23 Feb 2017 03:50:49 +0000 (03:50 +0000)
commit8adcceba11c91f02ee2aa2d85a7a6d12e8f20120
treed034e666b934ac27031cd04ecfd0a40e8251a434
parente5ff0240699d56229baa39f95a1b392c5b79a24d
ext4: reinforce check of i_dtime when clearing high fields of uid and gid

commit 93e3b4e6631d2a74a8cf7429138096862ff9f452 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: Daeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: Hobin Woo <hobin.woo@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/ext4/inode.c