Patrick Wang
06c348fde5
mm: kmemleak: take a full lowmem check in kmemleak_*_phys()
...
commit 23c2d497de21f25898fbea70aeb292ab8acc8c94 upstream.
The kmemleak_*_phys() apis do not check the address for lowmem's min
boundary, while the caller may pass an address below lowmem, which will
trigger an oops:
# echo scan > /sys/kernel/debug/kmemleak
Unable to handle kernel paging request at virtual address ff5fffffffe00000
Oops [#1 ]
Modules linked in:
CPU: 2 PID: 134 Comm: bash Not tainted 5.18.0-rc1-next-20220407 #33
Hardware name: riscv-virtio,qemu (DT)
epc : scan_block+0x74/0x15c
ra : scan_block+0x72/0x15c
epc : ffffffff801e5806 ra : ffffffff801e5804 sp : ff200000104abc30
gp : ffffffff815cd4e8 tp : ff60000004cfa340 t0 : 0000000000000200
t1 : 00aaaaaac23954cc t2 : 00000000000003ff s0 : ff200000104abc90
s1 : ffffffff81b0ff28 a0 : 0000000000000000 a1 : ff5fffffffe01000
a2 : ffffffff81b0ff28 a3 : 0000000000000002 a4 : 0000000000000001
a5 : 0000000000000000 a6 : ff200000104abd7c a7 : 0000000000000005
s2 : ff5fffffffe00ff9 s3 : ffffffff815cd998 s4 : ffffffff815d0e90
s5 : ffffffff81b0ff28 s6 : 0000000000000020 s7 : ffffffff815d0eb0
s8 : ffffffffffffffff s9 : ff5fffffffe00000 s10: ff5fffffffe01000
s11: 0000000000000022 t3 : 00ffffffaa17db4c t4 : 000000000000000f
t5 : 0000000000000001 t6 : 0000000000000000
status: 0000000000000100 badaddr: ff5fffffffe00000 cause: 000000000000000d
scan_gray_list+0x12e/0x1a6
kmemleak_scan+0x2aa/0x57e
kmemleak_write+0x32a/0x40c
full_proxy_write+0x56/0x82
vfs_write+0xa6/0x2a6
ksys_write+0x6c/0xe2
sys_write+0x22/0x2a
ret_from_syscall+0x0/0x2
The callers may not quite know the actual address they pass(e.g. from
devicetree). So the kmemleak_*_phys() apis should guarantee the address
they finally use is in lowmem range, so check the address for lowmem's
min boundary.
Link: https://lkml.kernel.org/r/20220413122925.33856-1-patrick.wang.shcn@gmail.com
Signed-off-by: Patrick Wang <patrick.wang.shcn@gmail.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-20 09:23:25 +02:00
..
2021-01-27 11:55:23 +01:00
2021-12-14 11:32:37 +01:00
2020-07-10 13:54:00 -07:00
2020-08-12 10:57:57 -07:00
2020-09-01 09:19:43 +02:00
2021-03-04 11:38:38 +01:00
2022-02-08 18:30:35 +01:00
2020-10-13 18:38:29 -07:00
2020-10-13 18:38:32 -07:00
2020-01-31 10:30:38 -08:00
2020-10-13 18:38:29 -07:00
2021-02-10 09:29:21 +01:00
2020-06-09 09:39:14 -07:00
2020-08-14 19:56:56 -07:00
2020-10-18 09:27:09 -07:00
2021-07-14 16:55:42 +02:00
2020-10-16 11:11:18 -07:00
2022-01-27 10:54:36 +01:00
2021-07-25 14:36:18 +02:00
2021-03-30 14:31:54 +02:00
2021-11-26 10:39:21 +01:00
2020-10-16 11:11:16 -07:00
2020-12-30 11:53:54 +01:00
2021-06-30 08:47:27 -04:00
2020-08-07 11:33:26 -07:00
2020-12-06 10:19:07 -08:00
2020-06-14 01:57:21 +09:00
2021-11-06 14:10:09 +01:00
2022-04-20 09:23:25 +02:00
2021-05-19 10:13:07 +02:00
2020-12-06 10:19:07 -08:00
2020-08-12 10:57:59 -07:00
2022-04-08 14:39:54 +02:00
2020-10-13 18:38:27 -07:00
2020-04-02 09:35:29 -07:00
2022-03-02 11:42:57 +01:00
2022-04-08 14:40:43 +02:00
2022-03-08 19:09:36 +01:00
2021-09-22 12:27:59 +02:00
2021-12-29 12:26:05 +01:00
2022-04-13 21:01:10 +02:00
2022-04-13 21:01:08 +02:00
2020-10-13 18:38:34 -07:00
2021-03-04 11:38:21 +01:00
2021-06-30 08:47:26 -04:00
2020-10-13 18:38:29 -07:00
2020-09-19 13:13:38 -07:00
2020-08-07 11:33:26 -07:00
2022-04-08 14:40:43 +02:00
2020-06-09 09:39:14 -07:00
2021-03-30 14:32:06 +02:00
2022-02-23 12:00:57 +01:00
2022-04-13 21:01:08 +02:00
2020-06-09 09:39:14 -07:00
2020-10-18 09:27:10 -07:00
2021-11-18 14:04:30 +01:00
2022-04-20 09:23:25 +02:00
2020-10-13 18:38:30 -07:00
2020-04-07 10:43:40 -07:00
2020-06-08 11:05:55 -07:00
2022-04-20 09:23:25 +02:00
2020-10-16 11:11:19 -07:00
2020-10-16 11:11:19 -07:00
2020-10-16 11:11:17 -07:00
2020-10-16 11:11:19 -07:00
2020-06-09 09:39:13 -07:00
2021-06-30 08:47:29 -04:00
2021-01-12 20:18:22 +01:00
2020-06-09 09:39:14 -07:00
2021-04-14 08:42:03 +02:00
2020-08-12 10:57:55 -07:00
2021-04-14 08:42:03 +02:00
2020-08-12 10:57:55 -07:00
2021-04-14 08:42:03 +02:00
2020-08-07 11:33:26 -07:00
2021-06-30 08:47:26 -04:00
2021-01-19 18:27:21 +01:00
2021-04-21 13:00:57 +02:00
2020-10-17 13:49:08 -06:00
2022-04-13 21:01:03 +02:00
2020-08-21 09:52:53 -07:00
2022-01-27 10:53:44 +01:00
2020-10-16 11:11:19 -07:00
2020-08-07 11:33:29 -07:00
2021-06-23 14:42:54 +02:00
2021-05-14 09:50:45 +02:00
2021-11-26 10:39:19 +01:00
2020-08-07 11:33:24 -07:00
2021-10-27 09:56:53 +02:00
2020-08-07 11:33:27 -07:00
2021-05-14 09:50:45 +02:00
2020-06-03 20:09:48 -07:00
2020-10-13 18:38:30 -07:00
2022-03-23 09:13:27 +01:00
2020-10-13 18:38:33 -07:00
2021-06-23 14:42:53 +02:00
2021-06-30 08:47:27 -04:00
2022-04-08 14:40:43 +02:00
2020-08-12 10:57:55 -07:00
2022-03-08 19:09:32 +01:00
2020-06-10 19:14:18 -07:00
2021-01-19 18:27:21 +01:00
2020-04-02 09:35:31 -07:00
2021-09-18 13:40:36 +02:00
2020-10-16 11:11:17 -07:00
2020-10-20 14:39:37 -07:00
2021-07-14 16:56:51 +02:00
2020-10-13 18:38:34 -07:00
2020-08-12 10:57:58 -07:00
2021-11-18 14:04:26 +01:00
2020-04-07 10:43:41 -07:00