]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ext4: disable pwsalt ioctl when encryption disabled by config
authorEric Biggers <ebiggers@google.com>
Thu, 1 Dec 2016 16:55:51 +0000 (11:55 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 1 Dec 2016 16:55:51 +0000 (11:55 -0500)
On a CONFIG_EXT4_FS_ENCRYPTION=n kernel, the ioctls to get and set
encryption policies were disabled but EXT4_IOC_GET_ENCRYPTION_PWSALT was
not.  But there's no good reason to expose the pwsalt ioctl if the
kernel doesn't support encryption.  The pwsalt ioctl was also disabled
pre-4.8 (via ext4_sb_has_crypto() previously returning 0 when encryption
was disabled by config) and seems to have been enabled by mistake when
ext4 encryption was refactored to use fs/crypto/.  So let's disable it
again.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ioctl.c

index 560afe08a5cac4211c0010f0ab440d9190ceebed..fcc9510a819ca7744ad51bce62342ebfaddeaae3 100644 (file)
@@ -191,6 +191,7 @@ journal_err_out:
        return err;
 }
 
+#ifdef CONFIG_EXT4_FS_ENCRYPTION
 static int uuid_is_zero(__u8 u[16])
 {
        int     i;
@@ -200,6 +201,7 @@ static int uuid_is_zero(__u8 u[16])
                        return 0;
        return 1;
 }
+#endif
 
 static int ext4_ioctl_setflags(struct inode *inode,
                               unsigned int flags)
@@ -802,6 +804,7 @@ resizefs_out:
 #endif
        }
        case EXT4_IOC_GET_ENCRYPTION_PWSALT: {
+#ifdef CONFIG_EXT4_FS_ENCRYPTION
                int err, err2;
                struct ext4_sb_info *sbi = EXT4_SB(sb);
                handle_t *handle;
@@ -836,6 +839,9 @@ resizefs_out:
                                 sbi->s_es->s_encrypt_pw_salt, 16))
                        return -EFAULT;
                return 0;
+#else
+               return -EOPNOTSUPP;
+#endif
        }
        case EXT4_IOC_GET_ENCRYPTION_POLICY: {
 #ifdef CONFIG_EXT4_FS_ENCRYPTION