From: Christian Brauner Date: Tue, 4 May 2021 11:21:28 +0000 (+0200) Subject: syscalls: wrap personality syscall if undefined X-Git-Tag: lxc-5.0.0~178^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3857c4ebf05e6642e22aa4470a91b3aae15cfdee;p=thirdparty%2Flxc.git syscalls: wrap personality syscall if undefined There's no need to making personality handling conditional as it has been around for such a long time that only weird systems wouldn't have support for it. And especially if the user requested a specific personality to be set but the system doesn't support the personality syscall we should loudly fail instead of moving on. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/macro.h b/src/lxc/macro.h index 42f95c235..ab4f989be 100644 --- a/src/lxc/macro.h +++ b/src/lxc/macro.h @@ -22,6 +22,7 @@ #include #include "compiler.h" +#include "config.h" #ifndef PATH_MAX #define PATH_MAX 4096 @@ -741,4 +742,9 @@ enum { #define BITS_PER_TYPE(type) (sizeof(type) * 8) #define LAST_BIT_PER_TYPE(type) (BITS_PER_TYPE(type) - 1) +#ifndef HAVE_SYS_PERSONALITY_H +#define PER_LINUX 0x0000 +#define PER_LINUX32 0x0008 +#endif + #endif /* __LXC_MACRO_H */ diff --git a/src/lxc/syscall_numbers.h b/src/lxc/syscall_numbers.h index 063316de3..97273b449 100644 --- a/src/lxc/syscall_numbers.h +++ b/src/lxc/syscall_numbers.h @@ -700,4 +700,43 @@ #endif #endif +#ifndef __NR_personality + #if defined __alpha__ + #define __NR_personality 324 + #elif defined __m68k__ + #define __NR_personality 136 + #elif defined __i386__ + #define __NR_personality 136 + #elif defined __x86_64__ + #define __NR_personality 135 + #elif defined __arm__ + #define __NR_personality 136 + #elif defined __aarch64__ + #define __NR_personality 92 + #elif defined __s390__ + #define __NR_personality 136 + #elif defined __powerpc__ + #define __NR_personality 136 + #elif defined __riscv + #define __NR_personality -1 + #elif defined __sparc__ + #define __NR_personality 191 + #elif defined __ia64__ + #define __NR_personality (116 + 1024) + #elif defined _MIPS_SIM + #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ + #define __NR_personality (136 + 4000) + #endif + #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ + #define __NR_personality (132 + 6000) + #endif + #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ + #define __NR_personality (132 + 5000) + #endif + #else + #define -1 + #warning "__NR_personality not defined for your architecture" + #endif +#endif + #endif /* __LXC_SYSCALL_NUMBERS_H */ diff --git a/src/lxc/syscall_wrappers.h b/src/lxc/syscall_wrappers.h index 718821147..e340f7f07 100644 --- a/src/lxc/syscall_wrappers.h +++ b/src/lxc/syscall_wrappers.h @@ -317,4 +317,11 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int } #endif +#ifndef HAVE_SYS_PERSONALITY_H +static inline int personality(unsigned long persona) +{ + return syscall(__NR_personality, persona); +} +#endif + #endif /* __LXC_SYSCALL_WRAPPER_H */