summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorKairui Song <kasong@tencent.com>2025-01-07 07:54:46 +0100
committerAndrew Morton <akpm@linux-foundation.org>2025-01-13 04:03:37 +0100
commit212fe1c0df4a150fb6298db2cfff267ceaba5402 (patch)
treeede7fb9e7142bab77a0481f45304244462af815e /drivers/block
parentselftests/mm: set allocated memory to non-zero content in cow test (diff)
downloadlinux-212fe1c0df4a150fb6298db2cfff267ceaba5402.tar.xz
linux-212fe1c0df4a150fb6298db2cfff267ceaba5402.zip
zram: fix potential UAF of zram table
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. Link: https://lkml.kernel.org/r/20250107065446.86928-1-ryncsn@gmail.com Fixes: 74363ec674cb ("zram: fix uninitialized ZRAM not releasing backing device") Signed-off-by: Kairui Song <kasong@tencent.com> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/zram/zram_drv.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 45df5eeabc5e..7903a4da40ac 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1468,6 +1468,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;
}