Commit 16db6264 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Thomas Gleixner

kprobes: Support NOKPROBE_SYMBOL() in modules

Support NOKPROBE_SYMBOL() in modules. NOKPROBE_SYMBOL() records only symbol
address in "_kprobe_blacklist" section in the module.
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarAlexandre Chartre <alexandre.chartre@oracle.com>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200505134059.771170126@linutronix.de
parent 1e6769b0
...@@ -492,6 +492,8 @@ struct module { ...@@ -492,6 +492,8 @@ struct module {
#ifdef CONFIG_KPROBES #ifdef CONFIG_KPROBES
void *kprobes_text_start; void *kprobes_text_start;
unsigned int kprobes_text_size; unsigned int kprobes_text_size;
unsigned long *kprobe_blacklist;
unsigned int num_kprobe_blacklist;
#endif #endif
#ifdef CONFIG_LIVEPATCH #ifdef CONFIG_LIVEPATCH
......
...@@ -2192,6 +2192,11 @@ static void kprobe_remove_area_blacklist(unsigned long start, unsigned long end) ...@@ -2192,6 +2192,11 @@ static void kprobe_remove_area_blacklist(unsigned long start, unsigned long end)
} }
} }
static void kprobe_remove_ksym_blacklist(unsigned long entry)
{
kprobe_remove_area_blacklist(entry, entry + 1);
}
int __init __weak arch_populate_kprobe_blacklist(void) int __init __weak arch_populate_kprobe_blacklist(void)
{ {
return 0; return 0;
...@@ -2231,6 +2236,12 @@ static int __init populate_kprobe_blacklist(unsigned long *start, ...@@ -2231,6 +2236,12 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
static void add_module_kprobe_blacklist(struct module *mod) static void add_module_kprobe_blacklist(struct module *mod)
{ {
unsigned long start, end; unsigned long start, end;
int i;
if (mod->kprobe_blacklist) {
for (i = 0; i < mod->num_kprobe_blacklist; i++)
kprobe_add_ksym_blacklist(mod->kprobe_blacklist[i]);
}
start = (unsigned long)mod->kprobes_text_start; start = (unsigned long)mod->kprobes_text_start;
if (start) { if (start) {
...@@ -2242,6 +2253,12 @@ static void add_module_kprobe_blacklist(struct module *mod) ...@@ -2242,6 +2253,12 @@ static void add_module_kprobe_blacklist(struct module *mod)
static void remove_module_kprobe_blacklist(struct module *mod) static void remove_module_kprobe_blacklist(struct module *mod)
{ {
unsigned long start, end; unsigned long start, end;
int i;
if (mod->kprobe_blacklist) {
for (i = 0; i < mod->num_kprobe_blacklist; i++)
kprobe_remove_ksym_blacklist(mod->kprobe_blacklist[i]);
}
start = (unsigned long)mod->kprobes_text_start; start = (unsigned long)mod->kprobes_text_start;
if (start) { if (start) {
......
...@@ -3197,6 +3197,9 @@ static int find_module_sections(struct module *mod, struct load_info *info) ...@@ -3197,6 +3197,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
#ifdef CONFIG_KPROBES #ifdef CONFIG_KPROBES
mod->kprobes_text_start = section_objs(info, ".kprobes.text", 1, mod->kprobes_text_start = section_objs(info, ".kprobes.text", 1,
&mod->kprobes_text_size); &mod->kprobes_text_size);
mod->kprobe_blacklist = section_objs(info, "_kprobe_blacklist",
sizeof(unsigned long),
&mod->num_kprobe_blacklist);
#endif #endif
mod->extable = section_objs(info, "__ex_table", mod->extable = section_objs(info, "__ex_table",
sizeof(*mod->extable), &mod->num_exentries); sizeof(*mod->extable), &mod->num_exentries);
......
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