diff options
author | Eric Biggers <ebiggers@google.com> | 2019-08-04 22:35:48 -0400 |
---|---|---|
committer | Eric Biggers <ebiggers@google.com> | 2019-08-12 22:18:50 -0400 |
commit | 29b3692e6dbf82266ec3c2764c236f8708d7fc89 (patch) | |
tree | 984c157afd0e2d1491c7aab26c9e13b8934ea905 | |
parent | 5ab7189a31bad40e4b44020cae6e56c8074721a1 (diff) |
ext4: wire up new fscrypt ioctls
Wire up the new ioctls for adding and removing fscrypt keys to/from the
filesystem, and the new ioctl for retrieving v2 encryption policies.
The key removal ioctls also required making ext4_drop_inode() call
fscrypt_drop_inode().
For more details see Documentation/filesystems/fscrypt.rst and the
fscrypt patches that added the implementation of these ioctls.
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r-- | fs/ext4/ioctl.c | 30 | ||||
-rw-r--r-- | fs/ext4/super.c | 3 |
2 files changed, 33 insertions, 0 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 442f7ef873fc..fe5a4b13f939 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -1115,6 +1115,31 @@ resizefs_out: | |||
1115 | case EXT4_IOC_GET_ENCRYPTION_POLICY: | 1115 | case EXT4_IOC_GET_ENCRYPTION_POLICY: |
1116 | return fscrypt_ioctl_get_policy(filp, (void __user *)arg); | 1116 | return fscrypt_ioctl_get_policy(filp, (void __user *)arg); |
1117 | 1117 | ||
1118 | case FS_IOC_GET_ENCRYPTION_POLICY_EX: | ||
1119 | if (!ext4_has_feature_encrypt(sb)) | ||
1120 | return -EOPNOTSUPP; | ||
1121 | return fscrypt_ioctl_get_policy_ex(filp, (void __user *)arg); | ||
1122 | |||
1123 | case FS_IOC_ADD_ENCRYPTION_KEY: | ||
1124 | if (!ext4_has_feature_encrypt(sb)) | ||
1125 | return -EOPNOTSUPP; | ||
1126 | return fscrypt_ioctl_add_key(filp, (void __user *)arg); | ||
1127 | |||
1128 | case FS_IOC_REMOVE_ENCRYPTION_KEY: | ||
1129 | if (!ext4_has_feature_encrypt(sb)) | ||
1130 | return -EOPNOTSUPP; | ||
1131 | return fscrypt_ioctl_remove_key(filp, (void __user *)arg); | ||
1132 | |||
1133 | case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS: | ||
1134 | if (!ext4_has_feature_encrypt(sb)) | ||
1135 | return -EOPNOTSUPP; | ||
1136 | return fscrypt_ioctl_remove_key_all_users(filp, | ||
1137 | (void __user *)arg); | ||
1138 | case FS_IOC_GET_ENCRYPTION_KEY_STATUS: | ||
1139 | if (!ext4_has_feature_encrypt(sb)) | ||
1140 | return -EOPNOTSUPP; | ||
1141 | return fscrypt_ioctl_get_key_status(filp, (void __user *)arg); | ||
1142 | |||
1118 | case EXT4_IOC_FSGETXATTR: | 1143 | case EXT4_IOC_FSGETXATTR: |
1119 | { | 1144 | { |
1120 | struct fsxattr fa; | 1145 | struct fsxattr fa; |
@@ -1231,6 +1256,11 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1231 | case EXT4_IOC_SET_ENCRYPTION_POLICY: | 1256 | case EXT4_IOC_SET_ENCRYPTION_POLICY: |
1232 | case EXT4_IOC_GET_ENCRYPTION_PWSALT: | 1257 | case EXT4_IOC_GET_ENCRYPTION_PWSALT: |
1233 | case EXT4_IOC_GET_ENCRYPTION_POLICY: | 1258 | case EXT4_IOC_GET_ENCRYPTION_POLICY: |
1259 | case FS_IOC_GET_ENCRYPTION_POLICY_EX: | ||
1260 | case FS_IOC_ADD_ENCRYPTION_KEY: | ||
1261 | case FS_IOC_REMOVE_ENCRYPTION_KEY: | ||
1262 | case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS: | ||
1263 | case FS_IOC_GET_ENCRYPTION_KEY_STATUS: | ||
1234 | case EXT4_IOC_SHUTDOWN: | 1264 | case EXT4_IOC_SHUTDOWN: |
1235 | case FS_IOC_GETFSMAP: | 1265 | case FS_IOC_GETFSMAP: |
1236 | break; | 1266 | break; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 4079605d437a..757819139b8f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1107,6 +1107,9 @@ static int ext4_drop_inode(struct inode *inode) | |||
1107 | { | 1107 | { |
1108 | int drop = generic_drop_inode(inode); | 1108 | int drop = generic_drop_inode(inode); |
1109 | 1109 | ||
1110 | if (!drop) | ||
1111 | drop = fscrypt_drop_inode(inode); | ||
1112 | |||
1110 | trace_ext4_drop_inode(inode, drop); | 1113 | trace_ext4_drop_inode(inode, drop); |
1111 | return drop; | 1114 | return drop; |
1112 | } | 1115 | } |