With CONFIG_LTO_CLANG, kallsyms.c:cleanup_symbol_name() removes symbols suffixes during comparison. This is problematic for livepatch, as kallsyms_on_each_match_symbol may find multiple matches for the same symbol, and fail with: livepatch: unresolvable ambiguity for symbol 'xxx' in object 'yyy' Fix this by using kallsyms_on_each_symbol instead, and matching symbols exactly. Signed-off-by: Song Liu <song@xxxxxxxxxx> --- kernel/livepatch/core.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 61328328c474..507e1e2e4290 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -125,10 +125,13 @@ struct klp_find_arg { unsigned long pos; }; -static int klp_match_callback(void *data, unsigned long addr) +static int klp_find_callback(void *data, const char *name, unsigned long addr) { struct klp_find_arg *args = data; + if (strcmp(args->name, name)) + return 0; + args->addr = addr; args->count++; @@ -143,16 +146,6 @@ static int klp_match_callback(void *data, unsigned long addr) return 0; } -static int klp_find_callback(void *data, const char *name, unsigned long addr) -{ - struct klp_find_arg *args = data; - - if (strcmp(args->name, name)) - return 0; - - return klp_match_callback(data, addr); -} - static int klp_find_object_symbol(const char *objname, const char *name, unsigned long sympos, unsigned long *addr) { @@ -166,7 +159,7 @@ static int klp_find_object_symbol(const char *objname, const char *name, if (objname) module_kallsyms_on_each_symbol(objname, klp_find_callback, &args); else - kallsyms_on_each_match_symbol(klp_match_callback, name, &args); + kallsyms_on_each_symbol(klp_find_callback, &args); /* * Ensure an address was found. If sympos is 0, ensure symbol is unique; -- 2.34.1