lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240923080211.820185-1-andrej.skvortzov@gmail.com>
Date: Mon, 23 Sep 2024 11:02:11 +0300
From: Andrey Skvortsov <andrej.skvortzov@...il.com>
To: Minchan Kim <minchan@...nel.org>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Jens Axboe <axboe@...nel.dk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	linux-block@...r.kernel.org
Cc: Andrey Skvortsov <andrej.skvortzov@...il.com>,
	stable@...r.kernel.org
Subject: [PATCH] zram: don't free statically defined names

The change is similar to that is used in comp_algorithm_set.
This is detected by KASAN.

==================================================================
 Unable to handle kernel paging request at virtual address ffffffffc1edc3c8
 KASAN: maybe wild-memory-access in range
 [0x0003fffe0f6e1e40-0x0003fffe0f6e1e47]
 Mem abort info:
   ESR = 0x0000000096000006
   EC = 0x25: DABT (current EL), IL = 32 bits
   SET = 0, FnV = 0
   EA = 0, S1PTW = 0
   FSC = 0x06: level 2 translation fault
 Data abort info:
   ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000
   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
 swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000427dc000
 [ffffffffc1edc3c8] pgd=00000000430e7003, p4d=00000000430e7003,
 pud=00000000430e8003, pmd=0000000000000000
 Internal error: Oops: 0000000096000006 [#1] SMP

 Tainted: [W]=WARN, [C]=CRAP, [N]=TEST
 Hardware name: Pine64 PinePhone (1.2) (DT)
 pstate: a0000005 (NzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : kfree+0x60/0x3a0
 lr : zram_destroy_comps+0x98/0x198 [zram]
 sp : ffff800089b57450
 x29: ffff800089b57460 x28: 0000000000000004 x27: ffff800082833010
 x26: 1fffe00000c8039c x25: 1fffe00000ba5004 x24: ffff000005d28000
 x23: ffff800082533178 x22: ffff80007b71eaa8 x21: ffff000006401ce8
 x20: ffff80007b70f7a0 x19: ffffffffc1edc3c0 x18: 1ffff00010506d6b
 x17: 0000000000000000 x16: 0000000000000000 x15: ffff8000808e85e4
 x14: ffff8000808e8478 x13: ffff80008003fa50 x12: ffff80008003f87c
 x11: ffff800080011550 x10: ffff800081ee63f0 x9 : ffff80007b71eaa8
 x8 : ffff80008003fa50 x7 : ffff80008003f87c x6 : 00000018a10e2f30
 x5 : 00ffffffffffffff x4 : ffff00000ec93200 x3 : ffff00000bbee6e0
 x2 : 0000000000000000 x1 : 0000000000000000 x0 : fffffdffc0000000

 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
 Code: b26287e0 d34cfe73 f2dfbfe0 8b131813 (f9400660)
==================================================================

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@...il.com>
Fixes: 684826f8271a ("zram: free secondary algorithms names")
Cc: <stable@...r.kernel.org>
---
 drivers/block/zram/zram_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index c3d245617083d..d9d2c36658f59 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2116,7 +2116,9 @@ static void zram_destroy_comps(struct zram *zram)
 	}
 
 	for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
-		kfree(zram->comp_algs[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;
 	}
 
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ