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: <610525a1-5fb5-475e-9842-dc145aaf8718@huaweicloud.com>
Date: Wed, 30 Apr 2025 18:54:29 +0800
From: Zhang Yi <yi.zhang@...weicloud.com>
To: Jan Kara <jack@...e.cz>
Cc: linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
 linux-kernel@...r.kernel.org, tytso@....edu, adilger.kernel@...ger.ca,
 wanghaichi0403@...il.com, yi.zhang@...wei.com, libaokun1@...wei.com,
 yukuai3@...wei.com, yangerkun@...wei.com
Subject: Re: [PATCH 2/4] ext4: fix incorrect punch max_end

On 2025/4/30 18:09, Jan Kara wrote:
> On Wed 30-04-25 16:44:25, Zhang Yi wrote:
>> On 2025/4/30 16:18, Jan Kara wrote:
>>> On Wed 30-04-25 09:12:59, Zhang Yi wrote:
>>>> From: Zhang Yi <yi.zhang@...wei.com>
>>>>
>>>> For the extents inodes, the maxbytes should be sb->s_maxbytes instead of
>>>> sbi->s_bitmap_maxbytes. Correct the maxbytes value to correct the
>>>> behavior of punch hole.
>>>>
>>>> Fixes: 2da376228a24 ("ext4: limit length to bitmap_maxbytes - blocksize in punch_hole")
>>>> Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
>>>
>>> Thinking about this some more...
>>>
>>>> @@ -4015,6 +4015,12 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
>>>>  	trace_ext4_punch_hole(inode, offset, length, 0);
>>>>  	WARN_ON_ONCE(!inode_is_locked(inode));
>>>>  
>>>> +	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
>>>> +		max_end = sb->s_maxbytes;
>>>> +	else
>>>> +		max_end = EXT4_SB(sb)->s_bitmap_maxbytes;
>>>> +	max_end -= sb->s_blocksize;
>>>
>>> I think the -= sb->s_blocksize is needed only for indirect-block based
>>> scheme (due to an implementation quirk in ext4_ind_remove_space()). But
>>> ext4_ext_remove_space() should be fine with punch hole ending right at
>>> sb->s_maxbytes. And since I find it somewhat odd that you can create file
>>> upto s_maxbytes but cannot punch hole to the end, it'd limit that behavior
>>> as much as possible. Ideally we'd fix ext4_ind_remove_space() but I can't
>>> be really bothered for the ancient format...
>>>
>>
>> Yes, I share your feelings. Currently, we do not seem to have any
>> practical issues. To maintain consistent behavior between the two inode
>> types and to keep the code simple, I retained the -= sb->s_blocksize
>> operation. Would you suggest that we should at least address the extents
>> inodes by removing the -=sb->s_blocksize now?
> 
> Yes, what I'm suggesting is that we keep -=sb->s_blocksize specific for the
> case !ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS).
> 

Sure. Let's do it.

Thanks,
Yi.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ