From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Xie Yuanbin <xieyuanbin1@huawei.com>,
andriy.shevchenko@intel.com, maddy@linux.ibm.com,
mpe@ellerman.id.au, npiggin@gmail.com, kees@kernel.org,
andy@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org, lilinjie8@huawei.com,
liaohua4@huawei.com
Subject: Re: [PATCH 2/2] powerpc/text-patching: Fix possible stringop-overread compilation error
Date: Mon, 9 Feb 2026 14:41:51 +0100 [thread overview]
Message-ID: <5cfae419-427a-471b-8bbe-645f56442e2c@kernel.org> (raw)
In-Reply-To: <20260209132510.84205-1-xieyuanbin1@huawei.com>
Le 09/02/2026 à 14:25, Xie Yuanbin a écrit :
> 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; \
> })
> ```
Good point.
To avoid duplicating the string I'd suggest:
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_V1) && !addr)
addr = kallsyms_lookup_name(name + 1);
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
next prev parent reply other threads:[~2026-02-09 13:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 10:05 [PATCH 1/2] string: move __compiletime_strlen() to string.h Xie Yuanbin
2026-02-05 10:05 ` [PATCH 2/2] powerpc/text-patching: Fix possible stringop-overread compilation error Xie Yuanbin
2026-02-05 16:40 ` Andy Shevchenko
2026-02-06 11:14 ` Xie Yuanbin
2026-02-06 18:26 ` Kees Cook
2026-02-06 19:53 ` Christophe Leroy (CS GROUP)
2026-02-09 13:25 ` Xie Yuanbin
2026-02-09 13:41 ` Christophe Leroy (CS GROUP) [this message]
2026-02-09 14:11 ` Xie Yuanbin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5cfae419-427a-471b-8bbe-645f56442e2c@kernel.org \
--to=chleroy@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=kees@kernel.org \
--cc=liaohua4@huawei.com \
--cc=lilinjie8@huawei.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=xieyuanbin1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox