mirror of https://github.com/dynup/kpatch
Merge pull request #1279 from joe-lawrence/syscalls
macros: tweak syscall patching macros
This commit is contained in:
commit
dbde872cee
|
@ -38,6 +38,8 @@
|
|||
|
||||
#ifdef CONFIG_X86_64
|
||||
|
||||
/* x86/include/asm/syscall_wrapper.h versions */
|
||||
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
|
||||
|
||||
# define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \
|
||||
|
@ -75,49 +77,12 @@
|
|||
} \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) */
|
||||
|
||||
#define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \
|
||||
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
|
||||
static inline long __kpatch_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
|
||||
asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
||||
{ \
|
||||
long ret = __kpatch_SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
|
||||
__MAP(x,__SC_TEST,__VA_ARGS__); \
|
||||
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
|
||||
return ret; \
|
||||
} \
|
||||
SYSCALL_ALIAS(sys##name, SyS##name); \
|
||||
static inline long __kpatch_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
# endif /* LINUX_VERSION_CODE */
|
||||
|
||||
|
||||
#elif defined(CONFIG_PPC64)
|
||||
|
||||
#define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \
|
||||
__diag_push(); \
|
||||
__diag_ignore(GCC, 8, "-Wattribute-alias", \
|
||||
"Type aliasing is used to sanitize syscall arguments");\
|
||||
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
|
||||
__attribute__((alias(__stringify(__se_sys##name)))); \
|
||||
ALLOW_ERROR_INJECTION(sys##name, ERRNO); \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
|
||||
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
||||
asmlinkage long __attribute__((optimize("-fno-optimize-sibling-calls")))\
|
||||
__se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
||||
{ \
|
||||
long ret = __kpatch_do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
|
||||
__MAP(x,__SC_TEST,__VA_ARGS__); \
|
||||
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
|
||||
return ret; \
|
||||
} \
|
||||
__diag_pop(); \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
|
||||
#elif defined(CONFIG_S390)
|
||||
|
||||
/* s390/include/asm/syscall_wrapper.h versions */
|
||||
|
||||
#define __KPATCH_S390_SYS_STUBx(x, name, ...) \
|
||||
long __s390_sys##name(struct pt_regs *regs); \
|
||||
ALLOW_ERROR_INJECTION(__s390_sys##name, ERRNO); \
|
||||
|
@ -149,7 +114,67 @@
|
|||
__diag_pop(); \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
|
||||
#endif /* CONFIG_X86_64 */
|
||||
|
||||
|
||||
#ifndef __KPATCH_SYSCALL_DEFINEx
|
||||
|
||||
/* include/linux/syscalls.h versions */
|
||||
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
|
||||
# define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \
|
||||
__diag_push(); \
|
||||
__diag_ignore(GCC, 8, "-Wattribute-alias", \
|
||||
"Type aliasing is used to sanitize syscall arguments");\
|
||||
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
|
||||
__attribute__((alias(__stringify(__se_sys##name)))); \
|
||||
ALLOW_ERROR_INJECTION(sys##name, ERRNO); \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
|
||||
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
||||
asmlinkage long __attribute__((optimize("-fno-optimize-sibling-calls")))\
|
||||
__se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
||||
{ \
|
||||
long ret = __kpatch_do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
|
||||
__MAP(x,__SC_TEST,__VA_ARGS__); \
|
||||
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
|
||||
return ret; \
|
||||
} \
|
||||
__diag_pop(); \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
|
||||
# define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \
|
||||
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
|
||||
__attribute__((alias(__stringify(__se_sys##name)))); \
|
||||
ALLOW_ERROR_INJECTION(sys##name, ERRNO); \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
|
||||
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
||||
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
||||
{ \
|
||||
long ret = __kpatch_do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
|
||||
__MAP(x,__SC_TEST,__VA_ARGS__); \
|
||||
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
|
||||
return ret; \
|
||||
} \
|
||||
static inline long __kpatch_do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
# else
|
||||
# define __KPATCH_SYSCALL_DEFINEx(x, name, ...) \
|
||||
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
|
||||
__attribute__((alias(__stringify(SyS##name)))); \
|
||||
static inline long __kpatch_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
|
||||
asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
||||
asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
|
||||
{ \
|
||||
long ret = __kpatch_SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
|
||||
__MAP(x,__SC_TEST,__VA_ARGS__); \
|
||||
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
|
||||
return ret; \
|
||||
} \
|
||||
static inline long __kpatch_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* __KPATCH_SYSCALL_DEFINEx */
|
||||
|
||||
#endif /* __KPATCH_SYSCALL_H_ */
|
||||
|
|
Loading…
Reference in New Issue