diff mbox series

[e2fsprogs,9/9] tune2fs: Prevent enabling encryption flag on encoding-aware fs

Message ID 20181015211220.27370-10-krisman@collabora.co.uk
State Superseded
Headers show
Series Support encoding awareness and casefold | expand

Commit Message

Gabriel Krisman Bertazi Oct. 15, 2018, 9:12 p.m. UTC
The kernel will refuse to mount filesystems with the encryption and
encoding features enabled at the same time.  The encoding feature can
only be set at mount time, so we can just prevent encryption from being
set at a later time by tune2fs.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
---
 misc/tune2fs.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Theodore Ts'o Nov. 21, 2018, 5:03 a.m. UTC | #1
On Mon, Oct 15, 2018 at 05:12:20PM -0400, Gabriel Krisman Bertazi wrote:
> The kernel will refuse to mount filesystems with the encryption and
> encoding features enabled at the same time.  The encoding feature can
> only be set at mount time, so we can just prevent encryption from being
> set at a later time by tune2fs.
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>

This check also needs to be in mke2fs, right?  I don't think I saw it
in your mke2fs patch.

					- Ted
Gabriel Krisman Bertazi Nov. 21, 2018, 7:46 p.m. UTC | #2
"Theodore Y. Ts'o" <tytso@mit.edu> writes:

> On Mon, Oct 15, 2018 at 05:12:20PM -0400, Gabriel Krisman Bertazi wrote:
>> The kernel will refuse to mount filesystems with the encryption and
>> encoding features enabled at the same time.  The encoding feature can
>> only be set at mount time, so we can just prevent encryption from being
>> set at a later time by tune2fs.
>> 
>> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
>
> This check also needs to be in mke2fs, right?  I don't think I saw it
> in your mke2fs patch.

I hadn't noticed you could set the encryption flag at mkfs time.
sorry.  will fix in v3.
diff mbox series

Patch

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index a680b461cc86..cda4d8076f81 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -1459,6 +1459,12 @@  mmp_error:
 	}
 
 	if (FEATURE_ON(E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_ENCRYPT)) {
+		if (ext2fs_has_feature_fname_encoding(sb)) {
+			fputs(_("Cannot enable feature 'encrypt' on filesystems "
+				"with the 'encoding' feature enabled.\n"),
+			      stderr);
+			return 1;
+		}
 		fs->super->s_encrypt_algos[0] =
 			EXT4_ENCRYPTION_MODE_AES_256_XTS;
 		fs->super->s_encrypt_algos[1] =