ext4: wire up FS_IOC_GET_ENCRYPTION_NONCE
authorEric Biggers <ebiggers@google.com>
Sat, 14 Mar 2020 20:50:50 +0000 (13:50 -0700)
committerEric Biggers <ebiggers@google.com>
Fri, 20 Mar 2020 04:56:59 +0000 (21:56 -0700)
This new ioctl retrieves a file's encryption nonce, which is useful for
testing.  See the corresponding fs/crypto/ patch for more details.

Link: https://lore.kernel.org/r/20200314205052.93294-3-ebiggers@kernel.org
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/ext4/ioctl.c

index a0ec750018dd383446de9436c20494051c1533f4..0c1d1720cf1ae04928c743e04286eb5a05755b49 100644 (file)
@@ -1210,6 +1210,11 @@ resizefs_out:
                        return -EOPNOTSUPP;
                return fscrypt_ioctl_get_key_status(filp, (void __user *)arg);
 
+       case FS_IOC_GET_ENCRYPTION_NONCE:
+               if (!ext4_has_feature_encrypt(sb))
+                       return -EOPNOTSUPP;
+               return fscrypt_ioctl_get_nonce(filp, (void __user *)arg);
+
        case EXT4_IOC_CLEAR_ES_CACHE:
        {
                if (!inode_owner_or_capable(inode))
@@ -1370,6 +1375,7 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case FS_IOC_REMOVE_ENCRYPTION_KEY:
        case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS:
        case FS_IOC_GET_ENCRYPTION_KEY_STATUS:
+       case FS_IOC_GET_ENCRYPTION_NONCE:
        case EXT4_IOC_SHUTDOWN:
        case FS_IOC_GETFSMAP:
        case FS_IOC_ENABLE_VERITY: