Re: [PATCH] x86/ftrace: Make sure that ftrace trampolines are not RWX

From: Steven Rostedt
Date: Wed May 24 2017 - 13:47:43 EST


OK, it crashed on one of my tests. I removed the patch and it boots
fine, and crashes when I add it back.

Here's the crash:

Running tests on all trace events:
Testing all events: OK
Testing ftrace filter: OK
trace_kprobe: Testing kprobe tracing:
BUG: unable to handle kernel paging request at ffff880214f5c000
IP: new_slab+0x1e8/0x2b4
PGD 338c067
P4D 338c067
PUD 338f067
PMD 212022063
PTE 8000000214f5c161

Oops: 0003 [#1] SMP
Modules linked in:
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc2-test+ #42
Hardware name: MSI MS-7823/CSM-H87M-G43 (MS-7823), BIOS V1.6 02/22/2014
task: ffff8802153a8000 task.stack: ffffc90000c74000
RIP: 0010:new_slab+0x1e8/0x2b4
RSP: 0000:ffffc90000c77b28 EFLAGS: 00010282
RAX: 0000000040040000 RBX: ffff880216003f00 RCX: ffff880214f5c058
RDX: 0000000000000000 RSI: ffff880214f5c000 RDI: ffff880216003f00
RBP: ffffc90000c77b70 R08: 000000000000002a R09: 0000000000000000
R10: 00000000000201e2 R11: 0000000000020190 R12: ffff880214f5c000
R13: 000000000000002e R14: 0000000000000001 R15: ffffea000853d700
FS: 0000000000000000(0000) GS:ffff88021eb80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff880214f5c000 CR3: 000000000221d000 CR4: 00000000001406e0
Call Trace:
? interleave_nodes+0x29/0x40
___slab_alloc+0x2e8/0x49e
? trace_create_new_event+0x1f/0x63
? trace_add_event_call+0x27/0x91
? mark_lock+0x24/0x1ec
? trace_create_new_event+0x1f/0x63
__slab_alloc+0x46/0x6b
? __slab_alloc+0x46/0x6b
? trace_create_new_event+0x1f/0x63
kmem_cache_alloc+0x59/0x1b2
trace_create_new_event+0x1f/0x63
__trace_add_new_event+0xd/0x29
trace_add_event_call+0x66/0x91
create_trace_kprobe+0x722/0x7f5
? argv_split+0x6c/0xce
? probes_open+0x3b/0x3b
? set_debug_rodata+0x17/0x17
traceprobe_command+0x42/0x57
kprobe_trace_self_tests_init+0x3c/0x338
? kprobe_trace_selftest_target+0x13/0x13
? set_debug_rodata+0x17/0x17
do_one_initcall+0x90/0x131
? set_debug_rodata+0x17/0x17
kernel_init_freeable+0x1f4/0x27c
? rest_init+0x12d/0x12d
kernel_init+0xe/0xfa
ret_from_fork+0x2e/0x40
Code: ff ff 48 8b 53 48 48 85 d2 74 05 4c 89 e7 ff d2 66 41 8b 57 1a 81 e2 ff 7f 00 00 44 39 f2 48 63 53 20 7e 0d 48 63 4b 18 4c 01 e1 <49> 89 0c 14 eb 08 49 c7 04 14 00 00 00 00 48 63 53 18 41 ff c6
RIP: new_slab+0x1e8/0x2b4 RSP: ffffc90000c77b28
CR2: ffff880214f5c000
---[ end trace e8a2200699d40525 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009

Kernel Offset: disabled
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009

sched: Unexpected reschedule of offline CPU#1!
------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at /work/git/linux-trace.git/arch/x86/kernel/smp.c:128 native_smp_send_reschedule+0x23/0x3b
Modules linked in:
CPU: 3 PID: 1 Comm: swapper/0 Tainted: G D 4.12.0-rc2-test+ #42
Hardware name: MSI MS-7823/CSM-H87M-G43 (MS-7823), BIOS V1.6 02/22/2014
task: ffff8802153a8000 task.stack: ffffc90000c74000
RIP: 0010:native_smp_send_reschedule+0x23/0x3b
RSP: 0000:ffff88021eb83e60 EFLAGS: 00010086
RAX: 000000000000002e RBX: 0000000000000001 RCX: ffff8802153a8000
RDX: ffffffff8226ba60 RSI: ffffffff8109ff35 RDI: ffffffff8108e779
RBP: ffff88021eb83e60 R08: 0000000000000001 R09: 0000000000000001
R10: ffff88021eb83de8 R11: ffffffff832b238c R12: 0000000000000003
R13: 0000000000000003 R14: ffff880216002270 R15: 0000000000000001
FS: 0000000000000000(0000) GS:ffff88021eb80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff880214f5c000 CR3: 000000000221d000 CR4: 00000000001406e0
Call Trace:
<IRQ>
trigger_load_balance+0x2dc/0x2e5
scheduler_tick+0x92/0x9b
update_process_times+0x47/0x54
tick_sched_handle+0x44/0x53
tick_sched_timer+0x39/0x5f
__hrtimer_run_queues+0x141/0x2c8
? tick_sched_do_timer+0x2e/0x2e
hrtimer_interrupt+0x6c/0x12e
local_apic_timer_interrupt+0x4b/0x4e
smp_apic_timer_interrupt+0x29/0x39
apic_timer_interrupt+0x90/0xa0
RIP: 0010:panic+0x1e1/0x21f
RSP: 0000:ffffc90000c77e70 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff10
RAX: 00000003810a049e RBX: 0000000000000000 RCX: ffff8802153a8000
RDX: ffffc90000c77e00 RSI: ffffffff81133f1a RDI: ffffffff81091058
RBP: ffffc90000c77ee0 R08: 0000000000000001 R09: 0000000000000001
R10: ffffc90000c77d78 R11: ffffffff8265a60a R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000009
</IRQ>
? panic+0x1de/0x21f
? trace_hardirqs_on+0xd/0xf
do_exit+0x568/0xa40
rewind_stack_do_exit+0x17/0x20
Code: ff 90 a0 00 00 00 5d c3 0f 1f 44 00 00 55 89 f8 48 89 e5 48 0f a3 05 ec 05 41 01 72 12 89 fe 48 c7 c7 5d 0b fe 81 e8 7a 2a 10 00 <0f> ff eb 12 48 8b 05 31 62 0e 01 be fd 00 00 00 ff 90 a0 00 00
---[ end trace e8a2200699d40526 ]---


I attached the config. I don't currently have time to look deeper into
it. But I should have some time later today.

-- Steve

Attachment: config.gz
Description: application/gzip