Re: [PATCH] filemap: Init the newly allocated folio memory to 0 for the filemap

From: Al Viro
Date: Wed Jul 31 2024 - 22:59:08 EST


On Thu, Aug 01, 2024 at 10:27:39AM +0800, Lizhi Xu wrote:
> syzbot report KMSAN: uninit-value in pick_link, this is because the
> corresponding folio was not found from the mapping, and the memory was
> not initialized when allocating a new folio for the filemap.
>
> To avoid the occurrence of kmsan report uninit-value, initialize the
> newly allocated folio memory to 0.

NAK.

You are papering over the real bug here.

That page either
* has been returned by find_get_page(), cached, uptodate and
with uninitialized contents or
* has been returned by successful read_mapping_page() - and
left with uninitialized contents or
* had inode->i_size in excess of initialized contents.

I'd suggest bisecting that.