Re: [syzbot] Re: [syzbot] [squashfs?] KMSAN: uninit-value in pick_link

From: syzbot
Date: Wed Jul 31 2024 - 22:12:01 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [squashfs?] KMSAN: uninit-value in pick_link
Author: lizhi.xu@xxxxxxxxxxxxx

if alloc new folio for filemap, init mem to zero

#syz test: upstream 2f8c4f506285

diff --git a/mm/filemap.c b/mm/filemap.c
index 657bcd887fdb..1b22eab691e8 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3753,6 +3753,11 @@ static struct folio *do_read_cache_folio(struct address_space *mapping,
folio = filemap_alloc_folio(gfp, 0);
if (!folio)
return ERR_PTR(-ENOMEM);
+
+ void *kaddr = kmap_local_folio(folio, 0);
+ memset(kaddr, 0, folio_size(folio));
+ kunmap_local(kaddr);
+
err = filemap_add_folio(mapping, folio, index, gfp);
if (unlikely(err)) {
folio_put(folio);