Commit 2a7c3db6 authored by Yang Jihong's avatar Yang Jihong Committed by Zheng Zengkai
Browse files

livepatch/powerpc64: Add arch_klp_module_check_calltrace

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5CJ7X



--------------------------------

Add arch_klp_module_check_calltrace to check whether stacks of all tasks
are within the code segment of module.

Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
Reviewed-by: default avatarXu Kuohai <xukuohai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 8b458d5f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ int klp_brk_handler(struct pt_regs *regs);
int arch_klp_add_breakpoint(struct arch_klp_data *arch_data, void *old_func);
void arch_klp_remove_breakpoint(struct arch_klp_data *arch_data, void *old_func);
long arch_klp_save_old_code(struct arch_klp_data *arch_data, void *old_func);
int arch_klp_module_check_calltrace(void *data);

#endif /* CONFIG_LIVEPATCH_FTRACE */

+23 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ struct stackframe {
struct walk_stackframe_args {
	int enable;
	struct klp_func_list *check_funcs;
	struct module *mod;
	int ret;
};

@@ -421,6 +422,28 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
	free_list(&check_funcs);
	return ret;
}

static int check_module_calltrace(struct stackframe *frame, void *data)
{
	struct walk_stackframe_args *args = data;

	if (within_module_core(frame->pc, args->mod)) {
		pr_err("module %s is in use!\n", args->mod->name);
		return (args->ret = -EBUSY);
	}
	return 0;
}

int arch_klp_module_check_calltrace(void *data)
{
	struct walk_stackframe_args args = {
		.mod = (struct module *)data,
		.ret = 0
	};

	return do_check_calltrace(&args, check_module_calltrace);
}

#endif

#ifdef CONFIG_LIVEPATCH_WO_FTRACE