[PATCH v4] ubifs: zero stale data beyond EOF before file size grows

Zhihao Cheng chengzhihao1 at huawei.com
Mon Oct 26 23:48:35 PDT 2026


在 2026/10/27 14:12, Nan Lin 写道:
>>> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> 
[...]
> 
>> Because the old-EOF folio is already uptodate, wouldn't ubifs_write_end()
> 
>> advance inode->i_size and ui->ui_size to pos + len even when copied < len,
> 
>> exposing the unzeroed stale mmap data in [pos + copied, pos + len)?
> 
>>
> 
>> By comparison, ext4_block_zero_eof() zeroes the entire tail of the old-EOF
> 
>> folio from old_size to folio_size(folio), and ext4_write_end() only advances
> 
>> i_size to pos + copied. Should ubifs_zero_eof_hole() also zero to the end of
> 
>> the folio (or be called whenever the write extends past i_size), or should
> 
>> ubifs_write_end() avoid extending i_size past pos + copied?
> 
> 
> 
> Valid concern. I think the short-copy issue is best handled separately
> 
> since it involves write_end() budget semantics and affects all buffered
> 
> writes, not just extending ones. Note that the i_size advance to pos + len on
> 
> short copies is pre-existing UBIFS behavior, not introduced by this patch.
> 
> Worth a dedicated analysis/patch but outside the scope of this fix.
> 

Agreed
> 
> .
> 




More information about the linux-mtd mailing list