]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
zram: fix potential UAF of zram table
authorKairui Song <kasong@tencent.com>
Tue, 7 Jan 2025 06:54:46 +0000 (14:54 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 13 Jan 2025 03:03:37 +0000 (19:03 -0800)
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>
drivers/block/zram/zram_drv.c

index 45df5eeabc5e3df07ad8525a6b33813f0bb49749..7903a4da40acfb02aba7a7f5aee49d162965350f 100644 (file)
@@ -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;
        }