public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH mm-hotfixes] mm/zswap: add missing kunmap_local()
@ 2026-03-16 14:01 Lorenzo Stoakes (Oracle)
  2026-03-16 14:52 ` Yosry Ahmed
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Lorenzo Stoakes (Oracle) @ 2026-03-16 14:01 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Yosry Ahmed, Nhat Pham, Chengming Zhou, linux-mm,
	linux-kernel

Commit e2c3b6b21c77 ("mm: zswap: use SG list decompression APIs from
zsmalloc") updated zswap_decompress() to use the scatterwalk API to copy
data for uncompressed pages.

In doing so, it mapped kernel memory locally for 32-bit kernels using
kmap_local_folio(), however it never unmapped this memory.

This resulted in the linked syzbot report where a BUG_ON() is triggered due
to leaking the kmap slot.

This patch fixes the issue by explicitly unmapping the established kmap.

Reported-by: syzbot+fe426bef95363177631d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/69b75e2c.050a0220.12d28.015a.GAE@google.com
Fixes: e2c3b6b21c77 ("mm: zswap: use SG list decompression APIs from zsmalloc")
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
---
 mm/zswap.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index e6ec3295bdb0..499520f65ff0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -942,9 +942,14 @@ static bool zswap_decompress(struct zswap_entry *entry, struct folio *folio)

 	/* zswap entries of length PAGE_SIZE are not compressed. */
 	if (entry->length == PAGE_SIZE) {
+		void *dst;
+
 		WARN_ON_ONCE(input->length != PAGE_SIZE);
-		memcpy_from_sglist(kmap_local_folio(folio, 0), input, 0, PAGE_SIZE);
+
+		dst = kmap_local_folio(folio, 0);
+		memcpy_from_sglist(dst, input, 0, PAGE_SIZE);
 		dlen = PAGE_SIZE;
+		kunmap_local(dst);
 	} else {
 		sg_init_table(&output, 1);
 		sg_set_folio(&output, folio, PAGE_SIZE, 0);
--
2.53.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-18 23:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 14:01 [PATCH mm-hotfixes] mm/zswap: add missing kunmap_local() Lorenzo Stoakes (Oracle)
2026-03-16 14:52 ` Yosry Ahmed
2026-03-16 15:49   ` Lorenzo Stoakes (Oracle)
2026-03-16 15:17 ` Johannes Weiner
2026-03-17  0:38 ` SeongJae Park
2026-03-17 10:01 ` Lorenzo Stoakes (Oracle)
2026-03-17 12:13   ` Lorenzo Stoakes (Oracle)
2026-03-17 12:59 ` Lorenzo Stoakes (Oracle)
2026-03-17 18:01   ` Andrew Morton
2026-03-17 19:01   ` Yosry Ahmed
2026-03-18  0:34   ` SeongJae Park
2026-03-18 23:15 ` Nhat Pham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox