]> git.baikalelectronics.ru Git - kernel.git/commit
fscrypt: fix inline encryption not used on new files
authorEric Biggers <ebiggers@google.com>
Wed, 11 Nov 2020 01:52:24 +0000 (17:52 -0800)
committerEric Biggers <ebiggers@google.com>
Thu, 12 Nov 2020 04:59:07 +0000 (20:59 -0800)
commite061f80f67a9e38f6733c775f1d2e9a1fa835d2c
tree0044d8b76c5188e3cfba501b9237453cc35e3915
parent290ecdecddea621c48e537b2ab6a042901eb83bf
fscrypt: fix inline encryption not used on new files

The new helper function fscrypt_prepare_new_inode() runs before
S_ENCRYPTED has been set on the new inode.  This accidentally made
fscrypt_select_encryption_impl() never enable inline encryption on newly
created files, due to its use of fscrypt_needs_contents_encryption()
which only returns true when S_ENCRYPTED is set.

Fix this by using S_ISREG() directly instead of
fscrypt_needs_contents_encryption(), analogous to what
select_encryption_mode() does.

I didn't notice this earlier because by design, the user-visible
behavior is the same (other than performance, potentially) regardless of
whether inline encryption is used or not.

Fixes: 1fdf5882475e ("fscrypt: add fscrypt_prepare_new_inode() and fscrypt_set_context()")
Reviewed-by: Satya Tangirala <satyat@google.com>
Link: https://lore.kernel.org/r/20201111015224.303073-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/inline_crypt.c