]> git.baikalelectronics.ru Git - kernel.git/commit
ext4: fix error handling in ext4_end_enable_verity()
authorEric Biggers <ebiggers@google.com>
Tue, 2 Mar 2021 20:04:19 +0000 (12:04 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Mar 2021 15:38:50 +0000 (10:38 -0500)
commit033eaebebc40f34a31b79e889508bc77a8e2baef
tree0c81b0b773d4f5e5b595ced3b6953df807fa5276
parent695b2ec6a3903d810ec319f4bb1b8e86ba2d6dfb
ext4: fix error handling in ext4_end_enable_verity()

ext4 didn't properly clean up if verity failed to be enabled on a file:

- It left verity metadata (pages past EOF) in the page cache, which
  would be exposed to userspace if the file was later extended.

- It didn't truncate the verity metadata at all (either from cache or
  from disk) if an error occurred while setting the verity bit.

Fix these bugs by adding a call to truncate_inode_pages() and ensuring
that we truncate the verity metadata (both from cache and from disk) in
all error paths.  Also rework the code to cleanly separate the success
path from the error paths, which makes it much easier to understand.

Reported-by: Yunlei He <heyunlei@hihonor.com>
Fixes: cf061e77dc1d ("ext4: add basic fs-verity support")
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20210302200420.137977-2-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/verity.c