Commit 1e785858 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Remove __mips32__ and __mips64__ defines from base/macros.h.

BUG=882085

Change-Id: I07243c03a28a45f3d368269668b54eadc0b50e98
Reviewed-on: https://chromium-review.googlesource.com/c/1362223Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618650}
parent f61ad483
......@@ -12,16 +12,6 @@
#include <stddef.h> // For size_t.
// Distinguish mips32.
#if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__)
#define __mips32__
#endif
// Distinguish mips64.
#if defined(__mips__) && (_MIPS_SIM == _ABI64) && !defined(__mips64__)
#define __mips64__
#endif
// Put this in the declarations for a class to be uncopyable.
#define DISALLOW_COPY(TypeName) \
TypeName(const TypeName&) = delete
......
......@@ -5,6 +5,8 @@
#ifndef SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_
#define SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_
#include "build/build_config.h"
#if defined(__x86_64__)
#define MIN_SYSCALL 0u
......@@ -33,14 +35,14 @@
#define MIN_GHOST_SYSCALL (MIN_PRIVATE_SYSCALL + 0xfff0u)
#define MAX_SYSCALL (MIN_GHOST_SYSCALL + 4u)
#elif defined(__mips32__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)
#include <asm/unistd.h> // for __NR_O32_Linux and __NR_Linux_syscalls
#define MIN_SYSCALL __NR_O32_Linux
#define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + __NR_Linux_syscalls)
#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
#elif defined(__mips64__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)
#include <asm/unistd.h> // for __NR_64_Linux and __NR_64_Linux_syscalls
#define MIN_SYSCALL __NR_64_Linux
......
......@@ -19,6 +19,7 @@
#endif
#endif
#include "build/build_config.h"
#include "sandbox/linux/system_headers/linux_seccomp.h" // For AUDIT_ARCH_*
// Impose some reasonable maximum BPF program size. Realistically, the
......@@ -190,7 +191,7 @@ typedef user_regs regs_struct;
#define SECCOMP_PT_PARM5(_regs) (_regs).REG_r4
#define SECCOMP_PT_PARM6(_regs) (_regs).REG_r5
#elif defined(__mips32__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)
#define SECCOMP_ARCH AUDIT_ARCH_MIPSEL
#define SYSCALL_EIGHT_ARGS
// MIPS sigcontext_t is different from i386/x86_64 and ARM.
......@@ -244,7 +245,7 @@ struct regs_struct {
#define SECCOMP_PT_PARM3(_regs) (_regs).REG_a2
#define SECCOMP_PT_PARM4(_regs) (_regs).REG_a3
#elif defined(__mips64__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)
#define SECCOMP_ARCH AUDIT_ARCH_MIPSEL64
#define SYSCALL_EIGHT_ARGS
// MIPS sigcontext_t is different from i386/x86_64 and ARM.
......
......@@ -8,16 +8,17 @@
#include "base/logging.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/linux_syscall_ranges.h"
namespace sandbox {
namespace {
#if defined(__mips32__)
#if defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)
// This is true for Mips O32 ABI.
static_assert(MIN_SYSCALL == __NR_Linux, "min syscall number should be 4000");
#elif defined(__mips64__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)
// This is true for MIPS N64 ABI.
static_assert(MIN_SYSCALL == __NR_Linux, "min syscall number should be 5000");
#else
......
......@@ -86,7 +86,8 @@ bool IsBaselinePolicyWatched(int sysno) {
SyscallSets::IsNuma(sysno) ||
SyscallSets::IsPrctl(sysno) ||
SyscallSets::IsProcessGroupOrSession(sysno) ||
#if defined(__i386__) || defined(__mips32__)
#if defined(__i386__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
SyscallSets::IsSocketCall(sysno) ||
#endif
#if defined(__arm__)
......@@ -147,7 +148,8 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
if (sysno == __NR_fcntl)
return RestrictFcntlCommands();
#if defined(__i386__) || defined(__arm__) || defined(__mips32__)
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
if (sysno == __NR_fcntl64)
return RestrictFcntlCommands();
#endif
......@@ -193,7 +195,8 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
return RestrictMmapFlags();
#endif
#if defined(__i386__) || defined(__arm__) || defined(__mips32__)
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
if (sysno == __NR_mmap2)
return RestrictMmapFlags();
#endif
......@@ -244,7 +247,8 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
return Error(EPERM);
}
#if defined(__i386__) || defined(__mips32__)
#if defined(__i386__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
if (SyscallSets::IsSocketCall(sysno))
return RestrictSocketcallCommand();
#endif
......
......@@ -76,13 +76,15 @@ ResultExpr BaselinePolicyAndroid::EvaluateSyscall(int sysno) const {
case __NR_flock:
case __NR_fsync:
case __NR_ftruncate:
#if defined(__i386__) || defined(__arm__) || defined(__mips32__)
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
case __NR_ftruncate64:
#endif
#if defined(__x86_64__) || defined(__aarch64__)
case __NR_newfstatat:
case __NR_fstatfs:
#elif defined(__i386__) || defined(__arm__) || defined(__mips32__)
#elif defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
case __NR_fstatat64:
case __NR_fstatfs64:
#endif
......
......@@ -99,7 +99,7 @@ void PrintSyscallError(uint32_t sysno) {
sysno_base10[i] = '0' + mod;
}
#if defined(__mips32__)
#if defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)
static const char kSeccompErrorPrefix[] = __FILE__
":**CRASHING**:" SECCOMP_MESSAGE_COMMON_CONTENT " in syscall 4000 + ";
#else
......
......@@ -42,7 +42,8 @@ class SANDBOX_EXPORT SyscallSets {
static bool IsAllowedGetOrModifySocket(int sysno);
static bool IsDeniedGetOrModifySocket(int sysno);
#if defined(__i386__) || defined(__mips32__)
#if defined(__i386__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
// Big multiplexing system call for sockets.
static bool IsSocketCall(int sysno);
#endif
......@@ -71,21 +72,22 @@ class SANDBOX_EXPORT SyscallSets {
static bool IsAsyncIo(int sysno);
static bool IsKeyManagement(int sysno);
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
defined(__mips64__)
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
static bool IsSystemVSemaphores(int sysno);
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
defined(__mips64__)
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
// These give a lot of ambient authority and bypass the setuid sandbox.
static bool IsSystemVSharedMemory(int sysno);
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
defined(__mips64__)
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
static bool IsSystemVMessageQueue(int sysno);
#endif
#if defined(__i386__) || defined(__mips32__)
#if defined(__i386__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
// Big system V multiplexing system call.
static bool IsSystemVIpc(int sysno);
#endif
......
......@@ -8,6 +8,7 @@
#include <stdint.h>
#include "base/logging.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/seccomp_macros.h"
namespace sandbox {
......@@ -188,7 +189,7 @@ asm(// We need to be able to tell the kernel exactly where we made a
".fnend\n"
#endif
"9:.size SyscallAsm, 9b-SyscallAsm\n"
#elif defined(__mips32__)
#elif (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
".text\n"
".option pic2\n"
".align 4\n"
......@@ -240,7 +241,7 @@ asm(// We need to be able to tell the kernel exactly where we made a
".set pop\n"
".end SyscallAsm\n"
".size SyscallAsm,.-SyscallAsm\n"
#elif defined(__mips64__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)
".text\n"
".option pic2\n"
".global SyscallAsm\n"
......
......@@ -156,7 +156,8 @@ bool BrokerProcess::IsSyscallAllowed(int sysno) const {
#endif
return !fast_check_in_client_ || allowed_command_set_.test(COMMAND_STAT);
#if defined(__i386__) || defined(__arm__) || defined(__mips32__)
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
case __NR_stat64:
case __NR_lstat64:
// For security purposes, map stat64 to COMMAND_STAT permission. The
......
......@@ -7,6 +7,8 @@
#include <stdint.h>
#include "build/build_config.h"
// NOTE: On some toolchains, signal related ABI is incompatible with Linux's
// (not undefined, but defined different values and in different memory
// layouts). So, fill the gap here.
......@@ -111,14 +113,14 @@ typedef siginfo_t LinuxSigInfo;
#endif // !defined(__native_client_nonsfi__)
// struct sigset_t is different size in PNaCl from the Linux's.
#if defined(__mips32__)
#if (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
#if !defined(_NSIG_WORDS)
#define _NSIG_WORDS 4
#endif
struct LinuxSigSet {
unsigned long sig[_NSIG_WORDS];
};
#elif defined(__mips64__)
#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)
#if !defined(_NSIG_WORDS)
#define _NSIG_WORDS 2
#endif
......
......@@ -9,6 +9,8 @@
#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
#define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
#include "build/build_config.h"
#if defined(__x86_64__)
#include "sandbox/linux/system_headers/x86_64_linux_syscalls.h"
#endif
......@@ -21,11 +23,11 @@
#include "sandbox/linux/system_headers/arm_linux_syscalls.h"
#endif
#if defined(__mips32__)
#if (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
#include "sandbox/linux/system_headers/mips_linux_syscalls.h"
#endif
#if defined(__mips64__)
#if defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)
#include "sandbox/linux/system_headers/mips64_linux_syscalls.h"
#endif
......
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