Commit 4b69775b authored by Yang Jihong's avatar Yang Jihong Committed by Zheng Zengkai
Browse files

livepatch/x86: 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 a42ae8c0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ int arch_klp_check_breakpoint(struct arch_klp_data *arch_data, void *old_func);
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);
int klp_int3_handler(struct pt_regs *regs);
int arch_klp_module_check_calltrace(void *data);
#endif

#endif
+17 −0
Original line number Diff line number Diff line
@@ -372,6 +372,23 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
	return ret;
}

static bool check_module_calltrace(void *data, int *ret, unsigned long pc)
{
	struct module *mod = (struct module *)data;

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

int arch_klp_module_check_calltrace(void *data)
{
	return do_check_calltrace(check_module_calltrace, data);
}

int arch_klp_check_breakpoint(struct arch_klp_data *arch_data, void *old_func)
{
	int ret;