Masami Hiramatsu
3c5f8d371b
kprobes: Fix to check probe enabled before disarm_kprobe_ftrace()
commit 3031313eb3d549b7ad6f9fbcc52ba04412e3eb9e upstream.
Commit 0cb2f1372baa ("kprobes: Fix NULL pointer dereference at
kprobe_ftrace_handler") fixed one bug but not completely fixed yet.
If we run a kprobe_module.tc of ftracetest, kernel showed a warning
as below.
# ./ftracetest test.d/kprobe/kprobe_module.tc
=== Ftrace unit tests ===
[1] Kprobe dynamic event - probing module
...
[ 22.400215] ------------[ cut here ]------------
[ 22.400962] Failed to disarm kprobe-ftrace at trace_printk_irq_work+0x0/0x7e [trace_printk] (-2)
[ 22.402139] WARNING: CPU: 7 PID: 200 at kernel/kprobes.c:1091 __disarm_kprobe_ftrace.isra.0+0x7e/0xa0
[ 22.403358] Modules linked in: trace_printk(-)
[ 22.404028] CPU: 7 PID: 200 Comm: rmmod Not tainted 5.9.0-rc2+ #66
[ 22.404870] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
[ 22.406139] RIP: 0010:__disarm_kprobe_ftrace.isra.0+0x7e/0xa0
[ 22.406947] Code: 30 8b 03 eb c9 80 3d e5 09 1f 01 00 75 dc 49 8b 34 24 89 c2 48 c7 c7 a0 c2 05 82 89 45 e4 c6 05 cc 09 1f 01 01 e8 a9 c7 f0 ff <0f> 0b 8b 45 e4 eb b9 89 c6 48 c7 c7 70 c2 05 82 89 45 e4 e8 91 c7
[ 22.409544] RSP: 0018:ffffc90000237df0 EFLAGS: 00010286
[ 22.410385] RAX: 0000000000000000 RBX: ffffffff83066024 RCX: 0000000000000000
[ 22.411434] RDX: 0000000000000001 RSI: ffffffff810de8d3 RDI: ffffffff810de8d3
[ 22.412687] RBP: ffffc90000237e10 R08: 0000000000000001 R09: 0000000000000001
[ 22.413762] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88807c478640
[ 22.414852] R13: ffffffff8235ebc0 R14: ffffffffa00060c0 R15: 0000000000000000
[ 22.415941] FS: 00000000019d48c0(0000) GS:ffff88807d7c0000(0000) knlGS:0000000000000000
[ 22.417264] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 22.418176] CR2: 00000000005bb7e3 CR3: 0000000078f7a000 CR4: 00000000000006a0
[ 22.419309] Call Trace:
[ 22.419990] kill_kprobe+0x94/0x160
[ 22.420652] kprobes_module_callback+0x64/0x230
[ 22.421470] notifier_call_chain+0x4f/0x70
[ 22.422184] blocking_notifier_call_chain+0x49/0x70
[ 22.422979] __x64_sys_delete_module+0x1ac/0x240
[ 22.423733] do_syscall_64+0x38/0x50
[ 22.424366] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 22.425176] RIP: 0033:0x4bb81d
[ 22.425741] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e0 ff ff ff f7 d8 64 89 01 48
[ 22.428726] RSP: 002b:00007ffc70fef008 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
[ 22.430169] RAX: ffffffffffffffda RBX: 00000000019d48a0 RCX: 00000000004bb81d
[ 22.431375] RDX: 0000000000000000 RSI: 0000000000000880 RDI: 00007ffc70fef028
[ 22.432543] RBP: 0000000000000880 R08: 00000000ffffffff R09: 00007ffc70fef320
[ 22.433692] R10: 0000000000656300 R11: 0000000000000246 R12: 00007ffc70fef028
[ 22.434635] R13: 0000000000000000 R14: 0000000000000002 R15: 0000000000000000
[ 22.435682] irq event stamp: 1169
[ 22.436240] hardirqs last enabled at (1179): [<ffffffff810df542>] console_unlock+0x422/0x580
[ 22.437466] hardirqs last disabled at (1188): [<ffffffff810df19b>] console_unlock+0x7b/0x580
[ 22.438608] softirqs last enabled at (866): [<ffffffff81c0038e>] __do_softirq+0x38e/0x490
[ 22.439637] softirqs last disabled at (859): [<ffffffff81a00f42>] asm_call_on_stack+0x12/0x20
[ 22.440690] ---[ end trace 1e7ce7e1e4567276 ]---
[ 22.472832] trace_kprobe: This probe might be able to register after target module is loaded. Continue.
This is because the kill_kprobe() calls disarm_kprobe_ftrace() even
if the given probe is not enabled. In that case, ftrace_set_filter_ip()
fails because the given probe point is not registered to ftrace.
Fix to check the given (going) probe is enabled before invoking
disarm_kprobe_ftrace().
Link: https://lkml.kernel.org/r/159888672694.1411785.5987998076694782591.stgit@devnote2
Fixes: 0cb2f1372baa ("kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler")
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Naveen N . Rao" <naveen.n.rao@linux.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David Miller <davem@davemloft.net>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Chengming Zhou <zhouchengming@bytedance.com>
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-01 11:11:58 +02:00
..
2020-05-10 10:26:19 +02:00
2016-09-24 10:07:42 +02:00
2020-07-09 09:35:08 +02:00
2020-07-31 16:43:12 +02:00
2020-09-23 08:44:26 +02:00
2020-06-03 08:12:14 +02:00
2015-11-11 17:36:04 +01:00
2020-09-03 11:19:24 +02:00
2019-04-03 06:23:24 +02:00
2020-10-01 11:11:56 +02:00
2019-06-11 12:24:04 +02:00
2020-07-22 09:10:07 +02:00
2020-08-21 10:52:54 +02:00
2020-10-01 11:11:53 +02:00
2015-10-21 15:18:35 +01:00
2018-01-10 09:27:08 +01:00
2018-02-16 20:09:45 +01:00
2015-08-06 16:14:53 -04:00
2015-11-04 08:23:51 -05:00
2020-10-01 11:11:52 +02:00
2020-05-02 17:20:48 +02:00
2015-11-04 08:23:51 -05:00
2020-03-11 07:51:13 +01:00
2019-11-28 18:26:01 +01:00
2018-11-21 09:27:35 +01:00
2017-01-06 11:16:14 +01:00
2015-12-03 10:18:21 -05:00
2019-12-21 10:35:24 +01:00
2019-09-06 10:18:11 +02:00
2015-06-04 23:57:18 +02:00
2015-11-10 12:06:23 +01:00
2020-06-20 10:23:24 +02:00
2019-07-10 09:56:36 +02:00
2017-10-12 11:27:35 +02:00
2019-08-04 09:35:01 +02:00
2019-10-17 13:40:56 -07:00
2019-02-06 19:43:07 +01:00
2017-07-21 07:44:56 +02:00
2019-10-17 13:41:04 -07:00
2016-02-25 12:01:16 -08:00
2020-04-24 07:57:13 +02:00
2018-01-10 09:27:10 +01:00
2019-02-20 10:13:14 +01:00
2015-11-23 09:44:58 +01:00
2017-12-16 10:33:55 +01:00
2016-02-25 12:01:16 -08:00
2015-05-12 09:46:00 +02:00
2015-11-06 17:50:42 -08:00
2016-09-24 10:07:36 +02:00
2015-09-10 13:29:01 -07:00
2015-11-06 17:50:42 -08:00
2020-04-24 07:57:15 +02:00
2020-10-01 11:11:58 +02:00
2015-09-10 13:29:01 -07:00
2018-09-09 20:04:34 +02:00
2015-09-11 15:21:34 -07:00
2017-03-12 06:37:26 +01:00
2019-01-13 10:05:32 +01:00
2015-10-21 15:18:36 +01:00
2019-12-21 10:35:38 +01:00
2020-04-02 19:02:31 +02:00
2020-05-27 16:40:27 +02:00
2019-10-17 13:40:58 -07:00
2015-11-09 15:53:39 -08:00
2019-08-04 09:34:42 +02:00
2018-04-13 19:50:03 +02:00
2018-02-25 11:03:44 +01:00
2019-07-10 09:56:42 +02:00
2015-09-10 13:29:01 -07:00
2018-05-30 07:49:00 +02:00
2018-04-24 09:32:05 +02:00
2018-07-25 10:18:27 +02:00
2020-04-24 07:57:12 +02:00
2015-11-06 17:50:42 -08:00
2015-10-20 10:23:55 +02:00
2015-12-12 10:15:34 -08:00
2015-11-05 19:34:48 -08:00
2020-10-01 11:11:51 +02:00
2016-04-12 09:08:58 -07:00
2020-07-09 09:35:08 +02:00
2015-09-05 13:46:58 -07:00
2020-01-12 11:22:40 +01:00
2015-10-06 11:25:01 -07:00
2018-05-16 10:06:47 +02:00
2018-01-10 09:27:10 +01:00
2018-09-09 20:04:35 +02:00
2018-09-09 20:04:35 +02:00
2017-01-06 11:16:16 +01:00
2017-11-15 17:13:11 +01:00
2019-12-21 10:35:37 +01:00