ext4: fix up test_dummy_encryption handling for new mount API
authorEric Biggers <ebiggers@google.com>
Thu, 26 May 2022 04:04:12 +0000 (21:04 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 18 Jun 2022 23:35:43 +0000 (19:35 -0400)
commit85456054e10b0247920b00422d27365e689d9f4a
treec01c9d64c0452d12b1603bd287eafa5462f18136
parent4efd9f0d120c55b08852ee5605dbb02a77089a5d
ext4: fix up test_dummy_encryption handling for new mount API

Since ext4 was converted to the new mount API, the test_dummy_encryption
mount option isn't being handled entirely correctly, because the needed
fscrypt_set_test_dummy_encryption() helper function combines
parsing/checking/applying into one function.  That doesn't work well
with the new mount API, which split these into separate steps.

This was sort of okay anyway, due to the parsing logic that was copied
from fscrypt_set_test_dummy_encryption() into ext4_parse_param(),
combined with an additional check in ext4_check_test_dummy_encryption().
However, these overlooked the case of changing the value of
test_dummy_encryption on remount, which isn't allowed but ext4 wasn't
detecting until ext4_apply_options() when it's too late to fail.
Another bug is that if test_dummy_encryption was specified multiple
times with an argument, memory was leaked.

Fix this up properly by using the new helper functions that allow
splitting up the parse/check/apply steps for test_dummy_encryption.

Fixes: cebe85d570cf ("ext4: switch to the new mount api")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20220526040412.173025-1-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c