Commit 3792ea4d authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

livepatch: Print logs when check calltrace failed

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



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

Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarKuohai Xu <xukuohai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 3c2830a6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -283,8 +283,10 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
	};

	ret = klp_check_activeness_func(patch, enable, &check_funcs);
	if (ret)
	if (ret) {
		pr_err("collect active functions failed, ret=%d\n", ret);
		goto out;
	}
	args.check_funcs = check_funcs;

	for_each_process_thread(g, t) {
+3 −1
Original line number Diff line number Diff line
@@ -276,8 +276,10 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
	};

	ret = klp_check_activeness_func(patch, enable, &check_funcs);
	if (ret)
	if (ret) {
		pr_err("collect active functions failed, ret=%d\n", ret);
		goto out;
	}
	args.check_funcs = check_funcs;

	for_each_process_thread(g, t) {
+3 −1
Original line number Diff line number Diff line
@@ -311,8 +311,10 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
	};

	ret = klp_check_activeness_func(patch, enable, &check_funcs);
	if (ret)
	if (ret) {
		pr_err("collect active functions failed, ret=%d\n", ret);
		goto out;
	}
	args.check_funcs = check_funcs;

	for_each_process_thread(g, t) {
+3 −1
Original line number Diff line number Diff line
@@ -359,8 +359,10 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
	struct walk_stackframe_args args;

	ret = klp_check_activeness_func(patch, enable, &check_funcs);
	if (ret)
	if (ret) {
		pr_err("collect active functions failed, ret=%d\n", ret);
		goto out;
	}
	args.check_funcs = check_funcs;
	args.ret = 0;

+14 −10
Original line number Diff line number Diff line
@@ -321,39 +321,43 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
#endif

	ret = klp_check_activeness_func(patch, enable, &check_funcs);
	if (ret)
	if (ret) {
		pr_err("collect active functions failed, ret=%d\n", ret);
		goto out;
	}
	for_each_process_thread(g, t) {
		if (!strncmp(t->comm, "migration/", 10))
			continue;

#ifdef CONFIG_ARCH_STACKWALK
		ret = stack_trace_save_tsk_reliable(t, trace_entries, MAX_STACK_ENTRIES);
		if (ret < 0)
		if (ret < 0) {
			pr_err("%s:%d has an unreliable stack, ret=%d\n",
			       t->comm, t->pid, ret);
			goto out;
		}
		trace_len = ret;
		ret = 0;
		ret = klp_check_stack(trace_entries, trace_len, check_funcs);
#else
		trace.skip = 0;
		trace.nr_entries = 0;
		trace.max_entries = MAX_STACK_ENTRIES;
		trace.entries = trace_entries;
		ret = save_stack_trace_tsk_reliable(t, &trace);
#endif
		WARN_ON_ONCE(ret == -ENOSYS);
		if (ret) {
			pr_info("%s: %s:%d has an unreliable stack\n",
				 __func__, t->comm, t->pid);
			pr_err("%s: %s:%d has an unreliable stack, ret=%d\n",
			       __func__, t->comm, t->pid, ret);
			goto out;
		}
#ifdef CONFIG_ARCH_STACKWALK
		ret = klp_check_stack(trace_entries, trace_len, check_funcs);
#else
		ret = klp_check_stack(&trace, 0, check_funcs);
#endif
		if (ret)
		if (ret) {
			pr_err("%s:%d check stack failed, ret=%d\n",
			       t->comm, t->pid, ret);
			goto out;
		}
	}

out:
	free_list(&check_funcs);