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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250701015314.3992659-1-wangzijie1@honor.com>
Date: Tue, 1 Jul 2025 09:53:14 +0800
From: wangzijie <wangzijie1@...or.com>
To: <linux-f2fs-devel@...ts.sourceforge.net>
CC: <feng.han@...or.com>, <jaegeuk@...nel.org>,
	<linux-kernel@...r.kernel.org>, <wangzijie1@...or.com>
Subject: Re: [f2fs-dev] [PATCH v5 2/2] f2fs: don't allow unaligned truncation to smaller/equal size on pinned file

>I think we can clean up more like this?
>
>https://lore.kernel.org/linux-f2fs-devel/20250630160839.1142073-1-jaegeuk@kernel.org/T/#u

Hi Kim,
Yes, I think we can apply the patch you showed and v4 of this patch. Thank you.
 
https://lore.kernel.org/linux-f2fs-devel/20250624035938.3176350-1-wangzijie1@honor.com/
https://lore.kernel.org/linux-f2fs-devel/20250624035938.3176350-2-wangzijie1@honor.com/

>On 06/30, wangzijie wrote:
>> To prevent scattered pin block generation, don't allow non-section aligned truncation
>> to smaller or equal size on pinned file. But for truncation to larger size, after
>> commit 3fdd89b452c2("f2fs: prevent writing without fallocate() for pinned files"),
>> we only support overwrite IO to pinned file, so we don't need to consider
>> attr->ia_size > i_size case.
>> In addition, xfstests #494 assumes truncation on active swapfile(pinned) will return
>> ETXTBSY by setattr_prepare() -> inode_newsize_ok(), so we relocate this check after
>> setattr_prepare().
>> 
>> Signed-off-by: wangzijie <wangzijie1@...or.com>
>> ---
>> v5:
>> - fix xfstests #494 fail
>> ---
>>  fs/f2fs/file.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>> 
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 78368b793..d4feea44b 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -1070,6 +1070,23 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>>  	if (err)
>>  		return err;
>>  
>> +	/*
>> +	 * To prevent scattered pin block generation, we don't allow
>> +	 * smaller/equal size unaligned truncation for pinned file.
>> +	 * We only support overwrite IO to pinned file, so don't
>> +	 * care about larger size truncation.
>> +	 * We need to check this after setattr_prepare() because xfstests
>> +	 * #494 assumes truncation on active swapfile(pinned) will
>> +	 * return ETXTBSY by setattr_prepare() -> inode_newsize_ok().
>> +	 */
>> +	if (attr->ia_valid & ATTR_SIZE) {
>> +		if (f2fs_is_pinned_file(inode) &&
>> +			attr->ia_size <= i_size_read(inode) &&
>> +			!IS_ALIGNED(attr->ia_size,
>> +			F2FS_BLK_TO_BYTES(CAP_BLKS_PER_SEC(sbi))))
>> +			return -EINVAL;
>> +	}
>> +
>>  	err = fscrypt_prepare_setattr(dentry, attr);
>>  	if (err)
>>  		return err;
>> -- 
>> 2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ