diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 707b0a908..4f9cf44ec 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -430,6 +430,30 @@ static int __kpatch_unique_id_strcmp(char *s1, char *s2) return 1; } +static int __kpatch_skip_digits_strcmp(char *s1, char *s2) +{ + while (*s1 && *s2) { + while (isdigit(*s1)) + s1++; + while (isdigit(*s2)) + s2++; + if (*s1 != *s2) + return 0; + + /* + * The pointers may be moved to skip the digits, so it is + * necessary to check again before advancing the pointers. + */ + if (*s1 == '\0' || *s2 == '\0') + break; + + s1++; + s2++; + } + + return *s1 == *s2; +} + /* * This is like strcmp, but for gcc-mangled symbols. It skips the comparison * of any substring which consists of '.' followed by any number of digits. @@ -446,6 +470,19 @@ static int kpatch_mangled_strcmp(char *s1, char *s2) if (!strncmp(s1, "__UNIQUE_ID_", 12)) return __kpatch_unique_id_strcmp(s1, s2); + /* + * Hack for __initcall_stub() with CONFIG_LTO_CLANG. + * The following should match: + * + * __initstub__kmod_syscall__728_5326_bpf_syscall_sysctl_init7 + * __initstub__kmod_syscall__728_5324_bpf_syscall_sysctl_init7 + * + * Please refer to __initcall_stub() in include/linux/init.h for + * more details. + */ + if (!strncmp(s1, "__initstub__kmod_syscall__", 26)) + return __kpatch_skip_digits_strcmp(s1, s2); + while (*s1 == *s2) { if (!*s1) return 0;