x86/kprobes: Prohibit probing on rcu_nmi_exit() and ist_exit()
Subsystems (4)
PATCH 1/1 x86/kprobes: Prohibit probing on rcu_nmi_exit() and ist_exit()
Prohibit probing on rcu_nmi_exit() and ist_exit() which are called from do_int3()'s kprobe path after kprobe_int3_handler().
The commit c13324a505c7 ("x86/kprobes: Prohibit probing on functions before kprobe_int3_handler()") tried to fix similar issue, but it only marks the functions before kprobe_int3_handler() in do_int3().
If we put a kprobe on rcu_nmi_exit() or ist_exit(), the kprobes will detect reentrance. However, it only skips the kprobe handler, exits from do_int3() and hits ist_exit() and rcu_nmi_exit() again. Thus, it causes another int3 exception and finally we will get the kernel panic with "Unrecoverable kprobe detected." error message.
This is reproducible by the following commands.
/ # echo 0 > /proc/sys/debug/kprobes-optimization
/ # echo p vfs_read > /sys/kernel/debug/tracing/kprobe_events / # echo p rcu_nmi_exit >> /sys/kernel/debug/tracing/kprobe_events / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable
--- arch/x86/kernel/traps.c | 1 + kernel/rcu/tree.c | 1 + 2 files changed, 2 insertions(+)
arch/x86/kernel/traps.c +1 -0
@@ -115,6 +115,7 @@ void ist_exit(struct pt_regs *regs)if (!user_mode (regs))rcu_nmi_exit (); } +NOKPROBE_SYMBOL (ist_exit);/** * ist_begin_non_atomic() - begin a non-atomic section in an IST exception
kernel/rcu/tree.c +1 -0
@@ -670,6 +670,7 @@ void rcu_nmi_exit(void) {rcu_nmi_exit_common (false); } +NOKPROBE_SYMBOL (rcu_nmi_exit);/** * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle
Quoted 16 lines · Masami Hiramatsu
Prohibit probing on
rcu_nmi_exit()andist_exit()which are called from do_int3()'s kprobe path afterkprobe_int3_handler().The commit
c13324a505c7("x86/kprobes: Prohibit probing on functions beforekprobe_int3_handler()") tried to fix similar issue, but it only marks the functions beforekprobe_int3_handler()indo_int3().If we put a kprobe on
rcu_nmi_exit()orist_exit(), the kprobes will detect reentrance. However, it only skips the kprobe handler, exits fromdo_int3()and hitsist_exit()andrcu_nmi_exit()again. Thus, it causes another int3 exception and finally we will get the kernel panic with "Unrecoverable kprobe detected." error message.This is reproducible by the following commands.
Quoted 8 lines
/ # echo 0 >
/proc/sys/debug/kprobes-optimization
/ # echo pvfs_read>/sys/kernel/debug/tracing/kprobe_events/ # echo prcu_nmi_exit>>/sys/kernel/debug/tracing/kprobe_events/ # echo 1 >/sys/kernel/debug/tracing/events/kprobes/enableFixes c13324a505c7 ("x86/kprobes: Prohibit probing on functions before kprobe_int3_handler()")Signed-off-by Masami Hiramatsu <[email protected]>
From an RCU perspective:
Quoted 30 lines
--- arch/x86/kernel/traps.c | 1 + kernel/rcu/tree.c | 1 + 2 files changed, 2 insertions(+)arch/x86/kernel/traps.c +1
-0@@ -115,6 +115,7 @@ void ist_exit(struct pt_regs *regs)if (!user_mode (regs))rcu_nmi_exit (); } +NOKPROBE_SYMBOL (ist_exit);/** * ist_begin_non_atomic() - begin a non-atomic section in an IST exception kernel/rcu/tree.c +1
-0@@ -670,6 +670,7 @@ void rcu_nmi_exit(void) {rcu_nmi_exit_common (false); } +NOKPROBE_SYMBOL (rcu_nmi_exit);/** * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle
Joel Fernandes
Reviewed-byQuoted 22 lines · Paul E. McKenney
Quoted 21 lines · Masami Hiramatsu
Prohibit probing on
rcu_nmi_exit()andist_exit()which are called from do_int3()'s kprobe path afterkprobe_int3_handler().The commit
c13324a505c7("x86/kprobes: Prohibit probing on functions beforekprobe_int3_handler()") tried to fix similar issue, but it only marks the functions beforekprobe_int3_handler()indo_int3().If we put a kprobe on
rcu_nmi_exit()orist_exit(), the kprobes will detect reentrance. However, it only skips the kprobe handler, exits fromdo_int3()and hitsist_exit()andrcu_nmi_exit()again. Thus, it causes another int3 exception and finally we will get the kernel panic with "Unrecoverable kprobe detected." error message.This is reproducible by the following commands.
/ # echo 0 >
/proc/sys/debug/kprobes-optimization
/ # echo pvfs_read>/sys/kernel/debug/tracing/kprobe_events/ # echo prcu_nmi_exit>>/sys/kernel/debug/tracing/kprobe_events/ # echo 1 >/sys/kernel/debug/tracing/events/kprobes/enable
Quoted 8 lines
Quoted 3 lines
Fixes c13324a505c7 ("x86/kprobes: Prohibit probing on functions before kprobe_int3_handler()")Signed-off-by Masami Hiramatsu <[email protected]>From an RCU perspective:
Reviewed-by Paul E. McKenney <[email protected]>
thanks,
- Joel
Quoted 30 lines
Quoted 30 lines
--- arch/x86/kernel/traps.c | 1 + kernel/rcu/tree.c | 1 + 2 files changed, 2 insertions(+)arch/x86/kernel/traps.c +1
-0@@ -115,6 +115,7 @@ void ist_exit(struct pt_regs *regs)if (!user_mode (regs))rcu_nmi_exit (); } +NOKPROBE_SYMBOL (ist_exit);/** * ist_begin_non_atomic() - begin a non-atomic section in an IST exception kernel/rcu/tree.c +1
-0@@ -670,6 +670,7 @@ void rcu_nmi_exit(void) {rcu_nmi_exit_common (false); } +NOKPROBE_SYMBOL (rcu_nmi_exit);/** * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle