* [PATCH v2] zram: don't free statically defined names
@ 2024-09-23 16:11 Andrey Skvortsov
2024-09-23 16:16 ` Sergey Senozhatsky
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Skvortsov @ 2024-09-23 16:11 UTC (permalink / raw)
To: Venkat Rao Bagalkote, Minchan Kim, Sergey Senozhatsky, Jens Axboe,
Andrew Morton, linux-kernel, linux-block
Cc: Andrey Skvortsov, stable
The change is similar to that is used in comp_algorithm_set.
default_compressor is used for ZRAM_PRIMARY_COMP only, but if
CONFIG_ZRAM_MULTI_COMP isn't set, then ZRAM_PRIMARY_COMP and
ZRAM_SECONDARY_COMP are the same.
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
==================================================================
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fixes: 684826f8271a ("zram: free secondary algorithms names")
Cc: <stable@vger.kernel.org>
---
Changes in v2:
- removed comment from source code about freeing statically defined compression
- removed part of KASAN report from commit description
- added information about CONFIG_ZRAM_MULTI_COMP into commit description
drivers/block/zram/zram_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index c3d245617083d..4a9cdb7fe8878 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2116,7 +2116,8 @@ static void zram_destroy_comps(struct zram *zram)
}
for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
- kfree(zram->comp_algs[prio]);
+ if (zram->comp_algs[prio] != default_compressor)
+ kfree(zram->comp_algs[prio]);
zram->comp_algs[prio] = NULL;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] zram: don't free statically defined names
2024-09-23 16:11 [PATCH v2] zram: don't free statically defined names Andrey Skvortsov
@ 2024-09-23 16:16 ` Sergey Senozhatsky
0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2024-09-23 16:16 UTC (permalink / raw)
To: Andrew Morton
Cc: Andrey Skvortsov, Venkat Rao Bagalkote, Minchan Kim, Jens Axboe,
linux-kernel, linux-block, stable, Sergey Senozhatsky
On (24/09/23 19:11), Andrey Skvortsov wrote:
> The change is similar to that is used in comp_algorithm_set.
> default_compressor is used for ZRAM_PRIMARY_COMP only, but if
> CONFIG_ZRAM_MULTI_COMP isn't set, then ZRAM_PRIMARY_COMP and
> ZRAM_SECONDARY_COMP are the same.
>
> 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
> ==================================================================
>
> Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
> Fixes: 684826f8271a ("zram: free secondary algorithms names")
> Cc: <stable@vger.kernel.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-23 16:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 16:11 [PATCH v2] zram: don't free statically defined names Andrey Skvortsov
2024-09-23 16:16 ` Sergey Senozhatsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox