summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 6a7349f9ac15..39fffc19e00c 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -496,6 +496,10 @@ static int f2fs_file_open(struct inode *inode, struct file *filp)
496 if (err) 496 if (err)
497 return err; 497 return err;
498 498
499 err = fsverity_file_open(inode, filp);
500 if (err)
501 return err;
502
499 filp->f_mode |= FMODE_NOWAIT; 503 filp->f_mode |= FMODE_NOWAIT;
500 504
501 return dquot_file_open(inode, filp); 505 return dquot_file_open(inode, filp);
@@ -778,6 +782,10 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
778 if (err) 782 if (err)
779 return err; 783 return err;
780 784
785 err = fsverity_prepare_setattr(dentry, attr);
786 if (err)
787 return err;
788
781 if (is_quota_modification(inode, attr)) { 789 if (is_quota_modification(inode, attr)) {
782 err = dquot_initialize(inode); 790 err = dquot_initialize(inode);
783 if (err) 791 if (err)
@@ -1705,7 +1713,8 @@ static const struct {
1705 FS_PROJINHERIT_FL | \ 1713 FS_PROJINHERIT_FL | \
1706 FS_ENCRYPT_FL | \ 1714 FS_ENCRYPT_FL | \
1707 FS_INLINE_DATA_FL | \ 1715 FS_INLINE_DATA_FL | \
1708 FS_NOCOW_FL) 1716 FS_NOCOW_FL | \
1717 FS_VERITY_FL)
1709 1718
1710#define F2FS_SETTABLE_FS_FL ( \ 1719#define F2FS_SETTABLE_FS_FL ( \
1711 FS_SYNC_FL | \ 1720 FS_SYNC_FL | \
@@ -1750,6 +1759,8 @@ static int f2fs_ioc_getflags(struct file *filp, unsigned long arg)
1750 1759
1751 if (IS_ENCRYPTED(inode)) 1760 if (IS_ENCRYPTED(inode))
1752 fsflags |= FS_ENCRYPT_FL; 1761 fsflags |= FS_ENCRYPT_FL;
1762 if (IS_VERITY(inode))
1763 fsflags |= FS_VERITY_FL;
1753 if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode)) 1764 if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode))
1754 fsflags |= FS_INLINE_DATA_FL; 1765 fsflags |= FS_INLINE_DATA_FL;
1755 if (is_inode_flag_set(inode, FI_PIN_FILE)) 1766 if (is_inode_flag_set(inode, FI_PIN_FILE))
@@ -3103,6 +3114,30 @@ static int f2fs_ioc_resize_fs(struct file *filp, unsigned long arg)
3103 return ret; 3114 return ret;
3104} 3115}
3105 3116
3117static int f2fs_ioc_enable_verity(struct file *filp, unsigned long arg)
3118{
3119 struct inode *inode = file_inode(filp);
3120
3121 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
3122
3123 if (!f2fs_sb_has_verity(F2FS_I_SB(inode))) {
3124 f2fs_warn(F2FS_I_SB(inode),
3125 "Can't enable fs-verity on inode %lu: the verity feature is not enabled on this filesystem.\n",
3126 inode->i_ino);
3127 return -EOPNOTSUPP;
3128 }
3129
3130 return fsverity_ioctl_enable(filp, (const void __user *)arg);
3131}
3132
3133static int f2fs_ioc_measure_verity(struct file *filp, unsigned long arg)
3134{
3135 if (!f2fs_sb_has_verity(F2FS_I_SB(file_inode(filp))))
3136 return -EOPNOTSUPP;
3137
3138 return fsverity_ioctl_measure(filp, (void __user *)arg);
3139}
3140
3106long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 3141long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3107{ 3142{
3108 if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp))))) 3143 if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
@@ -3171,6 +3206,10 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3171 return f2fs_ioc_precache_extents(filp, arg); 3206 return f2fs_ioc_precache_extents(filp, arg);
3172 case F2FS_IOC_RESIZE_FS: 3207 case F2FS_IOC_RESIZE_FS:
3173 return f2fs_ioc_resize_fs(filp, arg); 3208 return f2fs_ioc_resize_fs(filp, arg);
3209 case FS_IOC_ENABLE_VERITY:
3210 return f2fs_ioc_enable_verity(filp, arg);
3211 case FS_IOC_MEASURE_VERITY:
3212 return f2fs_ioc_measure_verity(filp, arg);
3174 default: 3213 default:
3175 return -ENOTTY; 3214 return -ENOTTY;
3176 } 3215 }
@@ -3290,6 +3329,8 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3290 case F2FS_IOC_SET_PIN_FILE: 3329 case F2FS_IOC_SET_PIN_FILE:
3291 case F2FS_IOC_PRECACHE_EXTENTS: 3330 case F2FS_IOC_PRECACHE_EXTENTS:
3292 case F2FS_IOC_RESIZE_FS: 3331 case F2FS_IOC_RESIZE_FS:
3332 case FS_IOC_ENABLE_VERITY:
3333 case FS_IOC_MEASURE_VERITY:
3293 break; 3334 break;
3294 default: 3335 default:
3295 return -ENOIOCTLCMD; 3336 return -ENOIOCTLCMD;