Patrick Wang
96eb48099a
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:06:46 +02:00
..
2019-05-08 07:19:07 +02:00
2021-12-14 10:04:47 +01:00
2016-07-26 16:19:19 -07:00
2016-10-11 15:06:33 -07:00
2016-01-27 09:09:57 -05:00
2019-06-22 08:17:12 +02:00
2019-08-06 18:29:37 +02:00
2017-01-12 11:39:32 +01:00
2016-03-17 15:09:34 -07:00
2018-09-19 22:47:17 +02:00
2016-03-17 15:09:34 -07:00
2018-02-25 11:05:49 +01:00
2018-09-15 09:42:57 +02:00
2016-03-15 16:55:16 -07:00
2020-10-01 20:40:11 +02:00
2018-11-10 07:42:52 -08:00
2016-07-26 16:19:19 -07:00
2022-01-27 08:47:42 +01:00
2016-05-19 19:12:14 -07:00
2022-01-27 08:47:42 +01:00
2019-11-25 09:51:58 +01:00
2021-12-08 08:45:05 +01:00
2017-01-06 10:40:13 +01:00
2019-12-05 15:35:02 +01:00
2018-05-22 16:57:57 +02:00
2016-09-13 02:35:27 +02:00
2021-05-22 10:40:31 +02:00
2016-03-17 15:09:34 -07:00
2016-03-17 15:09:34 -07:00
2022-04-20 09:06:46 +02:00
2021-05-22 10:40:31 +02:00
2019-06-22 08:17:18 +02:00
2020-09-12 11:47:35 +02:00
2018-10-10 08:53:20 +02:00
2016-10-12 10:23:41 -07:00
2022-03-02 11:32:06 +01:00
2022-04-20 09:06:41 +02:00
2020-08-21 11:02:11 +02:00
2021-06-30 08:49:13 -04:00
2022-04-20 09:06:44 +02:00
2022-04-20 09:06:44 +02:00
2016-07-28 16:07:41 -07:00
2019-03-13 14:04:54 -07:00
2019-05-21 18:48:58 +02:00
2019-07-10 09:55:43 +02:00
2016-03-17 15:09:34 -07:00
2022-04-20 09:06:41 +02:00
2016-04-28 11:44:19 +02:00
2019-08-04 09:33:42 +02:00
2016-05-19 19:12:14 -07:00
2018-08-15 18:14:45 +02:00
2022-04-20 09:06:44 +02:00
2017-08-24 17:12:19 -07:00
2020-04-02 17:20:26 +02:00
2021-11-26 11:48:40 +01:00
2022-04-20 09:06:45 +02:00
2019-04-05 22:29:06 +02:00
2019-07-10 09:55:38 +02:00
2021-03-07 11:25:59 +01:00
2016-10-07 18:46:29 -07:00
2016-10-07 18:46:27 -07:00
2016-06-03 15:06:22 -07:00
2021-02-23 13:59:14 +01:00
2020-10-01 20:40:06 +02:00
2016-03-17 15:09:34 -07:00
2019-04-27 09:34:47 +02:00
2016-03-17 15:09:34 -07:00
2016-10-18 14:13:37 -07:00
2016-03-17 15:09:34 -07:00
2016-08-26 17:39:35 -07:00
2022-04-20 09:06:43 +02:00
2022-03-08 19:00:59 +01:00
2020-06-30 15:38:44 -04:00
2019-06-22 08:17:13 +02:00
2021-11-26 11:48:42 +01:00
2017-03-22 12:43:38 +01:00
2021-03-17 16:10:14 +01:00
2016-08-02 17:31:41 -04:00
2017-10-21 17:21:36 +02:00
2017-07-05 14:40:17 +02:00
2020-07-09 09:35:54 +02:00
2016-10-07 18:46:28 -07:00
2021-03-07 11:25:59 +01:00
2018-12-08 13:05:09 +01:00
2019-10-17 13:42:06 -07:00
2016-04-04 10:41:08 -07:00
2019-01-16 22:12:32 +01:00
2018-09-19 22:47:17 +02:00
2020-06-03 08:16:47 +02:00
2017-03-12 06:41:43 +01:00
2018-09-19 22:47:12 +02:00
2021-06-03 08:23:27 +02:00
2017-04-08 09:30:36 +02:00
2016-06-03 16:02:55 -07:00
2016-01-15 11:40:52 -08:00
2015-11-06 17:50:42 -08:00
2021-11-26 11:48:39 +01:00
2018-09-05 09:20:02 +02:00