mirror of https://github.com/OpenIPC/firmware.git
119 lines
3.0 KiB
Diff
119 lines
3.0 KiB
Diff
diff -drupN a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
|
|
--- a/fs/ext4/ioctl.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/fs/ext4/ioctl.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -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)
|
|
@@ -735,11 +737,13 @@ resizefs_out:
|
|
return err;
|
|
}
|
|
|
|
+ case FIDTRIM:
|
|
case FITRIM:
|
|
{
|
|
struct request_queue *q = bdev_get_queue(sb->s_bdev);
|
|
struct fstrim_range range;
|
|
int ret = 0;
|
|
+ int flags = cmd == FIDTRIM ? BLKDEV_DISCARD_SECURE : 0;
|
|
|
|
if (!capable(CAP_SYS_ADMIN))
|
|
return -EPERM;
|
|
@@ -747,13 +751,16 @@ resizefs_out:
|
|
if (!blk_queue_discard(q))
|
|
return -EOPNOTSUPP;
|
|
|
|
+ if ((flags & BLKDEV_DISCARD_SECURE) && !blk_queue_secure_erase(q))
|
|
+ return -EOPNOTSUPP;
|
|
+
|
|
if (copy_from_user(&range, (struct fstrim_range __user *)arg,
|
|
sizeof(range)))
|
|
return -EFAULT;
|
|
|
|
range.minlen = max((unsigned int)range.minlen,
|
|
q->limits.discard_granularity);
|
|
- ret = ext4_trim_fs(sb, &range);
|
|
+ ret = ext4_trim_fs(sb, &range, flags);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
@@ -765,28 +772,19 @@ resizefs_out:
|
|
}
|
|
case EXT4_IOC_PRECACHE_EXTENTS:
|
|
return ext4_ext_precache(inode);
|
|
- case EXT4_IOC_SET_ENCRYPTION_POLICY: {
|
|
-#ifdef CONFIG_EXT4_FS_ENCRYPTION
|
|
- struct fscrypt_policy policy;
|
|
|
|
+ case EXT4_IOC_SET_ENCRYPTION_POLICY:
|
|
if (!ext4_has_feature_encrypt(sb))
|
|
return -EOPNOTSUPP;
|
|
+ return fscrypt_ioctl_set_policy(filp, (const void __user *)arg);
|
|
|
|
- if (copy_from_user(&policy,
|
|
- (struct fscrypt_policy __user *)arg,
|
|
- sizeof(policy)))
|
|
- return -EFAULT;
|
|
- return fscrypt_process_policy(filp, &policy);
|
|
-#else
|
|
- return -EOPNOTSUPP;
|
|
-#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;
|
|
|
|
- if (!ext4_sb_has_crypto(sb))
|
|
+ if (!ext4_has_feature_encrypt(sb))
|
|
return -EOPNOTSUPP;
|
|
if (uuid_is_zero(sbi->s_es->s_encrypt_pw_salt)) {
|
|
err = mnt_want_write_file(filp);
|
|
@@ -816,30 +814,18 @@ resizefs_out:
|
|
sbi->s_es->s_encrypt_pw_salt, 16))
|
|
return -EFAULT;
|
|
return 0;
|
|
- }
|
|
- case EXT4_IOC_GET_ENCRYPTION_POLICY: {
|
|
-#ifdef CONFIG_EXT4_FS_ENCRYPTION
|
|
- struct fscrypt_policy policy;
|
|
- int err = 0;
|
|
-
|
|
- if (!ext4_encrypted_inode(inode))
|
|
- return -ENOENT;
|
|
- err = fscrypt_get_policy(inode, &policy);
|
|
- if (err)
|
|
- return err;
|
|
- if (copy_to_user((void __user *)arg, &policy, sizeof(policy)))
|
|
- return -EFAULT;
|
|
- return 0;
|
|
#else
|
|
return -EOPNOTSUPP;
|
|
#endif
|
|
}
|
|
+ case EXT4_IOC_GET_ENCRYPTION_POLICY:
|
|
+ return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
|
|
+
|
|
case EXT4_IOC_FSGETXATTR:
|
|
{
|
|
struct fsxattr fa;
|
|
|
|
memset(&fa, 0, sizeof(struct fsxattr));
|
|
- ext4_get_inode_flags(ei);
|
|
fa.fsx_xflags = ext4_iflags_to_xflags(ei->i_flags & EXT4_FL_USER_VISIBLE);
|
|
|
|
if (ext4_has_feature_project(inode->i_sb)) {
|