Commit 44b53f67 authored by Pratyush Anand's avatar Pratyush Anand Committed by Catalin Marinas

arm64: Blacklist non-kprobe-able symbol

Add all function symbols which are called from do_debug_exception under
NOKPROBE_SYMBOL, as they can not kprobed.
Signed-off-by: default avatarPratyush Anand <panand@redhat.com>
Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 2dd0e8d2
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/arm-smccc.h> #include <linux/arm-smccc.h>
#include <linux/kprobes.h>
#include <asm/checksum.h> #include <asm/checksum.h>
...@@ -68,6 +69,7 @@ EXPORT_SYMBOL(test_and_change_bit); ...@@ -68,6 +69,7 @@ EXPORT_SYMBOL(test_and_change_bit);
#ifdef CONFIG_FUNCTION_TRACER #ifdef CONFIG_FUNCTION_TRACER
EXPORT_SYMBOL(_mcount); EXPORT_SYMBOL(_mcount);
NOKPROBE_SYMBOL(_mcount);
#endif #endif
/* arm-smccc */ /* arm-smccc */
......
...@@ -49,6 +49,7 @@ static void mdscr_write(u32 mdscr) ...@@ -49,6 +49,7 @@ static void mdscr_write(u32 mdscr)
asm volatile("msr mdscr_el1, %0" :: "r" (mdscr)); asm volatile("msr mdscr_el1, %0" :: "r" (mdscr));
local_dbg_restore(flags); local_dbg_restore(flags);
} }
NOKPROBE_SYMBOL(mdscr_write);
static u32 mdscr_read(void) static u32 mdscr_read(void)
{ {
...@@ -56,6 +57,7 @@ static u32 mdscr_read(void) ...@@ -56,6 +57,7 @@ static u32 mdscr_read(void)
asm volatile("mrs %0, mdscr_el1" : "=r" (mdscr)); asm volatile("mrs %0, mdscr_el1" : "=r" (mdscr));
return mdscr; return mdscr;
} }
NOKPROBE_SYMBOL(mdscr_read);
/* /*
* Allow root to disable self-hosted debug from userspace. * Allow root to disable self-hosted debug from userspace.
...@@ -104,6 +106,7 @@ void enable_debug_monitors(enum dbg_active_el el) ...@@ -104,6 +106,7 @@ void enable_debug_monitors(enum dbg_active_el el)
mdscr_write(mdscr); mdscr_write(mdscr);
} }
} }
NOKPROBE_SYMBOL(enable_debug_monitors);
void disable_debug_monitors(enum dbg_active_el el) void disable_debug_monitors(enum dbg_active_el el)
{ {
...@@ -124,6 +127,7 @@ void disable_debug_monitors(enum dbg_active_el el) ...@@ -124,6 +127,7 @@ void disable_debug_monitors(enum dbg_active_el el)
mdscr_write(mdscr); mdscr_write(mdscr);
} }
} }
NOKPROBE_SYMBOL(disable_debug_monitors);
/* /*
* OS lock clearing. * OS lock clearing.
...@@ -174,6 +178,7 @@ static void set_regs_spsr_ss(struct pt_regs *regs) ...@@ -174,6 +178,7 @@ static void set_regs_spsr_ss(struct pt_regs *regs)
spsr |= DBG_SPSR_SS; spsr |= DBG_SPSR_SS;
regs->pstate = spsr; regs->pstate = spsr;
} }
NOKPROBE_SYMBOL(set_regs_spsr_ss);
static void clear_regs_spsr_ss(struct pt_regs *regs) static void clear_regs_spsr_ss(struct pt_regs *regs)
{ {
...@@ -183,6 +188,7 @@ static void clear_regs_spsr_ss(struct pt_regs *regs) ...@@ -183,6 +188,7 @@ static void clear_regs_spsr_ss(struct pt_regs *regs)
spsr &= ~DBG_SPSR_SS; spsr &= ~DBG_SPSR_SS;
regs->pstate = spsr; regs->pstate = spsr;
} }
NOKPROBE_SYMBOL(clear_regs_spsr_ss);
/* EL1 Single Step Handler hooks */ /* EL1 Single Step Handler hooks */
static LIST_HEAD(step_hook); static LIST_HEAD(step_hook);
...@@ -226,6 +232,7 @@ static int call_step_hook(struct pt_regs *regs, unsigned int esr) ...@@ -226,6 +232,7 @@ static int call_step_hook(struct pt_regs *regs, unsigned int esr)
return retval; return retval;
} }
NOKPROBE_SYMBOL(call_step_hook);
static void send_user_sigtrap(int si_code) static void send_user_sigtrap(int si_code)
{ {
...@@ -284,6 +291,7 @@ static int single_step_handler(unsigned long addr, unsigned int esr, ...@@ -284,6 +291,7 @@ static int single_step_handler(unsigned long addr, unsigned int esr,
return 0; return 0;
} }
NOKPROBE_SYMBOL(single_step_handler);
/* /*
* Breakpoint handler is re-entrant as another breakpoint can * 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,6 +329,7 @@ static int call_break_hook(struct pt_regs *regs, unsigned int esr)
return fn ? fn(regs, esr) : DBG_HOOK_ERROR; return fn ? fn(regs, esr) : DBG_HOOK_ERROR;
} }
NOKPROBE_SYMBOL(call_break_hook);
static int brk_handler(unsigned long addr, unsigned int esr, static int brk_handler(unsigned long addr, unsigned int esr,
struct pt_regs *regs) struct pt_regs *regs)
...@@ -341,6 +350,7 @@ static int brk_handler(unsigned long addr, unsigned int esr, ...@@ -341,6 +350,7 @@ static int brk_handler(unsigned long addr, unsigned int esr,
return 0; return 0;
} }
NOKPROBE_SYMBOL(brk_handler);
int aarch32_break_handler(struct pt_regs *regs) int aarch32_break_handler(struct pt_regs *regs)
{ {
...@@ -377,6 +387,7 @@ int aarch32_break_handler(struct pt_regs *regs) ...@@ -377,6 +387,7 @@ int aarch32_break_handler(struct pt_regs *regs)
send_user_sigtrap(TRAP_BRKPT); send_user_sigtrap(TRAP_BRKPT);
return 0; return 0;
} }
NOKPROBE_SYMBOL(aarch32_break_handler);
static int __init debug_traps_init(void) static int __init debug_traps_init(void)
{ {
...@@ -398,6 +409,7 @@ void user_rewind_single_step(struct task_struct *task) ...@@ -398,6 +409,7 @@ void user_rewind_single_step(struct task_struct *task)
if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP)) if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP))
set_regs_spsr_ss(task_pt_regs(task)); set_regs_spsr_ss(task_pt_regs(task));
} }
NOKPROBE_SYMBOL(user_rewind_single_step);
void user_fastforward_single_step(struct task_struct *task) void user_fastforward_single_step(struct task_struct *task)
{ {
...@@ -413,6 +425,7 @@ void kernel_enable_single_step(struct pt_regs *regs) ...@@ -413,6 +425,7 @@ void kernel_enable_single_step(struct pt_regs *regs)
mdscr_write(mdscr_read() | DBG_MDSCR_SS); mdscr_write(mdscr_read() | DBG_MDSCR_SS);
enable_debug_monitors(DBG_ACTIVE_EL1); enable_debug_monitors(DBG_ACTIVE_EL1);
} }
NOKPROBE_SYMBOL(kernel_enable_single_step);
void kernel_disable_single_step(void) void kernel_disable_single_step(void)
{ {
...@@ -420,12 +433,14 @@ void kernel_disable_single_step(void) ...@@ -420,12 +433,14 @@ void kernel_disable_single_step(void)
mdscr_write(mdscr_read() & ~DBG_MDSCR_SS); mdscr_write(mdscr_read() & ~DBG_MDSCR_SS);
disable_debug_monitors(DBG_ACTIVE_EL1); disable_debug_monitors(DBG_ACTIVE_EL1);
} }
NOKPROBE_SYMBOL(kernel_disable_single_step);
int kernel_active_single_step(void) int kernel_active_single_step(void)
{ {
WARN_ON(!irqs_disabled()); WARN_ON(!irqs_disabled());
return mdscr_read() & DBG_MDSCR_SS; return mdscr_read() & DBG_MDSCR_SS;
} }
NOKPROBE_SYMBOL(kernel_active_single_step);
/* ptrace API */ /* ptrace API */
void user_enable_single_step(struct task_struct *task) void user_enable_single_step(struct task_struct *task)
...@@ -433,8 +448,10 @@ void user_enable_single_step(struct task_struct *task) ...@@ -433,8 +448,10 @@ void user_enable_single_step(struct task_struct *task)
set_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); set_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP);
set_regs_spsr_ss(task_pt_regs(task)); set_regs_spsr_ss(task_pt_regs(task));
} }
NOKPROBE_SYMBOL(user_enable_single_step);
void user_disable_single_step(struct task_struct *task) void user_disable_single_step(struct task_struct *task)
{ {
clear_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP); clear_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP);
} }
NOKPROBE_SYMBOL(user_disable_single_step);
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/cpu_pm.h> #include <linux/cpu_pm.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/hw_breakpoint.h> #include <linux/hw_breakpoint.h>
#include <linux/kprobes.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -127,6 +128,7 @@ static u64 read_wb_reg(int reg, int n) ...@@ -127,6 +128,7 @@ static u64 read_wb_reg(int reg, int n)
return val; return val;
} }
NOKPROBE_SYMBOL(read_wb_reg);
static void write_wb_reg(int reg, int n, u64 val) static void write_wb_reg(int reg, int n, u64 val)
{ {
...@@ -140,6 +142,7 @@ static void write_wb_reg(int reg, int n, u64 val) ...@@ -140,6 +142,7 @@ static void write_wb_reg(int reg, int n, u64 val)
} }
isb(); isb();
} }
NOKPROBE_SYMBOL(write_wb_reg);
/* /*
* Convert a breakpoint privilege level to the corresponding exception * Convert a breakpoint privilege level to the corresponding exception
...@@ -157,6 +160,7 @@ static enum dbg_active_el debug_exception_level(int privilege) ...@@ -157,6 +160,7 @@ static enum dbg_active_el debug_exception_level(int privilege)
return -EINVAL; return -EINVAL;
} }
} }
NOKPROBE_SYMBOL(debug_exception_level);
enum hw_breakpoint_ops { enum hw_breakpoint_ops {
HW_BREAKPOINT_INSTALL, HW_BREAKPOINT_INSTALL,
...@@ -575,6 +579,7 @@ static void toggle_bp_registers(int reg, enum dbg_active_el el, int enable) ...@@ -575,6 +579,7 @@ static void toggle_bp_registers(int reg, enum dbg_active_el el, int enable)
write_wb_reg(reg, i, ctrl); write_wb_reg(reg, i, ctrl);
} }
} }
NOKPROBE_SYMBOL(toggle_bp_registers);
/* /*
* Debug exception handlers. * Debug exception handlers.
...@@ -654,6 +659,7 @@ static int breakpoint_handler(unsigned long unused, unsigned int esr, ...@@ -654,6 +659,7 @@ static int breakpoint_handler(unsigned long unused, unsigned int esr,
return 0; return 0;
} }
NOKPROBE_SYMBOL(breakpoint_handler);
static int watchpoint_handler(unsigned long addr, unsigned int esr, static int watchpoint_handler(unsigned long addr, unsigned int esr,
struct pt_regs *regs) struct pt_regs *regs)
...@@ -756,6 +762,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr, ...@@ -756,6 +762,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr,
return 0; return 0;
} }
NOKPROBE_SYMBOL(watchpoint_handler);
/* /*
* Handle single-step exception. * Handle single-step exception.
...@@ -813,6 +820,7 @@ int reinstall_suspended_bps(struct pt_regs *regs) ...@@ -813,6 +820,7 @@ int reinstall_suspended_bps(struct pt_regs *regs)
return !handled_exception; return !handled_exception;
} }
NOKPROBE_SYMBOL(reinstall_suspended_bps);
/* /*
* Context-switcher for restoring suspended breakpoints. * Context-switcher for restoring suspended breakpoints.
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/kdebug.h> #include <linux/kdebug.h>
#include <linux/kgdb.h> #include <linux/kgdb.h>
#include <linux/kprobes.h>
#include <asm/traps.h> #include <asm/traps.h>
struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { 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,6 +231,7 @@ static int kgdb_brk_fn(struct pt_regs *regs, unsigned int esr)
kgdb_handle_exception(1, SIGTRAP, 0, regs); kgdb_handle_exception(1, SIGTRAP, 0, regs);
return 0; return 0;
} }
NOKPROBE_SYMBOL(kgdb_brk_fn)
static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr)
{ {
...@@ -238,12 +240,14 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) ...@@ -238,12 +240,14 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr)
return 0; return 0;
} }
NOKPROBE_SYMBOL(kgdb_compiled_brk_fn);
static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
{ {
kgdb_handle_exception(1, SIGTRAP, 0, regs); kgdb_handle_exception(1, SIGTRAP, 0, regs);
return 0; return 0;
} }
NOKPROBE_SYMBOL(kgdb_step_brk_fn);
static struct break_hook kgdb_brkpt_hook = { static struct break_hook kgdb_brkpt_hook = {
.esr_mask = 0xffffffff, .esr_mask = 0xffffffff,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment