[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260209132510.84205-1-xieyuanbin1@huawei.com>
Date: Mon, 9 Feb 2026 21:25:01 +0800
From: Xie Yuanbin <xieyuanbin1@...wei.com>
To: <chleroy@...nel.org>, <andriy.shevchenko@...el.com>,
<maddy@...ux.ibm.com>, <mpe@...erman.id.au>, <npiggin@...il.com>,
<kees@...nel.org>, <andy@...nel.org>
CC: <linuxppc-dev@...ts.ozlabs.org>, <linux-kernel@...r.kernel.org>,
<linux-hardening@...r.kernel.org>, <lilinjie8@...wei.com>,
<liaohua4@...wei.com>, <xieyuanbin1@...wei.com>
Subject: Re: [PATCH 2/2] powerpc/text-patching: Fix possible stringop-overread compilation error
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; \
})
```
Powered by blists - more mailing lists