diff options
| -rw-r--r-- | arch/arm64/kernel/arm64ksyms.c | 2 | ||||
| -rw-r--r-- | arch/arm64/kernel/debug-monitors.c | 17 | ||||
| -rw-r--r-- | arch/arm64/kernel/hw_breakpoint.c | 8 | ||||
| -rw-r--r-- | arch/arm64/kernel/kgdb.c | 4 |
4 files changed, 31 insertions, 0 deletions
diff --git a/arch/arm64/kernel/arm64ksyms.c b/arch/arm64/kernel/arm64ksyms.c index 678f30b05a45..b96ff1ae2786 100644 --- a/arch/arm64/kernel/arm64ksyms.c +++ b/arch/arm64/kernel/arm64ksyms.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/uaccess.h> | 27 | #include <linux/uaccess.h> |
| 28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
| 29 | #include <linux/arm-smccc.h> | 29 | #include <linux/arm-smccc.h> |
| 30 | #include <linux/kprobes.h> | ||
| 30 | 31 | ||
| 31 | #include <asm/checksum.h> | 32 | #include <asm/checksum.h> |
| 32 | 33 | ||
| @@ -68,6 +69,7 @@ EXPORT_SYMBOL(test_and_change_bit); | |||
| 68 | 69 | ||
| 69 | #ifdef CONFIG_FUNCTION_TRACER | 70 | #ifdef CONFIG_FUNCTION_TRACER |
| 70 | EXPORT_SYMBOL(_mcount); | 71 | EXPORT_SYMBOL(_mcount); |
| 72 | NOKPROBE_SYMBOL(_mcount); | ||
| 71 | #endif | 73 | #endif |
| 72 | 74 | ||
| 73 | /* arm-smccc */ | 75 | /* arm-smccc */ |
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 395de61108d8..2fbc1b99e8fb 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c | |||
| @@ -49,6 +49,7 @@ static void mdscr_write(u32 mdscr) | |||
| 49 | asm volatile("msr mdscr_el1, %0" :: "r" (mdscr)); | 49 | asm volatile("msr mdscr_el1, %0" :: "r" (mdscr)); |
| 50 | local_dbg_restore(flags); | 50 | local_dbg_restore(flags); |
| 51 | } | 51 | } |
| 52 | NOKPROBE_SYMBOL(mdscr_write); | ||
| 52 | 53 | ||
| 53 | static u32 mdscr_read(void) | 54 | static u32 mdscr_read(void) |
| 54 | { | 55 | { |
| @@ -56,6 +57,7 @@ static u32 mdscr_read(void) | |||
| 56 | asm volatile("mrs %0, mdscr_el1" : "=r" (mdscr)); | 57 | asm volatile("mrs %0, mdscr_el1" : "=r" (mdscr)); |
| 57 | return mdscr; | 58 | return mdscr; |
| 58 | } | 59 | } |
| 60 | NOKPROBE_SYMBOL(mdscr_read); | ||
| 59 | 61 | ||
| 60 | /* | 62 | /* |
| 61 | * Allow root to disable self-hosted debug from userspace. | 63 | * Allow root to disable self-hosted debug from userspace. |
| @@ -104,6 +106,7 @@ void enable_debug_monitors(enum dbg_active_el el) | |||
| 104 | mdscr_write(mdscr); | 106 | mdscr_write(mdscr); |
| 105 | } | 107 | } |
| 106 | } | 108 | } |
| 109 | NOKPROBE_SYMBOL(enable_debug_monitors); | ||
| 107 | 110 | ||
| 108 | void disable_debug_monitors(enum dbg_active_el el) | 111 | void disable_debug_monitors(enum dbg_active_el el) |
| 109 | { | 112 | { |
| @@ -124,6 +127,7 @@ void disable_debug_monitors(enum dbg_active_el el) | |||
| 124 | mdscr_write(mdscr); | 127 | mdscr_write(mdscr); |
| 125 | } | 128 | } |
| 126 | } | 129 | } |
| 130 | NOKPROBE_SYMBOL(disable_debug_monitors); | ||
| 127 | 131 | ||
| 128 | /* | 132 | /* |
| 129 | * OS lock clearing. | 133 | * OS lock clearing. |
| @@ -174,6 +178,7 @@ static void set_regs_spsr_ss(struct pt_regs *regs) | |||
| 174 | spsr |= DBG_SPSR_SS; | 178 | spsr |= DBG_SPSR_SS; |
| 175 | regs->pstate = spsr; | 179 | regs->pstate = spsr; |
| 176 | } | 180 | } |
| 181 | NOKPROBE_SYMBOL(set_regs_spsr_ss); | ||
| 177 | 182 | ||
| 178 | static void clear_regs_spsr_ss(struct pt_regs *regs) | 183 | static void clear_regs_spsr_ss(struct pt_regs *regs) |
| 179 | { | 184 | { |
| @@ -183,6 +188,7 @@ static void clear_regs_spsr_ss(struct pt_regs *regs) | |||
| 183 | spsr &= ~DBG_SPSR_SS; | 188 | spsr &= ~DBG_SPSR_SS; |
| 184 | regs->pstate = spsr; | 189 | regs->pstate = spsr; |
| 185 | } | 190 | } |
| 191 | NOKPROBE_SYMBOL(clear_regs_spsr_ss); | ||
| 186 | 192 | ||
| 187 | /* EL1 Single Step Handler hooks */ | 193 | /* EL1 Single Step Handler hooks */ |
| 188 | static LIST_HEAD(step_hook); | 194 | static LIST_HEAD(step_hook); |
| @@ -226,6 +232,7 @@ static int call_step_hook(struct pt_regs *regs, unsigned int esr) | |||
| 226 | 232 | ||
| 227 | return retval; | 233 | return retval; |
| 228 | } | 234 | } |
| 235 | NOKPROBE_SYMBOL(call_step_hook); | ||
| 229 | 236 | ||
| 230 | static void send_user_sigtrap(int si_code) | 237 | static void send_user_sigtrap(int si_code) |
| 231 | { | 238 | { |
| @@ -284,6 +291,7 @@ static int single_step_handler(unsigned long addr, unsigned int esr, | |||
| 284 | 291 | ||
| 285 | return 0; | 292 | return 0; |
| 286 | } | 293 | } |
| 294 | NOKPROBE_SYMBOL(single_step_handler); | ||
| 287 | 295 | ||
| 288 | /* | 296 | /* |
| 289 | * Breakpoint handler is re-entrant as another breakpoint can | 297 | * Breakpoint handler is re-entrant as another breakpoint can |
| @@ -321,6 +329,7 @@ static int call_break_hook(struct pt_regs *regs, unsigned int esr) | |||
| 321 | 329 | ||
| 322 | return fn ? fn(regs, esr) : DBG_HOOK_ERROR; | 330 | return fn ? fn(regs, esr) : DBG_HOOK_ERROR; |
| 323 | } | 331 | } |
| 332 | NOKPROBE_SYMBOL(call_break_hook); | ||
| 324 | 333 | ||
| 325 | static int brk_handler(unsigned long addr, unsigned int esr, | 334 | static int brk_handler(unsigned long addr, unsigned int esr, |
| 326 | struct pt_regs *regs) | 335 | struct pt_regs *regs) |
| @@ -341,6 +350,7 @@ static int brk_handler(unsigned long addr, unsigned int esr, | |||
| 341 | 350 | ||
| 342 | return 0; | 351 | return 0; |
| 343 | } | 352 | } |
| 353 | NOKPROBE_SYMBOL(brk_handler); | ||
| 344 | 354 | ||
| 345 | int aarch32_break_handler(struct pt_regs *regs) | 355 | int aarch32_break_handler(struct pt_regs *regs) |
| 346 | { | 356 | { |
| @@ -377,6 +387,7 @@ int aarch32_break_handler(struct pt_regs *regs) | |||
| 377 | send_user_sigtrap(TRAP_BRKPT); | 387 | send_user_sigtrap(TRAP_BRKPT); |
| 378 | return 0; | 388 | return 0; |
| 379 | } | 389 | } |
| 390 | NOKPROBE_SYMBOL(aarch32_break_handler); | ||
| 380 | 391 | ||
| 381 | static int __init debug_traps_init(void) | 392 | static int __init debug_traps_init(void) |
| 382 | { | 393 | { |
| @@ -398,6 +409,7 @@ void user_rewind_single_step(struct task_struct *task) | |||
| 398 | if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP)) | 409 | if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP)) |
| 399 | set_regs_spsr_ss(task_pt_regs(task)); | 410 | set_regs_spsr_ss(task_pt_regs(task)); |
| 400 | } | 411 | } |
| 412 | NOKPROBE_SYMBOL(user_rewind_single_step); | ||
| 401 | 413 | ||
| 402 | void user_fastforward_single_step(struct task_struct *task) | 414 | void user_fastforward_single_step(struct task_struct *task) |
| 403 | { | 415 | { |
| @@ -413,6 +425,7 @@ void kernel_enable_single_step(struct pt_regs *regs) | |||
| 413 | mdscr_write(mdscr_read() | DBG_MDSCR_SS); | 425 | mdscr_write(mdscr_read() | DBG_MDSCR_SS); |
| 414 | enable_debug_monitors(DBG_ACTIVE_EL1); | 426 | enable_debug_monitors(DBG_ACTIVE_EL1); |
| 415 | } | 427 | } |
| 428 | NOKPROBE_SYMBOL(kernel_enable_single_step); | ||
| 416 | 429 | ||
| 417 | void kernel_disable_single_step(void) | 430 | void kernel_disable_single_step(void) |
| 418 | { | 431 | { |
| @@ -420,12 +433,14 @@ void kernel_disable_single_step(void) | |||
| 420 | mdscr_write(mdscr_read() & ~DBG_MDSCR_SS); | 433 | mdscr_write(mdscr_read() & ~DBG_MDSCR_SS); |
| 421 | disable_debug_monitors(DBG_ACTIVE_EL1); | 434 | disable_debug_monitors(DBG_ACTIVE_EL1); |
| 422 | } | 435 | } |
| 436 | NOKPROBE_SYMBOL(kernel_disable_single_step); | ||
| 423 | 437 | ||
| 424 | int kernel_active_single_step(void) | 438 | int kernel_active_single_step(void) |
| 425 | { | 439 | { |
| 426 | WARN_ON(!irqs_disabled()); | 440 | WARN_ON(!irqs_disabled()); |
| 427 | return mdscr_read() & DBG_MDSCR_SS; | 441 | return mdscr_read() & DBG_MDSCR_SS; |
| 428 | } | 442 | } |
| 443 | NOKPROBE_SYMBOL(kernel_active_single_step); | ||
| 429 | 444 | ||
| 430 | /* ptrace API */ | 445 | /* ptrace API */ |
| 431 | void user_enable_single_step(struct task_struct *task) | 446 | void user_enable_single_step(struct task_struct *task) |
| @@ -433,8 +448,10 @@ void user_enable_single_step(struct task_struct *task) | |||
| 433 | set_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); | 448 | set_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); |
| 434 | set_regs_spsr_ss(task_pt_regs(task)); | 449 | set_regs_spsr_ss(task_pt_regs(task)); |
| 435 | } | 450 | } |
| 451 | NOKPROBE_SYMBOL(user_enable_single_step); | ||
| 436 | 452 | ||
| 437 | void user_disable_single_step(struct task_struct *task) | 453 | void user_disable_single_step(struct task_struct *task) |
| 438 | { | 454 | { |
| 439 | clear_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); | 455 | clear_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); |
| 440 | } | 456 | } |
| 457 | NOKPROBE_SYMBOL(user_disable_single_step); | ||
diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index ce21aa88263f..26a6bf77d272 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/cpu_pm.h> | 24 | #include <linux/cpu_pm.h> |
| 25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
| 26 | #include <linux/hw_breakpoint.h> | 26 | #include <linux/hw_breakpoint.h> |
| 27 | #include <linux/kprobes.h> | ||
| 27 | #include <linux/perf_event.h> | 28 | #include <linux/perf_event.h> |
| 28 | #include <linux/ptrace.h> | 29 | #include <linux/ptrace.h> |
| 29 | #include <linux/smp.h> | 30 | #include <linux/smp.h> |
| @@ -127,6 +128,7 @@ static u64 read_wb_reg(int reg, int n) | |||
| 127 | 128 | ||
| 128 | return val; | 129 | return val; |
| 129 | } | 130 | } |
| 131 | NOKPROBE_SYMBOL(read_wb_reg); | ||
| 130 | 132 | ||
| 131 | static void write_wb_reg(int reg, int n, u64 val) | 133 | static void write_wb_reg(int reg, int n, u64 val) |
| 132 | { | 134 | { |
| @@ -140,6 +142,7 @@ static void write_wb_reg(int reg, int n, u64 val) | |||
| 140 | } | 142 | } |
| 141 | isb(); | 143 | isb(); |
| 142 | } | 144 | } |
| 145 | NOKPROBE_SYMBOL(write_wb_reg); | ||
| 143 | 146 | ||
| 144 | /* | 147 | /* |
| 145 | * Convert a breakpoint privilege level to the corresponding exception | 148 | * Convert a breakpoint privilege level to the corresponding exception |
| @@ -157,6 +160,7 @@ static enum dbg_active_el debug_exception_level(int privilege) | |||
| 157 | return -EINVAL; | 160 | return -EINVAL; |
| 158 | } | 161 | } |
| 159 | } | 162 | } |
| 163 | NOKPROBE_SYMBOL(debug_exception_level); | ||
| 160 | 164 | ||
| 161 | enum hw_breakpoint_ops { | 165 | enum hw_breakpoint_ops { |
| 162 | HW_BREAKPOINT_INSTALL, | 166 | HW_BREAKPOINT_INSTALL, |
| @@ -575,6 +579,7 @@ static void toggle_bp_registers(int reg, enum dbg_active_el el, int enable) | |||
| 575 | write_wb_reg(reg, i, ctrl); | 579 | write_wb_reg(reg, i, ctrl); |
| 576 | } | 580 | } |
| 577 | } | 581 | } |
| 582 | NOKPROBE_SYMBOL(toggle_bp_registers); | ||
| 578 | 583 | ||
| 579 | /* | 584 | /* |
| 580 | * Debug exception handlers. | 585 | * Debug exception handlers. |
| @@ -654,6 +659,7 @@ unlock: | |||
| 654 | 659 | ||
| 655 | return 0; | 660 | return 0; |
| 656 | } | 661 | } |
| 662 | NOKPROBE_SYMBOL(breakpoint_handler); | ||
| 657 | 663 | ||
| 658 | static int watchpoint_handler(unsigned long addr, unsigned int esr, | 664 | static int watchpoint_handler(unsigned long addr, unsigned int esr, |
| 659 | struct pt_regs *regs) | 665 | struct pt_regs *regs) |
| @@ -756,6 +762,7 @@ unlock: | |||
| 756 | 762 | ||
| 757 | return 0; | 763 | return 0; |
| 758 | } | 764 | } |
| 765 | NOKPROBE_SYMBOL(watchpoint_handler); | ||
| 759 | 766 | ||
| 760 | /* | 767 | /* |
| 761 | * Handle single-step exception. | 768 | * Handle single-step exception. |
| @@ -813,6 +820,7 @@ int reinstall_suspended_bps(struct pt_regs *regs) | |||
| 813 | 820 | ||
| 814 | return !handled_exception; | 821 | return !handled_exception; |
| 815 | } | 822 | } |
| 823 | NOKPROBE_SYMBOL(reinstall_suspended_bps); | ||
| 816 | 824 | ||
| 817 | /* | 825 | /* |
| 818 | * Context-switcher for restoring suspended breakpoints. | 826 | * Context-switcher for restoring suspended breakpoints. |
diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index b5f063e5eff7..8c57f6496e56 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
| 23 | #include <linux/kdebug.h> | 23 | #include <linux/kdebug.h> |
| 24 | #include <linux/kgdb.h> | 24 | #include <linux/kgdb.h> |
| 25 | #include <linux/kprobes.h> | ||
| 25 | #include <asm/traps.h> | 26 | #include <asm/traps.h> |
| 26 | 27 | ||
| 27 | struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { | 28 | struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { |
| @@ -230,6 +231,7 @@ static int kgdb_brk_fn(struct pt_regs *regs, unsigned int esr) | |||
| 230 | kgdb_handle_exception(1, SIGTRAP, 0, regs); | 231 | kgdb_handle_exception(1, SIGTRAP, 0, regs); |
| 231 | return 0; | 232 | return 0; |
| 232 | } | 233 | } |
| 234 | NOKPROBE_SYMBOL(kgdb_brk_fn) | ||
| 233 | 235 | ||
| 234 | static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) | 236 | static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) |
| 235 | { | 237 | { |
| @@ -238,12 +240,14 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) | |||
| 238 | 240 | ||
| 239 | return 0; | 241 | return 0; |
| 240 | } | 242 | } |
| 243 | NOKPROBE_SYMBOL(kgdb_compiled_brk_fn); | ||
| 241 | 244 | ||
| 242 | static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) | 245 | static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) |
| 243 | { | 246 | { |
| 244 | kgdb_handle_exception(1, SIGTRAP, 0, regs); | 247 | kgdb_handle_exception(1, SIGTRAP, 0, regs); |
| 245 | return 0; | 248 | return 0; |
| 246 | } | 249 | } |
| 250 | NOKPROBE_SYMBOL(kgdb_step_brk_fn); | ||
| 247 | 251 | ||
| 248 | static struct break_hook kgdb_brkpt_hook = { | 252 | static struct break_hook kgdb_brkpt_hook = { |
| 249 | .esr_mask = 0xffffffff, | 253 | .esr_mask = 0xffffffff, |
