Thread (11 messages) flat view 11 messages, 4 authors, 2026-04-30

Re: [PATCH 2/2] powerpc/text-patching: Fix possible stringop-overread compilation error

From: Xie Yuanbin <hidden>
Date: 2026-02-09 13:25:17
Also in: linux-hardening, lkml

On Fri, 6 Feb 2026 20:53:55 +0100, Christophe Leroy (CS GROUP) wrote:
Le 06/02/2026 à 19:26, Kees Cook a écrit :
quoted
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):
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;							\
	})
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help