Skip to contentSkip to conversation

erofs: fix wrong kunmap when using LZMA on HIGHMEM platforms

PATCH In review Gao Xiang 3 participants 3 messages Mar 5, 2023 – Mar 9, 2023

Subsystems (2)
lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: fix wrong kunmap when using LZMA on HIGHMEM platforms

As the call trace shown, the root cause is kunmap incorrect pages:

 BUG: kernel NULL pointer dereference, address: 00000000
 CPU: 1 PID: 40 Comm: kworker/u5:0 Not tainted 6.2.0-rc5 #4
 Workqueue: erofs_worker z_erofs_decompressqueue_work
 EIP: z_erofs_lzma_decompress+0x34b/0x8ac
  z_erofs_decompress+0x12/0x14
  z_erofs_decompress_queue+0x7e7/0xb1c
  z_erofs_decompressqueue_work+0x32/0x60
  process_one_work+0x24b/0x4d8
  ? process_one_work+0x1a4/0x4d8
  worker_thread+0x14c/0x3fc
  kthread+0xe6/0x10c
  ? rescuer_thread+0x358/0x358
  ? kthread_complete_and_exit+0x18/0x18
  ret_from_fork+0x1c/0x28
 ---[ end trace 0000000000000000 ]---

The bug is trivial and should be fixed now. It has no impact on !HIGHMEM platforms.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Cc <[email protected]> # 5.16+
---
 fs/erofs/decompressor_lzma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/decompressor_lzma.c +1 -1
index 091fd5adf818..5cd612a8f858 100644
@@ -278,7 +278,7 @@ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
 		}
 	}
 	if (no < nrpages_out && strm->buf.out)
-		kunmap(rq->in[no]);
+		kunmap(rq->out[no]);
 	if (ni < nrpages_in)
 		kunmap(rq->in[ni]);
 	/* 4. push back LZMA stream context to the global list */
Signature · 1 line
2.24.4
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · On Sun, 5 Mar 2023 21:44:55 +0800 Gao Xiang <[email protected]>…

As the call trace shown, the root cause is kunmap incorrect pages:

 BUG: kernel NULL pointer dereference, address: 00000000
 CPU: 1 PID: 40 Comm: kworker/u5:0 Not tainted 6.2.0-rc5 #4
 Workqueue: erofs_worker z_erofs_decompressqueue_work
 EIP: z_erofs_lzma_decompress+0x34b/0x8ac
  z_erofs_decompress+0x12/0x14
  z_erofs_decompress_queue+0x7e7/0xb1c
  z_erofs_decompressqueue_work+0x32/0x60
  process_one_work+0x24b/0x4d8
  ? process_one_work+0x1a4/0x4d8
  worker_thread+0x14c/0x3fc
  kthread+0xe6/0x10c
  ? rescuer_thread+0x358/0x358
  ? kthread_complete_and_exit+0x18/0x18
  ret_from_fork+0x1c/0x28
 ---[ end trace 0000000000000000 ]---
Quoted 6 lines

The bug is trivial and should be fixed now. It has no impact on !HIGHMEM platforms.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Cc <[email protected]> # 5.16+
Quoted 17 lines
---
 fs/erofs/decompressor_lzma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/decompressor_lzma.c +1 -1
index 091fd5adf818..5cd612a8f858 100644
@@ -278,7 +278,7 @@ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
 		}
 	}
 	if (no < nrpages_out && strm->buf.out)
-		kunmap(rq->in[no]);
+		kunmap(rq->out[no]);
 	if (ni < nrpages_in)
 		kunmap(rq->in[ni]);
 	/* 4. push back LZMA stream context to the global list */
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gao Xiang
Quoted 18 lines · Gao Xiang

As the call trace shown, the root cause is kunmap incorrect pages:

  BUG: kernel NULL pointer dereference, address: 00000000
  CPU: 1 PID: 40 Comm: kworker/u5:0 Not tainted 6.2.0-rc5 #4
  Workqueue: erofs_worker z_erofs_decompressqueue_work
  EIP: z_erofs_lzma_decompress+0x34b/0x8ac
   z_erofs_decompress+0x12/0x14
   z_erofs_decompress_queue+0x7e7/0xb1c
   z_erofs_decompressqueue_work+0x32/0x60
   process_one_work+0x24b/0x4d8
   ? process_one_work+0x1a4/0x4d8
   worker_thread+0x14c/0x3fc
   kthread+0xe6/0x10c
   ? rescuer_thread+0x358/0x358
   ? kthread_complete_and_exit+0x18/0x18
   ret_from_fork+0x1c/0x28
  ---[ end trace 0000000000000000 ]---
Quoted 6 lines

The bug is trivial and should be fixed now. It has no impact on !HIGHMEM platforms.

Fixes 622ceaddb764 ("erofs: lzma compression support")
Cc <[email protected]> # 5.16+

Thanks,