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: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 9cc5d48b
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <unistd.h> #include <unistd.h>
#include "compiler.h" #include "compiler.h"
#include "config.h"
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 4096 #define PATH_MAX 4096
...@@ -741,4 +742,9 @@ enum { ...@@ -741,4 +742,9 @@ enum {
#define BITS_PER_TYPE(type) (sizeof(type) * 8) #define BITS_PER_TYPE(type) (sizeof(type) * 8)
#define LAST_BIT_PER_TYPE(type) (BITS_PER_TYPE(type) - 1) #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 */ #endif /* __LXC_MACRO_H */
...@@ -700,4 +700,43 @@ ...@@ -700,4 +700,43 @@
#endif #endif
#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 */ #endif /* __LXC_SYSCALL_NUMBERS_H */
...@@ -317,4 +317,11 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int ...@@ -317,4 +317,11 @@ static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int
} }
#endif #endif
#ifndef HAVE_SYS_PERSONALITY_H
static inline int personality(unsigned long persona)
{
return syscall(__NR_personality, persona);
}
#endif
#endif /* __LXC_SYSCALL_WRAPPER_H */ #endif /* __LXC_SYSCALL_WRAPPER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment