lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <22d8f579-ed67-4c4f-9e62-5e32b8bd0a7d@kernel.org>
Date: Mon, 16 Jun 2025 20:26:32 +0800
From: Chao Yu <chao@...nel.org>
To: wangzijie <wangzijie1@...or.com>, jaegeuk@...nel.org
Cc: chao@...nel.org, linux-f2fs-devel@...ts.sourceforge.net,
 linux-kernel@...r.kernel.org, niuzhiguo84@...il.com, bintian.wang@...or.com,
 feng.han@...or.com
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid non-section-aligned size pinned
 file generation

On 6/13/25 18:38, wangzijie wrote:
> To prevent non-section-aligned size pinned file generated from truncation,
> add check condition in setattr. Meanwhile, clean up F2FS_I_SB.
> 
> Signed-off-by: wangzijie <wangzijie1@...or.com>
> ---
>  fs/f2fs/file.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 6bd3de64f..31ecf615b 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1026,9 +1026,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  {
>  	struct inode *inode = d_inode(dentry);
>  	struct f2fs_inode_info *fi = F2FS_I(inode);
> +	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> +	block_t sec_blks = CAP_BLKS_PER_SEC(sbi);
>  	int err;
>  
> -	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +	if (unlikely(f2fs_cp_error(sbi)))
>  		return -EIO;
>  
>  	if (unlikely(IS_IMMUTABLE(inode)))
> @@ -1047,6 +1049,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  			!IS_ALIGNED(attr->ia_size,
>  			F2FS_BLK_TO_BYTES(fi->i_cluster_size)))
>  			return -EINVAL;
> +		if (f2fs_is_pinned_file(inode) &&
> +			attr->ia_size < i_size_read(inode) &&
> +			!IS_ALIGNED(attr->ia_size,
> +			F2FS_BLK_TO_BYTES(sec_blks)))

F2FS_BLK_TO_BYTES(CAP_BLKS_PER_SEC(sbi))?

as this is the only case we use sec_blks in f2fs_setattr().

And can you please do cleanup on sbi in separated patch?

Thanks,

> +			return -EINVAL;
>  	}
>  
>  	err = setattr_prepare(idmap, dentry, attr);
> @@ -1068,12 +1075,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  	}
>  	if (i_uid_needs_update(idmap, attr, inode) ||
>  	    i_gid_needs_update(idmap, attr, inode)) {
> -		f2fs_lock_op(F2FS_I_SB(inode));
> +		f2fs_lock_op(sbi);
>  		err = dquot_transfer(idmap, inode, attr);
>  		if (err) {
> -			set_sbi_flag(F2FS_I_SB(inode),
> -					SBI_QUOTA_NEED_REPAIR);
> -			f2fs_unlock_op(F2FS_I_SB(inode));
> +			set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
> +			f2fs_unlock_op(sbi);
>  			return err;
>  		}
>  		/*
> @@ -1083,7 +1089,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  		i_uid_update(idmap, attr, inode);
>  		i_gid_update(idmap, attr, inode);
>  		f2fs_mark_inode_dirty_sync(inode, true);
> -		f2fs_unlock_op(F2FS_I_SB(inode));
> +		f2fs_unlock_op(sbi);
>  	}
>  
>  	if (attr->ia_valid & ATTR_SIZE) {
> @@ -1144,7 +1150,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  
>  	/* inode change will produce dirty node pages flushed by checkpoint */
> -	f2fs_balance_fs(F2FS_I_SB(inode), true);
> +	f2fs_balance_fs(sbi, true);
>  
>  	return err;
>  }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ