forked from luck/tmp_suning_uos_patched
d0aaff9796
There are possible race conditions if probes are placed on routines within the kprobes files and routines used by the kprobes. For example if you put probe on get_kprobe() routines, the system can hang while inserting probes on any routine such as do_fork(). Because while inserting probes on do_fork(), register_kprobes() routine grabs the kprobes spin lock and executes get_kprobe() routine and to handle probe of get_kprobe(), kprobes_handler() gets executed and tries to grab kprobes spin lock, and spins forever. This patch avoids such possible race conditions by preventing probes on routines within the kprobes file and routines used by kprobes. I have modified the patches as per Andi Kleen's suggestion to move kprobes routines and other routines used by kprobes to a seperate section .kprobes.text. Also moved page fault and exception handlers, general protection fault to .kprobes.text section. These patches have been tested on i386, x86_64 and ppc64 architectures, also compiled on ia64 and sparc64 architectures. Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
106 lines
3.4 KiB
C
106 lines
3.4 KiB
C
#ifndef LOAD_OFFSET
|
|
#define LOAD_OFFSET 0
|
|
#endif
|
|
|
|
#ifndef VMLINUX_SYMBOL
|
|
#define VMLINUX_SYMBOL(_sym_) _sym_
|
|
#endif
|
|
|
|
/* Align . to a 8 byte boundary equals to maximum function alignment. */
|
|
#define ALIGN_FUNCTION() . = ALIGN(8)
|
|
|
|
#define RODATA \
|
|
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
|
|
*(.rodata) *(.rodata.*) \
|
|
*(__vermagic) /* Kernel version magic */ \
|
|
} \
|
|
\
|
|
.rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
|
|
*(.rodata1) \
|
|
} \
|
|
\
|
|
/* PCI quirks */ \
|
|
.pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
|
|
*(.pci_fixup_early) \
|
|
VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
|
|
VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
|
|
*(.pci_fixup_header) \
|
|
VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
|
|
VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
|
|
*(.pci_fixup_final) \
|
|
VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
|
|
VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
|
|
*(.pci_fixup_enable) \
|
|
VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
|
|
} \
|
|
\
|
|
/* Kernel symbol table: Normal symbols */ \
|
|
__ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__start___ksymtab) = .; \
|
|
*(__ksymtab) \
|
|
VMLINUX_SYMBOL(__stop___ksymtab) = .; \
|
|
} \
|
|
\
|
|
/* Kernel symbol table: GPL-only symbols */ \
|
|
__ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
|
|
*(__ksymtab_gpl) \
|
|
VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
|
|
} \
|
|
\
|
|
/* Kernel symbol table: Normal symbols */ \
|
|
__kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__start___kcrctab) = .; \
|
|
*(__kcrctab) \
|
|
VMLINUX_SYMBOL(__stop___kcrctab) = .; \
|
|
} \
|
|
\
|
|
/* Kernel symbol table: GPL-only symbols */ \
|
|
__kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
|
|
*(__kcrctab_gpl) \
|
|
VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
|
|
} \
|
|
\
|
|
/* Kernel symbol table: strings */ \
|
|
__ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
|
|
*(__ksymtab_strings) \
|
|
} \
|
|
\
|
|
/* Built-in module parameters. */ \
|
|
__param : AT(ADDR(__param) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__start___param) = .; \
|
|
*(__param) \
|
|
VMLINUX_SYMBOL(__stop___param) = .; \
|
|
}
|
|
|
|
#define SECURITY_INIT \
|
|
.security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
|
|
VMLINUX_SYMBOL(__security_initcall_start) = .; \
|
|
*(.security_initcall.init) \
|
|
VMLINUX_SYMBOL(__security_initcall_end) = .; \
|
|
}
|
|
|
|
/* sched.text is aling to function alignment to secure we have same
|
|
* address even at second ld pass when generating System.map */
|
|
#define SCHED_TEXT \
|
|
ALIGN_FUNCTION(); \
|
|
VMLINUX_SYMBOL(__sched_text_start) = .; \
|
|
*(.sched.text) \
|
|
VMLINUX_SYMBOL(__sched_text_end) = .;
|
|
|
|
/* spinlock.text is aling to function alignment to secure we have same
|
|
* address even at second ld pass when generating System.map */
|
|
#define LOCK_TEXT \
|
|
ALIGN_FUNCTION(); \
|
|
VMLINUX_SYMBOL(__lock_text_start) = .; \
|
|
*(.spinlock.text) \
|
|
VMLINUX_SYMBOL(__lock_text_end) = .;
|
|
|
|
#define KPROBES_TEXT \
|
|
ALIGN_FUNCTION(); \
|
|
VMLINUX_SYMBOL(__kprobes_text_start) = .; \
|
|
*(.kprobes.text) \
|
|
VMLINUX_SYMBOL(__kprobes_text_end) = .;
|