Re: [PATCH v3 21/21] klp-build: Add arm64 syscall patching macro

Josh Poimboeuf <[email protected]>
Newsgroups org.kernel.vger.live-patching,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <rumkp7mj6x4jo3r4x3erzkcwqkssbf5n46fxvrgcan7u4n2fuk@pkleqal5rqgr>
On Fri, May 15, 2026 at 02:44:39AM +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The arm64 __KLP_SYSCALL_DEFINEx macro omits the ALLOW_ERROR_INJECTION declaration, silently breaking BPF error injection for livepatched syscalls.
> --
> 
> commit b4d1a9ea352f196a7fd3e7198fdade51440d08e5
> Author: Josh Poimboeuf <[email protected]>
> 
> klp-build: Add arm64 syscall patching macro
> 
> This commit adds arm64 support for KLP_SYSCALL_DEFINEx(). The commit
> message states it is mirroring the arm64 __SYSCALL_DEFINEx() pattern from
> arch/arm64/include/asm/syscall_wrapper.h.
> 
> > diff --git a/include/linux/livepatch_helpers.h b/include/linux/livepatch_helpers.h
> > index 99d68d0773fa8..4b647b83865f9 100644
> > --- a/include/linux/livepatch_helpers.h
> > +++ b/include/linux/livepatch_helpers.h
> > @@ -72,6 +72,25 @@
> >  	}								\
> >  	static inline long __klp_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
> >  
> > +#elif defined(CONFIG_ARM64)
> > +
> > +#define __KLP_SYSCALL_DEFINEx(x, name, ...)				\
> > +	static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__));	\
> > +	static inline long __klp_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
> > +	asmlinkage long __arm64_sys##name(const struct pt_regs *regs);	\
> > +	asmlinkage long __arm64_sys##name(const struct pt_regs *regs)	\
> > +	{								\
> > +		return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__));\
> > +	}								\
> 
> Does this macro definition omit the ALLOW_ERROR_INJECTION declaration?
> 
> The standard arm64 __SYSCALL_DEFINEx() macro explicitly registers the top-level
> syscall handler with ALLOW_ERROR_INJECTION() to enable BPF error injection
> workflows like bpf_override_return(). The x86 implementation correctly
> preserves this functionality.
> 
> Because this macro is missing that declaration, it looks like it might
> introduce a regression where BPF cannot inject errors into the replacement
> syscalls in a livepatch module on arm64.

Fixed.

-- 
Josh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.