On Fri, 6 Feb 2026 20:53:55 +0100, Christophe Leroy (CS GROUP) wrote:
> Le 06/02/2026 ?? 19:26, Kees Cook a ??crit :
>>
>> Isn't it possible to do this and not need __compiletime_strlen at all?
>>
>> n_len = strnlen(name, min(__member_size(name), KSYM_NAME_LEN));
>
> ppc_kallsyms_lookup_name() only has two callers and they call it with a
> built-in string. I think we can do something a lot simpler, something
> like (untested):
>
> static inline unsigned long __ppc_kallsyms_lookup_name(const char *name)
> {
> unsigned long addr = kallsyms_lookup_name(name);
>
> if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2) && addr)
> addr = ppc_function_entry((void *)addr);
>
> return addr;
> }
>
> #ifdef CONFIG_PPC64_ELF_ABI_V1
> #define ppc_kallsyms_lookup_name(x) __ppc_kallsyms_lookup_name("." ## x);
> #else
> #define ppc_kallsyms_lookup_name(x) __ppc_kallsyms_lookup_name(x)
> #endif
>
> Christophe
When CONFIG_PPC64_ELF_ABI_V1=y, it seems that the try of lookupinp
the original non-dot symbol is missing.
What about this (Only the compilation test is performed):
```c
static inline unsigned long __ppc_kallsyms_lookup_name(const char *name)
{
unsigned long addr = kallsyms_lookup_name(name);
if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2) && addr)
addr = ppc_function_entry((void *)addr);
return addr;
}
#define ppc_kallsyms_lookup_name(x) ({ \
unsigned long addr = 0; \
if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1)) \
addr = __ppc_kallsyms_lookup_name("." x); \
if (!addr) \
addr = __ppc_kallsyms_lookup_name(x); \
addr; \
})
```