Patch "zram: don't free statically defined names" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    zram: don't free statically defined names

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     zram-don-t-free-statically-defined-names.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3cba76e7dc5cedd04870351833938bf1e2692c30
Author: Andrey Skvortsov <andrej.skvortzov@xxxxxxxxx>
Date:   Wed Oct 9 13:51:40 2024 +0900

    zram: don't free statically defined names
    
    [ Upstream commit 486fd58af7ac1098b68370b1d4d9f94a2a1c7124 ]
    
    When CONFIG_ZRAM_MULTI_COMP isn't set ZRAM_SECONDARY_COMP can hold
    default_compressor, because it's the same offset as ZRAM_PRIMARY_COMP, so
    we need to make sure that we don't attempt to kfree() the statically
    defined compressor name.
    
    This is detected by KASAN.
    
    ==================================================================
      Call trace:
       kfree+0x60/0x3a0
       zram_destroy_comps+0x98/0x198 [zram]
       zram_reset_device+0x22c/0x4a8 [zram]
       reset_store+0x1bc/0x2d8 [zram]
       dev_attr_store+0x44/0x80
       sysfs_kf_write+0xfc/0x188
       kernfs_fop_write_iter+0x28c/0x428
       vfs_write+0x4dc/0x9b8
       ksys_write+0x100/0x1f8
       __arm64_sys_write+0x74/0xb8
       invoke_syscall+0xd8/0x260
       el0_svc_common.constprop.0+0xb4/0x240
       do_el0_svc+0x48/0x68
       el0_svc+0x40/0xc8
       el0t_64_sync_handler+0x120/0x130
       el0t_64_sync+0x190/0x198
    ==================================================================
    
    Link: https://lkml.kernel.org/r/20240923164843.1117010-1-andrej.skvortzov@xxxxxxxxx
    Fixes: 684826f8271a ("zram: free secondary algorithms names")
    Signed-off-by: Andrey Skvortsov <andrej.skvortzov@xxxxxxxxx>
    Reviewed-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
    Reported-by: Venkat Rao Bagalkote <venkat88@xxxxxxxxxxxxxxxxxx>
    Closes: https://lore.kernel.org/lkml/57130e48-dbb6-4047-a8c7-ebf5aaea93f4@xxxxxxxxxxxxxxxxxx/
    Tested-by: Venkat Rao Bagalkote <venkat88@xxxxxxxxxxxxxxxxxx>
    Cc: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
    Cc: Jens Axboe <axboe@xxxxxxxxx>
    Cc: Minchan Kim <minchan@xxxxxxxxxx>
    Cc: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
    Cc: Venkat Rao Bagalkote <venkat88@xxxxxxxxxxxxxxxxxx>
    Cc: Chris Li <chrisl@xxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index db729035fd6bf..606f388c7a571 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1984,8 +1984,10 @@ static void zram_destroy_comps(struct zram *zram)
 		zram->num_active_comps--;
 	}
 
-	for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
-		kfree(zram->comp_algs[prio]);
+	for (prio = ZRAM_PRIMARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
+		/* Do not free statically defined compression algorithms */
+		if (zram->comp_algs[prio] != default_compressor)
+			kfree(zram->comp_algs[prio]);
 		zram->comp_algs[prio] = NULL;
 	}
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux