Skip to contentSkip to conversation

zram: fix potential UAF of zram table

PATCH Applied Kairui Song 2 participants 2 messages Jan 7, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zram: fix potential UAF of zram table

From: Kairui Song <[email protected]>

If zram_meta_alloc failed early, it frees allocated zram->table without setting it NULL. Which will potentially cause zram_meta_free to access the table if user reset an failed and uninitialized device.

Fixes 74363ec674cb ("zram: fix uninitialized ZRAM not releasing backing device")
---
 drivers/block/zram/zram_drv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/zram/zram_drv.c +1 -0
index 5b8e4f4171ab..70ecaee25c20 100644
@@ -1465,6 +1465,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
 	zram->mem_pool = zs_create_pool(zram->disk->disk_name);
 	if (!zram->mem_pool) {
 		vfree(zram->table);
+		zram->table = NULL;
 		return false;
 	}
 
Signature · 1 line
2.47.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Kairui Song

From: Kairui Song <[email protected]>

If zram_meta_alloc failed early, it frees allocated zram->table without setting it NULL. Which will potentially cause zram_meta_free to access the table if user reset an failed and uninitialized device.

Fixes 74363ec674cb ("zram: fix uninitialized ZRAM not releasing backing device")