linux/drivers/block/zram
Andrey Skvortsov 486fd58af7 zram: don't free statically defined names
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@gmail.com
Fixes: 684826f827 ("zram: free secondary algorithms names")
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reported-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Closes: https://lore.kernel.org/lkml/57130e48-dbb6-4047-a8c7-ebf5aaea93f4@linux.vnet.ibm.com/
Tested-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Cc: Chris Li <chrisl@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-09-26 14:01:44 -07:00
..
backend_842.c zram: move immutable comp params away from per-CPU context 2024-09-09 16:39:10 -07:00
backend_842.h zram: add 842 compression backend support 2024-09-09 16:39:08 -07:00
backend_deflate.c zram: move immutable comp params away from per-CPU context 2024-09-09 16:39:10 -07:00
backend_deflate.h zram: add zlib compression backend support 2024-09-09 16:39:08 -07:00
backend_lz4.c zram: add dictionary support to lz4 2024-09-09 16:39:11 -07:00
backend_lz4.h zram: add lz4 compression backend support 2024-09-09 16:39:07 -07:00
backend_lz4hc.c zram: add dictionary support to lz4hc 2024-09-09 16:39:11 -07:00
backend_lz4hc.h zram: add lz4hc compression backend support 2024-09-09 16:39:07 -07:00
backend_lzo.c zram: move immutable comp params away from per-CPU context 2024-09-09 16:39:10 -07:00
backend_lzo.h zram: add lzo and lzorle compression backends support 2024-09-09 16:39:07 -07:00
backend_lzorle.c zram: move immutable comp params away from per-CPU context 2024-09-09 16:39:10 -07:00
backend_lzorle.h zram: add lzo and lzorle compression backends support 2024-09-09 16:39:07 -07:00
backend_zstd.c zram: add dictionary support to zstd backend 2024-09-09 16:39:11 -07:00
backend_zstd.h zram: add zstd compression backend support 2024-09-09 16:39:08 -07:00
Kconfig zram: check that backends array has at least one backend 2024-09-09 16:39:09 -07:00
Makefile zram: add 842 compression backend support 2024-09-09 16:39:08 -07:00
zcomp.c zram: move immutable comp params away from per-CPU context 2024-09-09 16:39:10 -07:00
zcomp.h zram: move immutable comp params away from per-CPU context 2024-09-09 16:39:10 -07:00
zram_drv.c zram: don't free statically defined names 2024-09-26 14:01:44 -07:00
zram_drv.h ALong with the usual shower of singleton patches, notable patch series in 2024-09-21 07:29:05 -07:00