Loading arch/x86/kernel/livepatch.c +51 −29 Original line number Diff line number Diff line Loading @@ -252,9 +252,10 @@ static int klp_check_stack(void *trace_ptr, int trace_len, return 0; } static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *data) static int check_task_calltrace(struct task_struct *t, bool (*fn)(void *, int *, unsigned long), void *data) { struct task_struct *g, *t; int ret = 0; static unsigned long trace_entries[MAX_STACK_ENTRIES]; #ifdef CONFIG_ARCH_STACKWALK Loading @@ -263,10 +264,6 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da struct stack_trace trace; #endif for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) continue; #ifdef CONFIG_ARCH_STACKWALK ret = stack_trace_save_tsk_reliable(t, trace_entries, MAX_STACK_ENTRIES); if (ret < 0) { Loading @@ -282,7 +279,6 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da trace.max_entries = MAX_STACK_ENTRIES; trace.entries = trace_entries; ret = save_stack_trace_tsk_reliable(t, &trace); WARN_ON_ONCE(ret == -ENOSYS); if (ret) { pr_err("%s: %s:%d has an unreliable stack, ret=%d\n", __func__, t->comm, t->pid, ret); Loading @@ -295,6 +291,21 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da t->comm, t->pid, ret); return ret; } return 0; } static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *data) { int ret = 0; struct task_struct *g, *t; for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) continue; ret = check_task_calltrace(t, fn, data); if (ret) return ret; } return 0; Loading @@ -312,6 +323,17 @@ static bool check_module_calltrace(void *data, int *ret, unsigned long pc) return true; } #ifdef CONFIG_LIVEPATCH_BREAKPOINT_NO_STOP_MACHINE int arch_klp_check_task_calltrace(struct task_struct *t, bool (*fn)(void *, int *, unsigned long), void *data) { if (t == NULL) return -EINVAL; return check_task_calltrace(t, fn, data); } #endif int arch_klp_check_calltrace(bool (*check_func)(void *, int *, unsigned long), void *data) { return do_check_calltrace(check_func, data); Loading Loading
arch/x86/kernel/livepatch.c +51 −29 Original line number Diff line number Diff line Loading @@ -252,9 +252,10 @@ static int klp_check_stack(void *trace_ptr, int trace_len, return 0; } static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *data) static int check_task_calltrace(struct task_struct *t, bool (*fn)(void *, int *, unsigned long), void *data) { struct task_struct *g, *t; int ret = 0; static unsigned long trace_entries[MAX_STACK_ENTRIES]; #ifdef CONFIG_ARCH_STACKWALK Loading @@ -263,10 +264,6 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da struct stack_trace trace; #endif for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) continue; #ifdef CONFIG_ARCH_STACKWALK ret = stack_trace_save_tsk_reliable(t, trace_entries, MAX_STACK_ENTRIES); if (ret < 0) { Loading @@ -282,7 +279,6 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da trace.max_entries = MAX_STACK_ENTRIES; trace.entries = trace_entries; ret = save_stack_trace_tsk_reliable(t, &trace); WARN_ON_ONCE(ret == -ENOSYS); if (ret) { pr_err("%s: %s:%d has an unreliable stack, ret=%d\n", __func__, t->comm, t->pid, ret); Loading @@ -295,6 +291,21 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da t->comm, t->pid, ret); return ret; } return 0; } static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *data) { int ret = 0; struct task_struct *g, *t; for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) continue; ret = check_task_calltrace(t, fn, data); if (ret) return ret; } return 0; Loading @@ -312,6 +323,17 @@ static bool check_module_calltrace(void *data, int *ret, unsigned long pc) return true; } #ifdef CONFIG_LIVEPATCH_BREAKPOINT_NO_STOP_MACHINE int arch_klp_check_task_calltrace(struct task_struct *t, bool (*fn)(void *, int *, unsigned long), void *data) { if (t == NULL) return -EINVAL; return check_task_calltrace(t, fn, data); } #endif int arch_klp_check_calltrace(bool (*check_func)(void *, int *, unsigned long), void *data) { return do_check_calltrace(check_func, data); Loading