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: <87fs7c3nvl.fsf@suse.de>
Date:   Wed, 31 May 2023 09:29:18 +0100
From:   Luís Henriques <lhenriques@...e.de>
To:     Joseph Qi <joseph.qi@...ux.alibaba.com>
Cc:     Mark Fasheh <mark@...heh.com>, Joel Becker <jlbec@...lplan.org>,
        Heming Zhao <heming.zhao@...e.com>, ocfs2-devel@....oracle.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ocfs2: check new file size on fallocate call

Joseph Qi <joseph.qi@...ux.alibaba.com> writes:

> On 5/29/23 11:26 PM, Luís Henriques wrote:
>> When changing a file size with fallocate() the new size isn't being
>> checked.  In particular, the FSIZE ulimit isn't being checked, which makes
>> fstest generic/228 fail.  Simply adding a call to inode_newsize_ok() fixes
>> this issue.
>> 
>> Signed-off-by: Luís Henriques <lhenriques@...e.de>
>> ---
>>  fs/ocfs2/file.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>> 
>> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
>> index efb09de4343d..b173c36bcab3 100644
>> --- a/fs/ocfs2/file.c
>> +++ b/fs/ocfs2/file.c
>> @@ -2100,14 +2100,20 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
>>  	struct ocfs2_space_resv sr;
>>  	int change_size = 1;
>>  	int cmd = OCFS2_IOC_RESVSP64;
>> +	int ret = 0;
>>  
>>  	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
>>  		return -EOPNOTSUPP;
>
> This means we only support keep-size and pouch_hole.
> And it seems pouch_hole will also imply keep-size.

I think you're forgetting about mode = 0, which is also valid.  And the
default '0' will allow size to be changed.

>>  	if (!ocfs2_writes_unwritten_extents(osb))
>>  		return -EOPNOTSUPP;
>>  
>> -	if (mode & FALLOC_FL_KEEP_SIZE)
>> +	if (mode & FALLOC_FL_KEEP_SIZE) {
>>  		change_size = 0;
>> +	} else {
>
> Seems this will be a dead branch?

Again, you need to consider '0' as a valid mode value.  If you run
generic/228 without this patch you'll see that test failing because it
*does* hit this branch.

Cheers,
-- 
Luís

>
> Thanks,
> Joseph
>
>> +		ret = inode_newsize_ok(inode, offset + len);
>> +		if (ret)
>> +			return ret;
>> +	}
>>  
>>  	if (mode & FALLOC_FL_PUNCH_HOLE)
>>  		cmd = OCFS2_IOC_UNRESVSP64;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ