b506a9d08b
When developing the Kprobes arch code for ARM, I ran across some code found in x86 and s390 Kprobes arch code which I didn't consider as good as it could be. Once I figured out what the code was doing, I changed the code for ARM Kprobes to work the way I felt was more appropriate. I've tested the code this way in ARM for about a year and would like to push the same change to the other affected architectures. The code in question is in kprobe_exceptions_notify() which does: ==== /* kprobe_running() needs smp_processor_id() */ preempt_disable(); if (kprobe_running() && kprobe_fault_handler(args->regs, args->trapnr)) ret = NOTIFY_STOP; preempt_enable(); ==== For the moment, ignore the code having the preempt_disable()/ preempt_enable() pair in it. The problem is that kprobe_running() needs to call smp_processor_id() which will assert if preemption is enabled. That sanity check by smp_processor_id() makes perfect sense since calling it with preemption enabled would return an unreliable result. But the function kprobe_exceptions_notify() can be called from a context where preemption could be enabled. If that happens, the assertion in smp_processor_id() happens and we're dead. So what the original author did (speculation on my part!) is put in the preempt_disable()/preempt_enable() pair to simply defeat the check. Once I figured out what was going on, I considered this an inappropriate approach. If kprobe_exceptions_notify() is called from a preemptible context, we can't be in a kprobe processing context at that time anyways since kprobes requires preemption to already be disabled, so just check for preemption enabled, and if so, blow out before ever calling kprobe_running(). I wrote the ARM kprobe code like this: ==== /* To be potentially processing a kprobe fault and to * trust the result from kprobe_running(), we have * be non-preemptible. */ if (!preemptible() && kprobe_running() && kprobe_fault_handler(args->regs, args->trapnr)) ret = NOTIFY_STOP; ==== The above code has been working fine for ARM Kprobes for a year. So I changed the x86 code (2.6.24-rc6) to be the same way and ran the Systemtap tests on that kernel. As on ARM, Systemtap on x86 comes up with the same test results either way, so it's a neutral external functional change (as expected). This issue has been discussed previously on linux-arm-kernel and the Systemtap mailing lists. Pointers to the by base for the two discussions: http://lists.arm.linux.org.uk/lurker/message/20071219.223225.1f5c2a5e.en.html http://sourceware.org/ml/systemtap/2007-q1/msg00251.html Signed-off-by: Quentin Barnes <qbarnes@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Ananth N Mavinakayahanalli <ananth@in.ibm.com> Acked-by: Ananth N Mavinakayahanalli <ananth@in.ibm.com> |
||
---|---|---|
.. | ||
acpi | ||
cpu | ||
.gitignore | ||
alternative.c | ||
aperture_64.c | ||
apic_32.c | ||
apic_64.c | ||
apm_32.c | ||
asm-offsets_32.c | ||
asm-offsets_64.c | ||
asm-offsets.c | ||
audit_64.c | ||
bootflag.c | ||
bugs_64.c | ||
cpuid.c | ||
crash_dump_32.c | ||
crash_dump_64.c | ||
crash.c | ||
doublefault_32.c | ||
ds.c | ||
e820_32.c | ||
e820_64.c | ||
early_printk.c | ||
early-quirks.c | ||
efi_32.c | ||
efi_64.c | ||
efi_stub_32.S | ||
efi_stub_64.S | ||
efi.c | ||
entry_32.S | ||
entry_64.S | ||
genapic_64.c | ||
genapic_flat_64.c | ||
geode_32.c | ||
head64.c | ||
head_32.S | ||
head_64.S | ||
hpet.c | ||
i386_ksyms_32.c | ||
i387.c | ||
i8237.c | ||
i8253.c | ||
i8259_32.c | ||
i8259_64.c | ||
init_task.c | ||
io_apic_32.c | ||
io_apic_64.c | ||
io_delay.c | ||
ioport_32.c | ||
ioport_64.c | ||
irq_32.c | ||
irq_64.c | ||
k8.c | ||
kprobes.c | ||
ldt.c | ||
machine_kexec_32.c | ||
machine_kexec_64.c | ||
Makefile | ||
mca_32.c | ||
mfgpt_32.c | ||
microcode.c | ||
module_32.c | ||
module_64.c | ||
mpparse_32.c | ||
mpparse_64.c | ||
msr.c | ||
nmi_32.c | ||
nmi_64.c | ||
numaq_32.c | ||
paravirt_patch_32.c | ||
paravirt_patch_64.c | ||
paravirt.c | ||
pci-calgary_64.c | ||
pci-dma_32.c | ||
pci-dma_64.c | ||
pci-gart_64.c | ||
pci-nommu_64.c | ||
pci-swiotlb_64.c | ||
pcspeaker.c | ||
pmtimer_64.c | ||
process_32.c | ||
process_64.c | ||
ptrace.c | ||
quirks.c | ||
reboot_32.c | ||
reboot_64.c | ||
reboot_fixups_32.c | ||
relocate_kernel_32.S | ||
relocate_kernel_64.S | ||
rtc.c | ||
scx200_32.c | ||
setup64.c | ||
setup_32.c | ||
setup_64.c | ||
sigframe_32.h | ||
signal_32.c | ||
signal_64.c | ||
smp_32.c | ||
smp_64.c | ||
smpboot_32.c | ||
smpboot_64.c | ||
smpcommon_32.c | ||
srat_32.c | ||
stacktrace.c | ||
step.c | ||
summit_32.c | ||
suspend_64.c | ||
suspend_asm_64.S | ||
sys_i386_32.c | ||
sys_x86_64.c | ||
syscall_64.c | ||
syscall_table_32.S | ||
tce_64.c | ||
time_32.c | ||
time_64.c | ||
tls.c | ||
tls.h | ||
topology.c | ||
trampoline_32.S | ||
trampoline_64.S | ||
traps_32.c | ||
traps_64.c | ||
tsc_32.c | ||
tsc_64.c | ||
tsc_sync.c | ||
verify_cpu_64.S | ||
vm86_32.c | ||
vmi_32.c | ||
vmiclock_32.c | ||
vmlinux_32.lds.S | ||
vmlinux_64.lds.S | ||
vmlinux.lds.S | ||
vsmp_64.c | ||
vsyscall_64.c | ||
x8664_ksyms_64.c |