nfqws,tpws: fix seccomp on mips64

This commit is contained in:
bol-van 2024-09-14 21:00:15 +03:00
parent d014ffe0ba
commit 482ea8d4c0
2 changed files with 61 additions and 6 deletions

View File

@ -19,39 +19,67 @@ bool dropcaps(void);
#define syscall_arg(x) (offsetof(struct seccomp_data, args[x])) #define syscall_arg(x) (offsetof(struct seccomp_data, args[x]))
#if defined(__aarch64__) #if defined(__aarch64__)
# define REG_SYSCALL regs.regs[8] # define REG_SYSCALL regs.regs[8]
# define ARCH_NR AUDIT_ARCH_AARCH64 # define ARCH_NR AUDIT_ARCH_AARCH64
#elif defined(__amd64__) #elif defined(__amd64__)
# define REG_SYSCALL REG_RAX # define REG_SYSCALL REG_RAX
# define ARCH_NR AUDIT_ARCH_X86_64 # define ARCH_NR AUDIT_ARCH_X86_64
#elif defined(__arm__) && (defined(__ARM_EABI__) || defined(__thumb__)) #elif defined(__arm__) && (defined(__ARM_EABI__) || defined(__thumb__))
# define REG_SYSCALL regs.uregs[7] # define REG_SYSCALL regs.uregs[7]
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
# define ARCH_NR AUDIT_ARCH_ARM # define ARCH_NR AUDIT_ARCH_ARM
# else # else
# define ARCH_NR AUDIT_ARCH_ARMEB # define ARCH_NR AUDIT_ARCH_ARMEB
# endif # endif
#elif defined(__i386__) #elif defined(__i386__)
# define REG_SYSCALL REG_EAX # define REG_SYSCALL REG_EAX
# define ARCH_NR AUDIT_ARCH_I386 # define ARCH_NR AUDIT_ARCH_I386
#elif defined(__mips__) #elif defined(__mips__)
# define REG_SYSCALL regs[2] # define REG_SYSCALL regs[2]
#if _MIPS_SIM == _MIPS_SIM_ABI32
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
# define ARCH_NR AUDIT_ARCH_MIPSEL # define ARCH_NR AUDIT_ARCH_MIPSEL
# else # else
# define ARCH_NR AUDIT_ARCH_MIPS # define ARCH_NR AUDIT_ARCH_MIPS
# endif # endif
#elif defined(__PPC__) #elif _MIPS_SIM == _MIPS_SIM_ABI64
# define REG_SYSCALL regs.gpr[0] # if __BYTE_ORDER == __LITTLE_ENDIAN
# define ARCH_NR AUDIT_ARCH_PPC # define ARCH_NR AUDIT_ARCH_MIPSEL64
# else
# define ARCH_NR AUDIT_ARCH_MIPS64
# endif
#else #else
# warning "Platform does not support seccomp filter yet" # warning "Platform does not support seccomp filter yet"
# define REG_SYSCALL 0 # define REG_SYSCALL 0
# define ARCH_NR 0 # define ARCH_NR 0
#endif #endif
#elif defined(__PPC__)
# define REG_SYSCALL regs.gpr[0]
# define ARCH_NR AUDIT_ARCH_PPC
#else
# warning "Platform does not support seccomp filter yet"
# define REG_SYSCALL 0
# define ARCH_NR 0
#endif #endif
#endif
#ifndef __CYGWIN__ #ifndef __CYGWIN__
bool sec_harden(void); bool sec_harden(void);
bool can_drop_root(void); bool can_drop_root(void);

View File

@ -21,37 +21,64 @@ bool dropcaps(void);
#define syscall_arg(x) (offsetof(struct seccomp_data, args[x])) #define syscall_arg(x) (offsetof(struct seccomp_data, args[x]))
#if defined(__aarch64__) #if defined(__aarch64__)
# define REG_SYSCALL regs.regs[8] # define REG_SYSCALL regs.regs[8]
# define ARCH_NR AUDIT_ARCH_AARCH64 # define ARCH_NR AUDIT_ARCH_AARCH64
#elif defined(__amd64__) #elif defined(__amd64__)
# define REG_SYSCALL REG_RAX # define REG_SYSCALL REG_RAX
# define ARCH_NR AUDIT_ARCH_X86_64 # define ARCH_NR AUDIT_ARCH_X86_64
#elif defined(__arm__) && (defined(__ARM_EABI__) || defined(__thumb__)) #elif defined(__arm__) && (defined(__ARM_EABI__) || defined(__thumb__))
# define REG_SYSCALL regs.uregs[7] # define REG_SYSCALL regs.uregs[7]
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
# define ARCH_NR AUDIT_ARCH_ARM # define ARCH_NR AUDIT_ARCH_ARM
# else # else
# define ARCH_NR AUDIT_ARCH_ARMEB # define ARCH_NR AUDIT_ARCH_ARMEB
# endif # endif
#elif defined(__i386__) #elif defined(__i386__)
# define REG_SYSCALL REG_EAX # define REG_SYSCALL REG_EAX
# define ARCH_NR AUDIT_ARCH_I386 # define ARCH_NR AUDIT_ARCH_I386
#elif defined(__mips__) #elif defined(__mips__)
# define REG_SYSCALL regs[2] # define REG_SYSCALL regs[2]
#if _MIPS_SIM == _MIPS_SIM_ABI32
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
# define ARCH_NR AUDIT_ARCH_MIPSEL # define ARCH_NR AUDIT_ARCH_MIPSEL
# else # else
# define ARCH_NR AUDIT_ARCH_MIPS # define ARCH_NR AUDIT_ARCH_MIPS
# endif # endif
#elif defined(__PPC__) #elif _MIPS_SIM == _MIPS_SIM_ABI64
# define REG_SYSCALL regs.gpr[0] # if __BYTE_ORDER == __LITTLE_ENDIAN
# define ARCH_NR AUDIT_ARCH_PPC # define ARCH_NR AUDIT_ARCH_MIPSEL64
# else
# define ARCH_NR AUDIT_ARCH_MIPS64
# endif
#else #else
# warning "Platform does not support seccomp filter yet" # warning "Platform does not support seccomp filter yet"
# define REG_SYSCALL 0 # define REG_SYSCALL 0
# define ARCH_NR 0 # define ARCH_NR 0
#endif #endif
#elif defined(__PPC__)
# define REG_SYSCALL regs.gpr[0]
# define ARCH_NR AUDIT_ARCH_PPC
#else
# warning "Platform does not support seccomp filter yet"
# define REG_SYSCALL 0
# define ARCH_NR 0
#endif
#endif #endif
bool sec_harden(void); bool sec_harden(void);