Commit 78e923cf authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

livepatch: Fix compile error when CONFIG_LIVEPATCH_WO_FTRACE disabled

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I67QMO


CVE: NA

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

When disable CONFIG_LIVEPATCH_WO_FTRACE, compiler report following error:
  kernel/livepatch/core.c: In function ‘check_address_conflict’:
  kernel/livepatch/core.c:1214:18: error: ‘KLP_MAX_REPLACE_SIZE’
  undeclared (first use in this function)
   1214 |    end = start + KLP_MAX_REPLACE_SIZE - 1;
        |                  ^~~~~~~~~~~~~~~~~~~~
  kernel/livepatch/core.c:1214:18: note: each undeclared identifier is
  reported only once for each function it appears in
  At top level:
  kernel/livepatch/core.c:1195:12: warning: ‘check_address_conflict’
  defined but not used [-Wunused-function]
   1195 | static int check_address_conflict(struct klp_patch *patch)
        |            ^~~~~~~~~~~~~~~~~~~~~~

Fixes: 2c3c0b3a ("livepatch/x86: Avoid conflict with static {call,key}")
Fixes: ed8c4c72 ("livepatch/core: Restrict minimum size of function that can be patched")
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 0af20926
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1041,11 +1041,13 @@ static int klp_init_object_loaded(struct klp_patch *patch,
			       func->old_name);
			return -ENOENT;
		}
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
		if (func->old_size < KLP_MAX_REPLACE_SIZE) {
			pr_err("%s size less than limit (%lu < %zu)\n", func->old_name,
			       func->old_size, KLP_MAX_REPLACE_SIZE);
			return -EINVAL;
		}
#endif

#ifdef PPC64_ELF_ABI_v1
		/*
@@ -1195,6 +1197,7 @@ extern int klp_static_call_register(struct module *mod);
static inline int klp_static_call_register(struct module *mod) { return 0; }
#endif

#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
static int check_address_conflict(struct klp_patch *patch)
{
	struct klp_object *obj;
@@ -1231,6 +1234,7 @@ static int check_address_conflict(struct klp_patch *patch)
	}
	return 0;
}
#endif

static int klp_init_patch(struct klp_patch *patch)
{
@@ -1278,11 +1282,11 @@ static int klp_init_patch(struct klp_patch *patch)
	}
	module_enable_ro(patch->mod, true);

#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
	ret = check_address_conflict(patch);
	if (ret)
		return ret;

#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
	klp_for_each_object(patch, obj)
		klp_load_hook(obj);
#endif