1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 03:09:51 +03:00
aports/community/qt6-qtwebengine/qt6-6.9.0.loongarch64-sandbox.diff

2275 lines
69 KiB
Diff

diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/features.gni b/src/3rdparty/chromium/sandbox/features.gni
--- a/src/3rdparty/chromium/sandbox/features.gni 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/features.gni 2000-01-01 00:00:00.000000000 +0800
@@ -9,7 +9,7 @@
use_seccomp_bpf = (is_linux || is_chromeos || is_android) &&
(current_cpu == "x86" || current_cpu == "x64" ||
current_cpu == "arm" || current_cpu == "arm64" ||
- current_cpu == "mipsel" || current_cpu == "mips64el")
+ current_cpu == "mipsel" || current_cpu == "mips64el" || current_cpu == "loong64")
# SSBD (Speculative Store Bypass Disable) is a mitigation of Spectre Variant 4.
# As Spectre Variant 4 can be mitigated by site isolation, opt-out SSBD on site
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
--- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h 2000-01-01 00:00:00.000000000 +0800
@@ -56,6 +56,13 @@
#define MAX_PUBLIC_SYSCALL __NR_syscalls
#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
+#elif defined(__loongarch__)
+
+#include <asm-generic/unistd.h>
+#define MIN_SYSCALL 0u
+#define MAX_PUBLIC_SYSCALL __NR_syscalls
+#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
+
#else
#error "Unsupported architecture"
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h
--- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h 2000-01-01 00:00:00.000000000 +0800
@@ -343,6 +343,47 @@ struct regs_struct {
#define SECCOMP_PT_PARM4(_regs) (_regs).regs[3]
#define SECCOMP_PT_PARM5(_regs) (_regs).regs[4]
#define SECCOMP_PT_PARM6(_regs) (_regs).regs[5]
+
+#elif defined(__loongarch__)
+struct regs_struct {
+ unsigned long long regs[32];
+ unsigned long long pc;
+};
+
+#define SECCOMP_ARCH AUDIT_ARCH_LOONGARCH64
+
+#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg])
+
+#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 4)
+#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 11)
+#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__pc
+#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 4)
+#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 5)
+#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 6)
+#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 7)
+#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, 8)
+#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, 9)
+
+#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr))
+#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch))
+#define SECCOMP_IP_MSB_IDX \
+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4)
+#define SECCOMP_IP_LSB_IDX \
+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0)
+#define SECCOMP_ARG_MSB_IDX(nr) \
+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4)
+#define SECCOMP_ARG_LSB_IDX(nr) \
+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0)
+
+#define SECCOMP_PT_RESULT(_regs) (_regs).regs[4]
+#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[11]
+#define SECCOMP_PT_IP(_regs) (_regs).pc
+#define SECCOMP_PT_PARM1(_regs) (_regs).regs[4]
+#define SECCOMP_PT_PARM2(_regs) (_regs).regs[5]
+#define SECCOMP_PT_PARM3(_regs) (_regs).regs[6]
+#define SECCOMP_PT_PARM4(_regs) (_regs).regs[7]
+#define SECCOMP_PT_PARM5(_regs) (_regs).regs[8]
+#define SECCOMP_PT_PARM6(_regs) (_regs).regs[9]
#else
#error Unsupported target platform
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc 2000-01-01 00:00:00.000000000 +0800
@@ -193,7 +193,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
return RestrictFcntlCommands();
#endif
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
// fork() is never used as a system call (clone() is used instead), but we
// have seen it in fallback code on Android.
if (sysno == __NR_fork) {
@@ -255,7 +255,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
}
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
if (sysno == __NR_mmap)
return RestrictMmapFlags();
#endif
@@ -276,7 +276,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
return RestrictPrctl();
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
if (sysno == __NR_socketpair) {
// Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
static_assert(AF_UNIX == PF_UNIX,
@@ -302,6 +302,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
return Allow();
}
+#if !defined(__loongarch__)
// The fstatat syscalls are file system syscalls, which will be denied below
// with fs_denied_errno. However some allowed fstat syscalls are rewritten by
// libc implementations to fstatat syscalls, and we need to rewrite them back.
@@ -319,6 +320,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
return If(mask == STATX_BASIC_STATS, Error(ENOSYS))
.Else(Error(fs_denied_errno));
}
+#endif
if (SyscallSets::IsFileSystem(sysno) ||
SyscallSets::IsCurrentDirectory(sysno)) {
@@ -366,7 +368,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
// Allow creating pipes, but don't allow weird flags to pipe2().
// O_NOTIFICATION_PIPE (== O_EXCL) can be used to create
// "notification pipes", which are rarely used.
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
if (sysno == __NR_pipe) {
return Allow();
}
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc
--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc 2000-01-01 00:00:00.000000000 +0800
@@ -359,6 +359,7 @@ intptr_t SIGSYSSchedHandler(const struct
intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args,
void* fs_denied_errno) {
+#if !defined(__loongarch__)
if (args.nr == __NR_fstatat_default) {
if (*reinterpret_cast<const char*>(args.args[1]) == '\0' &&
args.args[3] == static_cast<uint64_t>(AT_EMPTY_PATH)) {
@@ -367,6 +368,7 @@ intptr_t SIGSYSFstatatHandler(const stru
}
return -reinterpret_cast<intptr_t>(fs_denied_errno);
}
+#endif
CrashSIGSYS_Handler(args, fs_denied_errno);
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc 2000-01-01 00:00:00.000000000 +0800
@@ -37,7 +37,7 @@
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
!defined(__arm__) && !defined(__aarch64__) && \
- !defined(PTRACE_GET_THREAD_AREA)
+ !defined(PTRACE_GET_THREAD_AREA) && !defined(__loongarch__)
// Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance
// the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA.
// asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't
@@ -347,7 +347,7 @@ ResultExpr RestrictFutex() {
.Cases({FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE, FUTEX_CMP_REQUEUE,
#if BUILDFLAG(ENABLE_MUTEX_PRIORITY_INHERITANCE)
// Enable priority-inheritance operations.
- FUTEX_LOCK_PI, FUTEX_UNLOCK_PI, FUTEX_TRYLOCK_PI,
+ FUTEX_LOCK_PI, FUTEX_LOCK_PI2, FUTEX_UNLOCK_PI, FUTEX_TRYLOCK_PI,
FUTEX_WAIT_REQUEUE_PI, FUTEX_CMP_REQUEUE_PI,
#endif // BUILDFLAG(ENABLE_MUTEX_PRIORITY_INHERITANCE)
FUTEX_WAKE_OP, FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET},
@@ -464,8 +464,11 @@ ResultExpr RestrictPtrace() {
return Switch(request)
.Cases({
#if !defined(__aarch64__)
- PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GET_THREAD_AREA,
+ PTRACE_GETREGS, PTRACE_GETFPREGS,
PTRACE_GETREGSET,
+#if !defined(__loongarch__)
+ PTRACE_GET_THREAD_AREA,
+#endif
#endif
#if defined(__arm__)
PTRACE_GETVFPREGS,
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc 2000-01-01 00:00:00.000000000 +0800
@@ -103,7 +103,7 @@ bool SyscallSets::IsUmask(int sysno) {
// Both EPERM and ENOENT are valid errno unless otherwise noted in comment.
bool SyscallSets::IsFileSystem(int sysno) {
switch (sysno) {
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_access: // EPERM not a valid errno.
case __NR_chmod:
case __NR_chown:
@@ -161,7 +161,9 @@ bool SyscallSets::IsFileSystem(int sysno
#endif
case __NR_openat:
case __NR_readlinkat:
+#if !defined(__loongarch__)
case __NR_renameat:
+#endif
case __NR_renameat2:
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
@@ -211,7 +213,11 @@ bool SyscallSets::IsTruncate(int sysno)
bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) {
switch (sysno) {
+#if !defined(__loongarch__)
case __NR_fstat:
+#else
+ case __NR_statx:
+#endif
case __NR_ftruncate:
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
@@ -241,7 +247,7 @@ bool SyscallSets::IsAllowedFileSystemAcc
case __NR_oldfstat:
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_sync_file_range: // EPERM not a valid errno.
#elif defined(__arm__)
case __NR_arm_sync_file_range: // EPERM not a valid errno.
@@ -260,7 +266,7 @@ bool SyscallSets::IsDeniedFileSystemAcce
#if defined(__i386__) || defined(__arm__)
case __NR_fchown32:
#endif
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_getdents: // EPERM not a valid errno.
#endif
case __NR_getdents64: // EPERM not a valid errno.
@@ -339,7 +345,7 @@ bool SyscallSets::IsProcessPrivilegeChan
bool SyscallSets::IsProcessGroupOrSession(int sysno) {
switch (sysno) {
case __NR_setpgid:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_getpgrp:
#endif
case __NR_setsid:
@@ -373,7 +379,7 @@ bool SyscallSets::IsAllowedSignalHandlin
case __NR_rt_sigqueueinfo:
case __NR_rt_sigsuspend:
case __NR_rt_tgsigqueueinfo:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_signalfd:
#endif
case __NR_signalfd4:
@@ -397,12 +403,12 @@ bool SyscallSets::IsAllowedOperationOnFd
switch (sysno) {
case __NR_close:
case __NR_dup:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_dup2:
#endif
case __NR_dup3:
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_shutdown:
#endif
return true;
@@ -441,7 +447,7 @@ bool SyscallSets::IsAllowedProcessStartO
return true;
case __NR_clone: // Should be parameter-restricted.
case __NR_setns: // Privileged.
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_fork:
#endif
#if defined(__i386__) || defined(__x86_64__)
@@ -452,7 +458,7 @@ bool SyscallSets::IsAllowedProcessStartO
#endif
case __NR_set_tid_address:
case __NR_unshare:
-#if !defined(__mips__) && !defined(__aarch64__)
+#if !defined(__mips__) && !defined(__aarch64__) && !defined(__loongarch__)
case __NR_vfork:
#endif
default:
@@ -477,7 +483,7 @@ bool SyscallSets::IsAllowedFutex(int sys
bool SyscallSets::IsAllowedEpoll(int sysno) {
switch (sysno) {
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_epoll_create:
case __NR_epoll_wait:
#endif
@@ -499,7 +505,7 @@ bool SyscallSets::IsAllowedEpoll(int sys
bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) {
switch (sysno) {
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_accept:
case __NR_accept4:
case __NR_bind:
@@ -554,7 +560,7 @@ bool SyscallSets::IsAllowedAddressSpaceA
case __NR_mincore:
case __NR_mlockall:
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_mmap:
#endif
#if defined(__i386__) || defined(__arm__) || \
@@ -587,7 +593,7 @@ bool SyscallSets::IsAllowedGeneralIo(int
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
case __NR__llseek:
#endif
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_poll:
#endif
case __NR_ppoll:
@@ -608,7 +614,7 @@ bool SyscallSets::IsAllowedGeneralIo(int
case __NR_recv:
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_recvfrom: // Could specify source.
case __NR_recvmsg: // Could specify source.
#endif
@@ -623,7 +629,7 @@ bool SyscallSets::IsAllowedGeneralIo(int
case __NR_send:
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_sendmsg: // Could specify destination.
case __NR_sendto: // Could specify destination.
#endif
@@ -672,7 +678,7 @@ bool SyscallSets::IsSeccomp(int sysno) {
bool SyscallSets::IsAllowedBasicScheduler(int sysno) {
switch (sysno) {
case __NR_sched_yield:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_pause:
#endif
case __NR_nanosleep:
@@ -756,7 +762,7 @@ bool SyscallSets::IsNuma(int sysno) {
case __NR_getcpu:
case __NR_mbind:
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
case __NR_migrate_pages:
#endif
case __NR_move_pages:
@@ -804,7 +810,9 @@ bool SyscallSets::IsGlobalProcessEnviron
case __NR_getrusage:
case __NR_personality: // Can change its personality as well.
case __NR_prlimit64: // Like setrlimit / getrlimit.
+#if !defined(__loongarch__)
case __NR_setrlimit:
+#endif
case __NR_times:
return true;
default:
@@ -826,7 +834,7 @@ bool SyscallSets::IsDebug(int sysno) {
bool SyscallSets::IsGlobalSystemStatus(int sysno) {
switch (sysno) {
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR__sysctl:
case __NR_sysfs:
#endif
@@ -844,7 +852,7 @@ bool SyscallSets::IsGlobalSystemStatus(i
bool SyscallSets::IsEventFd(int sysno) {
switch (sysno) {
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_eventfd:
#endif
case __NR_eventfd2:
@@ -896,7 +904,7 @@ bool SyscallSets::IsKeyManagement(int sy
}
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
bool SyscallSets::IsSystemVSemaphores(int sysno) {
switch (sysno) {
case __NR_semctl:
@@ -916,7 +924,7 @@ bool SyscallSets::IsSystemVSemaphores(in
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
// These give a lot of ambient authority and bypass the setuid sandbox.
bool SyscallSets::IsSystemVSharedMemory(int sysno) {
switch (sysno) {
@@ -932,7 +940,7 @@ bool SyscallSets::IsSystemVSharedMemory(
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
bool SyscallSets::IsSystemVMessageQueue(int sysno) {
switch (sysno) {
case __NR_msgctl:
@@ -963,7 +971,7 @@ bool SyscallSets::IsSystemVIpc(int sysno
bool SyscallSets::IsAnySystemV(int sysno) {
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) ||
IsSystemVSharedMemory(sysno);
#elif defined(__i386__) || \
@@ -1000,7 +1008,7 @@ bool SyscallSets::IsAdvancedScheduler(in
bool SyscallSets::IsInotify(int sysno) {
switch (sysno) {
case __NR_inotify_add_watch:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_inotify_init:
#endif
case __NR_inotify_init1:
@@ -1135,7 +1143,7 @@ bool SyscallSets::IsMisc(int sysno) {
#if defined(__x86_64__)
case __NR_tuxcall:
#endif
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_vserver:
#endif
return true;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h 2000-01-01 00:00:00.000000000 +0800
@@ -79,18 +79,18 @@ class SANDBOX_EXPORT SyscallSets {
static bool IsAsyncIo(int sysno);
static bool IsKeyManagement(int sysno);
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
static bool IsSystemVSemaphores(int sysno);
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
// 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(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__loongarch__)
static bool IsSystemVMessageQueue(int sysno);
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc
--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc 2000-01-01 00:00:00.000000000 +0800
@@ -23,7 +23,7 @@ namespace sandbox {
namespace {
#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
- defined(ARCH_CPU_MIPS_FAMILY)
+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY)
// Number that's not currently used by any Linux kernel ABIs.
const int kInvalidSyscallNumber = 0x351d3;
#else
@@ -313,6 +313,27 @@ asm(// We need to be able to tell the ke
"2:ret\n"
".cfi_endproc\n"
".size SyscallAsm, .-SyscallAsm\n"
+#elif defined(__loongarch__)
+ ".text\n"
+ ".align 2\n"
+ ".type SyscallAsm, %function\n"
+ "SyscallAsm:\n"
+ ".cfi_startproc\n"
+ "bge $a0, $zero, 1f\n"
+ "la.pcrel $a0, 2f\n"
+ "b 2f\n"
+ "1:ld.d $a5, $a6, 40\n"
+ "ld.d $a4, $a6, 32\n"
+ "ld.d $a3, $a6, 24\n"
+ "ld.d $a2, $a6, 16\n"
+ "ld.d $a1, $a6, 8\n"
+ "move $a7, $a0\n"
+ "ld.d $a0, $a6, 0\n"
+ // Enter the kernel
+ "syscall 0\n"
+ "2:ret\n"
+ ".cfi_endproc\n"
+ ".size SyscallAsm, .-SyscallAsm\n"
#endif
); // asm
@@ -430,6 +451,18 @@ intptr_t Syscall::Call(int nr,
ret = inout;
}
+#elif defined(__loongarch__)
+ intptr_t ret;
+ {
+ register intptr_t inout __asm__("$r4") = nr;
+ register const intptr_t* data __asm__("$r10") = args;
+ asm volatile("bl SyscallAsm\n"
+ : "=r"(inout)
+ : "0"(inout), "r"(data)
+ : "memory", "$r5", "$r6", "$r7", "$r8", "$r9", "$r11", "$r1");
+ ret = inout;
+ }
+
#else
#error "Unimplemented architecture"
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/services/credentials.cc b/src/3rdparty/chromium/sandbox/linux/services/credentials.cc
--- a/src/3rdparty/chromium/sandbox/linux/services/credentials.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/services/credentials.cc 2000-01-01 00:00:00.000000000 +0800
@@ -87,7 +87,7 @@ bool ChrootToSafeEmptyDir() {
alignas(16) char stack_buf[PTHREAD_STACK_MIN_CONST];
#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
- defined(ARCH_CPU_MIPS_FAMILY)
+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY)
// The stack grows downward.
void* stack = stack_buf + sizeof(stack_buf);
#else
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc b/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc
--- a/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc 2000-01-01 00:00:00.000000000 +0800
@@ -5,6 +5,7 @@
#include "sandbox/linux/services/syscall_wrappers.h"
#include <fcntl.h>
+#include <linux/stat.h>
#include <pthread.h>
#include <sched.h>
#include <setjmp.h>
@@ -58,7 +59,7 @@ long sys_clone(unsigned long flags,
if (ctid) MSAN_UNPOISON(ctid, sizeof(*ctid));
// See kernel/fork.c in Linux. There is different ordering of sys_clone
// parameters depending on CONFIG_CLONE_BACKWARDS* configuration options.
-#if defined(ARCH_CPU_X86_64)
+#if defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_LOONGARCH_FAMILY)
return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls);
#elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \
defined(ARCH_CPU_MIPS_FAMILY)
@@ -163,9 +164,53 @@ int sys_sigaction(int signum,
return sigaction(signum, act, oldact);
}
+// follow glibc __cp_stat64_statx
+void statx_to_stat(struct kernel_stat* to, struct kernel_statx* from) {
+ memset(to, 0, sizeof(struct kernel_stat));
+ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) |
+ ((from->stx_dev_minor & ~0xff) << 12));
+ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) |
+ ((from->stx_rdev_minor & ~0xff) << 12));
+ to->st_ino = from->stx_ino;
+ to->st_mode = from->stx_mode;
+ to->st_nlink = from->stx_nlink;
+ to->st_uid = from->stx_uid;
+ to->st_gid = from->stx_gid;
+ to->st_atime_ = from->stx_atime.tv_sec;
+ to->st_atime_nsec_ = from->stx_atime.tv_nsec;
+ to->st_mtime_ = from->stx_mtime.tv_sec;
+ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec;
+ to->st_ctime_ = from->stx_ctime.tv_sec;
+ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec;
+ to->st_size = from->stx_size;
+ to->st_blocks = from->stx_blocks;
+ to->st_blksize = from->stx_blksize;
+}
+
+int sys_statx(int fd,
+ const char* path,
+ int flags,
+ unsigned int mask,
+ struct kernel_statx* statx_buf) {
+#if defined(__NR_statx)
+ int res = syscall(__NR_statx, fd, path, flags, mask, statx_buf);
+ if (res == 0)
+ MSAN_UNPOISON(statx_buf, sizeof(*statx_buf));
+ return res;
+#else // defined(__NR_statx)
+ RAW_CHECK(false);
+ return -ENOSYS;
+#endif
+}
+
int sys_stat(const char* path, struct kernel_stat* stat_buf) {
int res;
-#if !defined(__NR_stat)
+#if defined(__NR_statx)
+ kernel_statx statx_buf;
+ res = syscall(__NR_statx, AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &statx_buf);
+ if (res == 0)
+ statx_to_stat(stat_buf, &statx_buf);
+#elif !defined(__NR_stat)
res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, 0);
#else
res = syscall(__NR_stat, path, stat_buf);
@@ -177,7 +222,12 @@ int sys_stat(const char* path, struct ke
int sys_lstat(const char* path, struct kernel_stat* stat_buf) {
int res;
-#if !defined(__NR_lstat)
+#if defined(__NR_statx)
+ kernel_statx statx_buf;
+ res = syscall(__NR_statx, AT_FDCWD, path, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &statx_buf);
+ if (res == 0)
+ statx_to_stat(stat_buf, &statx_buf);
+#elif !defined(__NR_lstat)
res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW);
#else
res = syscall(__NR_lstat, path, stat_buf);
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.h b/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.h
--- a/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.h 2000-01-01 00:00:00.000000000 +0800
@@ -19,6 +19,7 @@ struct cap_hdr;
struct cap_data;
struct kernel_stat;
struct kernel_stat64;
+struct kernel_statx;
struct landlock_ruleset_attr;
namespace sandbox {
@@ -92,6 +93,7 @@ SANDBOX_EXPORT int sys_sigaction(int sig
// architectures, with the same capabilities as stat() and lstat().
SANDBOX_EXPORT int sys_stat(const char* path, struct kernel_stat* stat_buf);
SANDBOX_EXPORT int sys_lstat(const char* path, struct kernel_stat* stat_buf);
+SANDBOX_EXPORT int sys_statx(int fd, const char* path, int flags, unsigned int mask, struct kernel_statx* statx_buf);
// Takes care of unpoisoning |stat_buf| for MSAN. Check-fails if fstatat64() is
// not a supported syscall on the current platform.
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.cc b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.cc
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.cc 2000-01-01 00:00:00.000000000 +0800
@@ -198,6 +198,21 @@ int BrokerClient::Stat64(const char* pat
sizeof(*sb));
}
+int BrokerClient::Statx(const char* pathname,
+ bool follow_links,
+ struct kernel_statx* sb) const {
+ if (!pathname || !sb)
+ return -EFAULT;
+
+ if (fast_check_in_client_ &&
+ !CommandStatIsSafe(policy_->allowed_command_set,
+ *policy_->file_permissions, pathname)) {
+ return -policy_->file_permissions->denied_errno();
+ }
+ return StatFamilySyscall(COMMAND_STATX, pathname, follow_links, sb,
+ sizeof(*sb));
+}
+
int BrokerClient::Unlink(const char* path) const {
if (!path)
return -EFAULT;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.h b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.h
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_client.h 2000-01-01 00:00:00.000000000 +0800
@@ -67,6 +67,9 @@ class SANDBOX_EXPORT BrokerClient : publ
int Stat64(const char* pathname,
bool follow_links,
struct kernel_stat64* sb) const override;
+ int Statx(const char* pathname,
+ bool follow_links,
+ struct kernel_statx* sb) const override;
int Unlink(const char* unlink) const override;
int InotifyAddWatch(int fd,
const char* pathname,
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_command.h b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_command.h
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_command.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_command.h 2000-01-01 00:00:00.000000000 +0800
@@ -42,6 +42,7 @@ enum BrokerCommand {
COMMAND_RMDIR,
COMMAND_STAT,
COMMAND_STAT64,
+ COMMAND_STATX,
COMMAND_UNLINK,
COMMAND_INOTIFY_ADD_WATCH,
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_host.cc b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_host.cc
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_host.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_host.cc 2000-01-01 00:00:00.000000000 +0800
@@ -302,6 +302,21 @@ void BrokerHost::StatFileForIPC(BrokerCo
RAW_CHECK(reply->AddIntToMessage(0));
RAW_CHECK(
reply->AddDataToMessage(reinterpret_cast<char*>(&sb), sizeof(sb)));
+#elif defined(__loongarch__)
+ // handle COMMAND_STATX
+ DCHECK(command_type == COMMAND_STATX);
+ struct kernel_statx sb;
+
+ int sts = sandbox::sys_statx(AT_FDCWD, file_to_access,
+ follow_links ? 0 : AT_SYMLINK_NOFOLLOW,
+ STATX_BASIC_STATS, &sb);
+ if (sts < 0) {
+ RAW_CHECK(reply->AddIntToMessage(-errno));
+ return;
+ }
+ RAW_CHECK(reply->AddIntToMessage(0));
+ RAW_CHECK(
+ reply->AddDataToMessage(reinterpret_cast<char*>(&sb), sizeof(sb)));
#else // defined(__NR_fstatat64)
// We should not reach here on 64-bit systems, as the *stat*64() are only
// necessary on 32-bit.
@@ -441,7 +456,8 @@ bool BrokerHost::HandleRemoteCommand(Bro
break;
}
case COMMAND_STAT:
- case COMMAND_STAT64: {
+ case COMMAND_STAT64:
+ case COMMAND_STATX: {
const char* requested_filename;
if (!message->ReadString(&requested_filename)) {
return false;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc 2000-01-01 00:00:00.000000000 +0800
@@ -122,44 +122,46 @@ bool BrokerProcess::IsSyscallBrokerable(
// and are default disabled in Android. So, we should refuse to broker them
// to be consistent with the platform's restrictions.
switch (sysno) {
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_access:
#endif
case __NR_faccessat:
case __NR_faccessat2:
return !fast_check || policy_->allowed_command_set.test(COMMAND_ACCESS);
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_mkdir:
#endif
case __NR_mkdirat:
return !fast_check || policy_->allowed_command_set.test(COMMAND_MKDIR);
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_open:
#endif
case __NR_openat:
return !fast_check || policy_->allowed_command_set.test(COMMAND_OPEN);
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_readlink:
#endif
case __NR_readlinkat:
return !fast_check || policy_->allowed_command_set.test(COMMAND_READLINK);
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_rename:
#endif
+#if !defined(__loongarch__)
case __NR_renameat:
+#endif
case __NR_renameat2:
return !fast_check || policy_->allowed_command_set.test(COMMAND_RENAME);
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_rmdir:
return !fast_check || policy_->allowed_command_set.test(COMMAND_RMDIR);
#endif
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_stat:
case __NR_lstat:
#endif
@@ -169,6 +171,9 @@ bool BrokerProcess::IsSyscallBrokerable(
#if defined(__NR_fstatat64)
case __NR_fstatat64:
#endif
+#if defined(__NR_statx)
+ case __NR_statx:
+#endif
#if defined(__x86_64__) || defined(__aarch64__)
case __NR_newfstatat:
#endif
@@ -184,7 +189,7 @@ bool BrokerProcess::IsSyscallBrokerable(
return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT);
#endif
-#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
+#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__loongarch__)
case __NR_unlink:
return !fast_check || policy_->allowed_command_set.test(COMMAND_UNLINK);
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.cc b/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.cc
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.cc 2000-01-01 00:00:00.000000000 +0800
@@ -29,6 +29,8 @@ int SyscallDispatcher::DefaultStatForTes
default_stat_struct* sb) {
#if defined(__NR_fstatat64)
return Stat64(pathname, follow_links, sb);
+#elif defined(__NR_statx)
+ return Statx(pathname, follow_links ? 0 : AT_SYMLINK_NOFOLLOW, sb);
#elif defined(__NR_newfstatat)
return Stat(pathname, follow_links, sb);
#endif
@@ -174,6 +176,19 @@ int SyscallDispatcher::DispatchSyscall(c
return Stat64(reinterpret_cast<const char*>(args.args[0]), true,
reinterpret_cast<struct kernel_stat64*>(args.args[1]));
#endif
+#if defined(__NR_statx)
+ case __NR_statx:
+ // we have ensured that the statx does not have AT_EMPTY_PATH in HandleViaBroker()
+ // so this is stat/lstat instead of fstat
+ // see PerformStatat
+ if (static_cast<int>(args.args[0]) != AT_FDCWD) {
+ return -EPERM;
+ }
+
+ return Statx(reinterpret_cast<const char*>(args.args[1]),
+ !(static_cast<int>(args.args[2]) & AT_SYMLINK_NOFOLLOW),
+ reinterpret_cast<struct kernel_statx*>(args.args[4]));
+#endif
#if defined(__NR_lstat)
case __NR_lstat:
// See https://crbug.com/847096
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.h b/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.h
--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/syscall_dispatcher.h 2000-01-01 00:00:00.000000000 +0800
@@ -49,6 +49,9 @@ class SANDBOX_EXPORT SyscallDispatcher {
virtual int Stat64(const char* pathname,
bool follow_links,
struct kernel_stat64* sb) const = 0;
+ virtual int Statx(const char* pathname,
+ bool follow_links,
+ struct kernel_statx* sb) const = 0;
// Emulates unlink()/unlinkat().
virtual int Unlink(const char* unlink) const = 0;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h
--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h 2000-01-01 00:00:00.000000000 +0800
@@ -39,6 +39,10 @@
#define EM_AARCH64 183
#endif
+#ifndef EM_LOONGARCH64
+#define EM_LOONGARCH64 258
+#endif
+
#ifndef __AUDIT_ARCH_64BIT
#define __AUDIT_ARCH_64BIT 0x80000000
#endif
@@ -71,6 +75,10 @@
#define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
+#ifndef AUDIT_ARCH_LOONGARCH64
+#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
+#endif
+
// For prctl.h
#ifndef PR_SET_SECCOMP
#define PR_SET_SECCOMP 22
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h
--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h 2000-01-01 00:00:00.000000000 +0800
@@ -13,7 +13,7 @@
// (not undefined, but defined different values and in different memory
// layouts). So, fill the gap here.
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__loongarch__)
#define LINUX_SIGHUP 1
#define LINUX_SIGINT 2
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h
--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h 2000-01-01 00:00:00.000000000 +0800
@@ -150,7 +150,7 @@ struct kernel_stat {
int st_blocks;
int st_pad4[14];
};
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) || defined(__loongarch__)
struct kernel_stat {
unsigned long st_dev;
unsigned long st_ino;
@@ -175,6 +175,42 @@ struct kernel_stat {
};
#endif
+#if defined(__loongarch__)
+// from linux include/uapi/linux/stat.h
+struct kernel_statx_timestamp {
+ long tv_sec;
+ unsigned int tv_nsec;
+ int __reserved;
+};
+
+struct kernel_statx {
+ unsigned int stx_mask;
+ unsigned int stx_blksize;
+ unsigned long stx_attributes;
+ unsigned int stx_nlink;
+ unsigned int stx_uid;
+ unsigned int stx_gid;
+ unsigned short stx_mode;
+ unsigned short __spare0[1];
+ unsigned long stx_ino;
+ unsigned long stx_size;
+ unsigned long stx_blocks;
+ unsigned long stx_attributes_mask;
+ struct kernel_statx_timestamp stx_atime;
+ struct kernel_statx_timestamp stx_btime;
+ struct kernel_statx_timestamp stx_ctime;
+ struct kernel_statx_timestamp stx_mtime;
+ unsigned int stx_rdev_major;
+ unsigned int stx_rdev_minor;
+ unsigned int stx_dev_major;
+ unsigned int stx_dev_minor;
+ unsigned long stx_mnt_id;
+ unsigned int stx_dio_mem_align;
+ unsigned int stx_dio_offset_align;
+ unsigned long __spare3[12];
+};
+#endif
+
#if !defined(AT_EMPTY_PATH)
#define AT_EMPTY_PATH 0x1000
#endif
@@ -207,8 +243,14 @@ using default_stat_struct = struct kerne
#define __NR_fstatat_default __NR_newfstatat
#define __NR_fstat_default __NR_fstat
+#elif defined(__NR_statx)
+
+namespace sandbox {
+using default_stat_struct = struct kernel_statx;
+} // namespace sandbox
+
#else
-#error "one of fstatat64 and newfstatat must be defined"
+#error "one of fstatat64, newfstatat and statx must be defined"
#endif
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_STAT_H_
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h
--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h 2000-01-01 00:00:00.000000000 +0800
@@ -35,5 +35,9 @@
#include "sandbox/linux/system_headers/arm64_linux_syscalls.h"
#endif
+#if defined(__loongarch__)
+#include "sandbox/linux/system_headers/loong64_linux_syscalls.h"
+#endif
+
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/linux/system_headers/loong64_linux_syscalls.h b/src/3rdparty/chromium/sandbox/linux/system_headers/loong64_linux_syscalls.h
--- a/src/3rdparty/chromium/sandbox/linux/system_headers/loong64_linux_syscalls.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/loong64_linux_syscalls.h 2000-01-01 00:00:00.000000000 +0800
@@ -0,0 +1,1194 @@
+// Copyright 2023 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LOONG64_LINUX_SYSCALLS_H_
+#define SANDBOX_LINUX_SYSTEM_HEADERS_LOONG64_LINUX_SYSCALLS_H_
+
+#include <asm-generic/unistd.h>
+
+#if !defined(__NR_io_setup)
+#define __NR_io_setup 0
+#endif
+
+#if !defined(__NR_io_destroy)
+#define __NR_io_destroy 1
+#endif
+
+#if !defined(__NR_io_submit)
+#define __NR_io_submit 2
+#endif
+
+#if !defined(__NR_io_cancel)
+#define __NR_io_cancel 3
+#endif
+
+#if !defined(__NR_io_getevents)
+#define __NR_io_getevents 4
+#endif
+
+#if !defined(__NR_setxattr)
+#define __NR_setxattr 5
+#endif
+
+#if !defined(__NR_lsetxattr)
+#define __NR_lsetxattr 6
+#endif
+
+#if !defined(__NR_fsetxattr)
+#define __NR_fsetxattr 7
+#endif
+
+#if !defined(__NR_getxattr)
+#define __NR_getxattr 8
+#endif
+
+#if !defined(__NR_lgetxattr)
+#define __NR_lgetxattr 9
+#endif
+
+#if !defined(__NR_fgetxattr)
+#define __NR_fgetxattr 10
+#endif
+
+#if !defined(__NR_listxattr)
+#define __NR_listxattr 11
+#endif
+
+#if !defined(__NR_llistxattr)
+#define __NR_llistxattr 12
+#endif
+
+#if !defined(__NR_flistxattr)
+#define __NR_flistxattr 13
+#endif
+
+#if !defined(__NR_removexattr)
+#define __NR_removexattr 14
+#endif
+
+#if !defined(__NR_lremovexattr)
+#define __NR_lremovexattr 15
+#endif
+
+#if !defined(__NR_fremovexattr)
+#define __NR_fremovexattr 16
+#endif
+
+#if !defined(__NR_getcwd)
+#define __NR_getcwd 17
+#endif
+
+#if !defined(__NR_lookup_dcookie)
+#define __NR_lookup_dcookie 18
+#endif
+
+#if !defined(__NR_eventfd2)
+#define __NR_eventfd2 19
+#endif
+
+#if !defined(__NR_epoll_create1)
+#define __NR_epoll_create1 20
+#endif
+
+#if !defined(__NR_epoll_ctl)
+#define __NR_epoll_ctl 21
+#endif
+
+#if !defined(__NR_epoll_pwait)
+#define __NR_epoll_pwait 22
+#endif
+
+#if !defined(__NR_dup)
+#define __NR_dup 23
+#endif
+
+#if !defined(__NR_dup3)
+#define __NR_dup3 24
+#endif
+
+#if !defined(__NR_fcntl)
+#define __NR_fcntl 25
+#endif
+
+#if !defined(__NR_inotify_init1)
+#define __NR_inotify_init1 26
+#endif
+
+#if !defined(__NR_inotify_add_watch)
+#define __NR_inotify_add_watch 27
+#endif
+
+#if !defined(__NR_inotify_rm_watch)
+#define __NR_inotify_rm_watch 28
+#endif
+
+#if !defined(__NR_ioctl)
+#define __NR_ioctl 29
+#endif
+
+#if !defined(__NR_ioprio_set)
+#define __NR_ioprio_set 30
+#endif
+
+#if !defined(__NR_ioprio_get)
+#define __NR_ioprio_get 31
+#endif
+
+#if !defined(__NR_flock)
+#define __NR_flock 32
+#endif
+
+#if !defined(__NR_mknodat)
+#define __NR_mknodat 33
+#endif
+
+#if !defined(__NR_mkdirat)
+#define __NR_mkdirat 34
+#endif
+
+#if !defined(__NR_unlinkat)
+#define __NR_unlinkat 35
+#endif
+
+#if !defined(__NR_symlinkat)
+#define __NR_symlinkat 36
+#endif
+
+#if !defined(__NR_linkat)
+#define __NR_linkat 37
+#endif
+
+#if !defined(__NR_umount2)
+#define __NR_umount2 39
+#endif
+
+#if !defined(__NR_mount)
+#define __NR_mount 40
+#endif
+
+#if !defined(__NR_pivot_root)
+#define __NR_pivot_root 41
+#endif
+
+#if !defined(__NR_nfsservctl)
+#define __NR_nfsservctl 42
+#endif
+
+#if !defined(__NR_statfs)
+#define __NR_statfs 43
+#endif
+
+#if !defined(__NR_fstatfs)
+#define __NR_fstatfs 44
+#endif
+
+#if !defined(__NR_truncate)
+#define __NR_truncate 45
+#endif
+
+#if !defined(__NR_ftruncate)
+#define __NR_ftruncate 46
+#endif
+
+#if !defined(__NR_fallocate)
+#define __NR_fallocate 47
+#endif
+
+#if !defined(__NR_faccessat)
+#define __NR_faccessat 48
+#endif
+
+#if !defined(__NR_chdir)
+#define __NR_chdir 49
+#endif
+
+#if !defined(__NR_fchdir)
+#define __NR_fchdir 50
+#endif
+
+#if !defined(__NR_chroot)
+#define __NR_chroot 51
+#endif
+
+#if !defined(__NR_fchmod)
+#define __NR_fchmod 52
+#endif
+
+#if !defined(__NR_fchmodat)
+#define __NR_fchmodat 53
+#endif
+
+#if !defined(__NR_fchownat)
+#define __NR_fchownat 54
+#endif
+
+#if !defined(__NR_fchown)
+#define __NR_fchown 55
+#endif
+
+#if !defined(__NR_openat)
+#define __NR_openat 56
+#endif
+
+#if !defined(__NR_close)
+#define __NR_close 57
+#endif
+
+#if !defined(__NR_vhangup)
+#define __NR_vhangup 58
+#endif
+
+#if !defined(__NR_pipe2)
+#define __NR_pipe2 59
+#endif
+
+#if !defined(__NR_quotactl)
+#define __NR_quotactl 60
+#endif
+
+#if !defined(__NR_getdents64)
+#define __NR_getdents64 61
+#endif
+
+#if !defined(__NR_lseek)
+#define __NR_lseek 62
+#endif
+
+#if !defined(__NR_read)
+#define __NR_read 63
+#endif
+
+#if !defined(__NR_write)
+#define __NR_write 64
+#endif
+
+#if !defined(__NR_readv)
+#define __NR_readv 65
+#endif
+
+#if !defined(__NR_writev)
+#define __NR_writev 66
+#endif
+
+#if !defined(__NR_pread64)
+#define __NR_pread64 67
+#endif
+
+#if !defined(__NR_pwrite64)
+#define __NR_pwrite64 68
+#endif
+
+#if !defined(__NR_preadv)
+#define __NR_preadv 69
+#endif
+
+#if !defined(__NR_pwritev)
+#define __NR_pwritev 70
+#endif
+
+#if !defined(__NR_sendfile)
+#define __NR_sendfile 71
+#endif
+
+#if !defined(__NR_pselect6)
+#define __NR_pselect6 72
+#endif
+
+#if !defined(__NR_ppoll)
+#define __NR_ppoll 73
+#endif
+
+#if !defined(__NR_signalfd4)
+#define __NR_signalfd4 74
+#endif
+
+#if !defined(__NR_vmsplice)
+#define __NR_vmsplice 75
+#endif
+
+#if !defined(__NR_splice)
+#define __NR_splice 76
+#endif
+
+#if !defined(__NR_tee)
+#define __NR_tee 77
+#endif
+
+#if !defined(__NR_readlinkat)
+#define __NR_readlinkat 78
+#endif
+
+#if !defined(__NR_sync)
+#define __NR_sync 81
+#endif
+
+#if !defined(__NR_fsync)
+#define __NR_fsync 82
+#endif
+
+#if !defined(__NR_fdatasync)
+#define __NR_fdatasync 83
+#endif
+
+#if !defined(__NR_sync_file_range)
+#define __NR_sync_file_range 84
+#endif
+
+#if !defined(__NR_timerfd_create)
+#define __NR_timerfd_create 85
+#endif
+
+#if !defined(__NR_timerfd_settime)
+#define __NR_timerfd_settime 86
+#endif
+
+#if !defined(__NR_timerfd_gettime)
+#define __NR_timerfd_gettime 87
+#endif
+
+#if !defined(__NR_utimensat)
+#define __NR_utimensat 88
+#endif
+
+#if !defined(__NR_acct)
+#define __NR_acct 89
+#endif
+
+#if !defined(__NR_capget)
+#define __NR_capget 90
+#endif
+
+#if !defined(__NR_capset)
+#define __NR_capset 91
+#endif
+
+#if !defined(__NR_personality)
+#define __NR_personality 92
+#endif
+
+#if !defined(__NR_exit)
+#define __NR_exit 93
+#endif
+
+#if !defined(__NR_exit_group)
+#define __NR_exit_group 94
+#endif
+
+#if !defined(__NR_waitid)
+#define __NR_waitid 95
+#endif
+
+#if !defined(__NR_set_tid_address)
+#define __NR_set_tid_address 96
+#endif
+
+#if !defined(__NR_unshare)
+#define __NR_unshare 97
+#endif
+
+#if !defined(__NR_futex)
+#define __NR_futex 98
+#endif
+
+#if !defined(__NR_set_robust_list)
+#define __NR_set_robust_list 99
+#endif
+
+#if !defined(__NR_get_robust_list)
+#define __NR_get_robust_list 100
+#endif
+
+#if !defined(__NR_nanosleep)
+#define __NR_nanosleep 101
+#endif
+
+#if !defined(__NR_getitimer)
+#define __NR_getitimer 102
+#endif
+
+#if !defined(__NR_setitimer)
+#define __NR_setitimer 103
+#endif
+
+#if !defined(__NR_kexec_load)
+#define __NR_kexec_load 104
+#endif
+
+#if !defined(__NR_init_module)
+#define __NR_init_module 105
+#endif
+
+#if !defined(__NR_delete_module)
+#define __NR_delete_module 106
+#endif
+
+#if !defined(__NR_timer_create)
+#define __NR_timer_create 107
+#endif
+
+#if !defined(__NR_timer_gettime)
+#define __NR_timer_gettime 108
+#endif
+
+#if !defined(__NR_timer_getoverrun)
+#define __NR_timer_getoverrun 109
+#endif
+
+#if !defined(__NR_timer_settime)
+#define __NR_timer_settime 110
+#endif
+
+#if !defined(__NR_timer_delete)
+#define __NR_timer_delete 111
+#endif
+
+#if !defined(__NR_clock_settime)
+#define __NR_clock_settime 112
+#endif
+
+#if !defined(__NR_clock_gettime)
+#define __NR_clock_gettime 113
+#endif
+
+#if !defined(__NR_clock_getres)
+#define __NR_clock_getres 114
+#endif
+
+#if !defined(__NR_clock_nanosleep)
+#define __NR_clock_nanosleep 115
+#endif
+
+#if !defined(__NR_syslog)
+#define __NR_syslog 116
+#endif
+
+#if !defined(__NR_ptrace)
+#define __NR_ptrace 117
+#endif
+
+#if !defined(__NR_sched_setparam)
+#define __NR_sched_setparam 118
+#endif
+
+#if !defined(__NR_sched_setscheduler)
+#define __NR_sched_setscheduler 119
+#endif
+
+#if !defined(__NR_sched_getscheduler)
+#define __NR_sched_getscheduler 120
+#endif
+
+#if !defined(__NR_sched_getparam)
+#define __NR_sched_getparam 121
+#endif
+
+#if !defined(__NR_sched_setaffinity)
+#define __NR_sched_setaffinity 122
+#endif
+
+#if !defined(__NR_sched_getaffinity)
+#define __NR_sched_getaffinity 123
+#endif
+
+#if !defined(__NR_sched_yield)
+#define __NR_sched_yield 124
+#endif
+
+#if !defined(__NR_sched_get_priority_max)
+#define __NR_sched_get_priority_max 125
+#endif
+
+#if !defined(__NR_sched_get_priority_min)
+#define __NR_sched_get_priority_min 126
+#endif
+
+#if !defined(__NR_sched_rr_get_interval)
+#define __NR_sched_rr_get_interval 127
+#endif
+
+#if !defined(__NR_restart_syscall)
+#define __NR_restart_syscall 128
+#endif
+
+#if !defined(__NR_kill)
+#define __NR_kill 129
+#endif
+
+#if !defined(__NR_tkill)
+#define __NR_tkill 130
+#endif
+
+#if !defined(__NR_tgkill)
+#define __NR_tgkill 131
+#endif
+
+#if !defined(__NR_sigaltstack)
+#define __NR_sigaltstack 132
+#endif
+
+#if !defined(__NR_rt_sigsuspend)
+#define __NR_rt_sigsuspend 133
+#endif
+
+#if !defined(__NR_rt_sigaction)
+#define __NR_rt_sigaction 134
+#endif
+
+#if !defined(__NR_rt_sigprocmask)
+#define __NR_rt_sigprocmask 135
+#endif
+
+#if !defined(__NR_rt_sigpending)
+#define __NR_rt_sigpending 136
+#endif
+
+#if !defined(__NR_rt_sigtimedwait)
+#define __NR_rt_sigtimedwait 137
+#endif
+
+#if !defined(__NR_rt_sigqueueinfo)
+#define __NR_rt_sigqueueinfo 138
+#endif
+
+#if !defined(__NR_rt_sigreturn)
+#define __NR_rt_sigreturn 139
+#endif
+
+#if !defined(__NR_setpriority)
+#define __NR_setpriority 140
+#endif
+
+#if !defined(__NR_getpriority)
+#define __NR_getpriority 141
+#endif
+
+#if !defined(__NR_reboot)
+#define __NR_reboot 142
+#endif
+
+#if !defined(__NR_setregid)
+#define __NR_setregid 143
+#endif
+
+#if !defined(__NR_setgid)
+#define __NR_setgid 144
+#endif
+
+#if !defined(__NR_setreuid)
+#define __NR_setreuid 145
+#endif
+
+#if !defined(__NR_setuid)
+#define __NR_setuid 146
+#endif
+
+#if !defined(__NR_setresuid)
+#define __NR_setresuid 147
+#endif
+
+#if !defined(__NR_getresuid)
+#define __NR_getresuid 148
+#endif
+
+#if !defined(__NR_setresgid)
+#define __NR_setresgid 149
+#endif
+
+#if !defined(__NR_getresgid)
+#define __NR_getresgid 150
+#endif
+
+#if !defined(__NR_setfsuid)
+#define __NR_setfsuid 151
+#endif
+
+#if !defined(__NR_setfsgid)
+#define __NR_setfsgid 152
+#endif
+
+#if !defined(__NR_times)
+#define __NR_times 153
+#endif
+
+#if !defined(__NR_setpgid)
+#define __NR_setpgid 154
+#endif
+
+#if !defined(__NR_getpgid)
+#define __NR_getpgid 155
+#endif
+
+#if !defined(__NR_getsid)
+#define __NR_getsid 156
+#endif
+
+#if !defined(__NR_setsid)
+#define __NR_setsid 157
+#endif
+
+#if !defined(__NR_getgroups)
+#define __NR_getgroups 158
+#endif
+
+#if !defined(__NR_setgroups)
+#define __NR_setgroups 159
+#endif
+
+#if !defined(__NR_uname)
+#define __NR_uname 160
+#endif
+
+#if !defined(__NR_sethostname)
+#define __NR_sethostname 161
+#endif
+
+#if !defined(__NR_setdomainname)
+#define __NR_setdomainname 162
+#endif
+
+#if !defined(__NR_getrusage)
+#define __NR_getrusage 165
+#endif
+
+#if !defined(__NR_umask)
+#define __NR_umask 166
+#endif
+
+#if !defined(__NR_prctl)
+#define __NR_prctl 167
+#endif
+
+#if !defined(__NR_getcpu)
+#define __NR_getcpu 168
+#endif
+
+#if !defined(__NR_gettimeofday)
+#define __NR_gettimeofday 169
+#endif
+
+#if !defined(__NR_settimeofday)
+#define __NR_settimeofday 170
+#endif
+
+#if !defined(__NR_adjtimex)
+#define __NR_adjtimex 171
+#endif
+
+#if !defined(__NR_getpid)
+#define __NR_getpid 172
+#endif
+
+#if !defined(__NR_getppid)
+#define __NR_getppid 173
+#endif
+
+#if !defined(__NR_getuid)
+#define __NR_getuid 174
+#endif
+
+#if !defined(__NR_geteuid)
+#define __NR_geteuid 175
+#endif
+
+#if !defined(__NR_getgid)
+#define __NR_getgid 176
+#endif
+
+#if !defined(__NR_getegid)
+#define __NR_getegid 177
+#endif
+
+#if !defined(__NR_gettid)
+#define __NR_gettid 178
+#endif
+
+#if !defined(__NR_sysinfo)
+#define __NR_sysinfo 179
+#endif
+
+#if !defined(__NR_mq_open)
+#define __NR_mq_open 180
+#endif
+
+#if !defined(__NR_mq_unlink)
+#define __NR_mq_unlink 181
+#endif
+
+#if !defined(__NR_mq_timedsend)
+#define __NR_mq_timedsend 182
+#endif
+
+#if !defined(__NR_mq_timedreceive)
+#define __NR_mq_timedreceive 183
+#endif
+
+#if !defined(__NR_mq_notify)
+#define __NR_mq_notify 184
+#endif
+
+#if !defined(__NR_mq_getsetattr)
+#define __NR_mq_getsetattr 185
+#endif
+
+#if !defined(__NR_msgget)
+#define __NR_msgget 186
+#endif
+
+#if !defined(__NR_msgctl)
+#define __NR_msgctl 187
+#endif
+
+#if !defined(__NR_msgrcv)
+#define __NR_msgrcv 188
+#endif
+
+#if !defined(__NR_msgsnd)
+#define __NR_msgsnd 189
+#endif
+
+#if !defined(__NR_semget)
+#define __NR_semget 190
+#endif
+
+#if !defined(__NR_semctl)
+#define __NR_semctl 191
+#endif
+
+#if !defined(__NR_semtimedop)
+#define __NR_semtimedop 192
+#endif
+
+#if !defined(__NR_semop)
+#define __NR_semop 193
+#endif
+
+#if !defined(__NR_shmget)
+#define __NR_shmget 194
+#endif
+
+#if !defined(__NR_shmctl)
+#define __NR_shmctl 195
+#endif
+
+#if !defined(__NR_shmat)
+#define __NR_shmat 196
+#endif
+
+#if !defined(__NR_shmdt)
+#define __NR_shmdt 197
+#endif
+
+#if !defined(__NR_socket)
+#define __NR_socket 198
+#endif
+
+#if !defined(__NR_socketpair)
+#define __NR_socketpair 199
+#endif
+
+#if !defined(__NR_bind)
+#define __NR_bind 200
+#endif
+
+#if !defined(__NR_listen)
+#define __NR_listen 201
+#endif
+
+#if !defined(__NR_accept)
+#define __NR_accept 202
+#endif
+
+#if !defined(__NR_connect)
+#define __NR_connect 203
+#endif
+
+#if !defined(__NR_getsockname)
+#define __NR_getsockname 204
+#endif
+
+#if !defined(__NR_getpeername)
+#define __NR_getpeername 205
+#endif
+
+#if !defined(__NR_sendto)
+#define __NR_sendto 206
+#endif
+
+#if !defined(__NR_recvfrom)
+#define __NR_recvfrom 207
+#endif
+
+#if !defined(__NR_setsockopt)
+#define __NR_setsockopt 208
+#endif
+
+#if !defined(__NR_getsockopt)
+#define __NR_getsockopt 209
+#endif
+
+#if !defined(__NR_shutdown)
+#define __NR_shutdown 210
+#endif
+
+#if !defined(__NR_sendmsg)
+#define __NR_sendmsg 211
+#endif
+
+#if !defined(__NR_recvmsg)
+#define __NR_recvmsg 212
+#endif
+
+#if !defined(__NR_readahead)
+#define __NR_readahead 213
+#endif
+
+#if !defined(__NR_brk)
+#define __NR_brk 214
+#endif
+
+#if !defined(__NR_munmap)
+#define __NR_munmap 215
+#endif
+
+#if !defined(__NR_mremap)
+#define __NR_mremap 216
+#endif
+
+#if !defined(__NR_add_key)
+#define __NR_add_key 217
+#endif
+
+#if !defined(__NR_request_key)
+#define __NR_request_key 218
+#endif
+
+#if !defined(__NR_keyctl)
+#define __NR_keyctl 219
+#endif
+
+#if !defined(__NR_clone)
+#define __NR_clone 220
+#endif
+
+#if !defined(__NR_execve)
+#define __NR_execve 221
+#endif
+
+#if !defined(__NR_mmap)
+#define __NR_mmap 222
+#endif
+
+#if !defined(__NR_fadvise64)
+#define __NR_fadvise64 223
+#endif
+
+#if !defined(__NR_swapon)
+#define __NR_swapon 224
+#endif
+
+#if !defined(__NR_swapoff)
+#define __NR_swapoff 225
+#endif
+
+#if !defined(__NR_mprotect)
+#define __NR_mprotect 226
+#endif
+
+#if !defined(__NR_msync)
+#define __NR_msync 227
+#endif
+
+#if !defined(__NR_mlock)
+#define __NR_mlock 228
+#endif
+
+#if !defined(__NR_munlock)
+#define __NR_munlock 229
+#endif
+
+#if !defined(__NR_mlockall)
+#define __NR_mlockall 230
+#endif
+
+#if !defined(__NR_munlockall)
+#define __NR_munlockall 231
+#endif
+
+#if !defined(__NR_mincore)
+#define __NR_mincore 232
+#endif
+
+#if !defined(__NR_madvise)
+#define __NR_madvise 233
+#endif
+
+#if !defined(__NR_remap_file_pages)
+#define __NR_remap_file_pages 234
+#endif
+
+#if !defined(__NR_mbind)
+#define __NR_mbind 235
+#endif
+
+#if !defined(__NR_get_mempolicy)
+#define __NR_get_mempolicy 236
+#endif
+
+#if !defined(__NR_set_mempolicy)
+#define __NR_set_mempolicy 237
+#endif
+
+#if !defined(__NR_migrate_pages)
+#define __NR_migrate_pages 238
+#endif
+
+#if !defined(__NR_move_pages)
+#define __NR_move_pages 239
+#endif
+
+#if !defined(__NR_rt_tgsigqueueinfo)
+#define __NR_rt_tgsigqueueinfo 240
+#endif
+
+#if !defined(__NR_perf_event_open)
+#define __NR_perf_event_open 241
+#endif
+
+#if !defined(__NR_accept4)
+#define __NR_accept4 242
+#endif
+
+#if !defined(__NR_recvmmsg)
+#define __NR_recvmmsg 243
+#endif
+
+#if !defined(__NR_wait4)
+#define __NR_wait4 260
+#endif
+
+#if !defined(__NR_prlimit64)
+#define __NR_prlimit64 261
+#endif
+
+#if !defined(__NR_fanotify_init)
+#define __NR_fanotify_init 262
+#endif
+
+#if !defined(__NR_fanotify_mark)
+#define __NR_fanotify_mark 263
+#endif
+
+#if !defined(__NR_name_to_handle_at)
+#define __NR_name_to_handle_at 264
+#endif
+
+#if !defined(__NR_open_by_handle_at)
+#define __NR_open_by_handle_at 265
+#endif
+
+#if !defined(__NR_clock_adjtime)
+#define __NR_clock_adjtime 266
+#endif
+
+#if !defined(__NR_syncfs)
+#define __NR_syncfs 267
+#endif
+
+#if !defined(__NR_setns)
+#define __NR_setns 268
+#endif
+
+#if !defined(__NR_sendmmsg)
+#define __NR_sendmmsg 269
+#endif
+
+#if !defined(__NR_process_vm_readv)
+#define __NR_process_vm_readv 270
+#endif
+
+#if !defined(__NR_process_vm_writev)
+#define __NR_process_vm_writev 271
+#endif
+
+#if !defined(__NR_kcmp)
+#define __NR_kcmp 272
+#endif
+
+#if !defined(__NR_finit_module)
+#define __NR_finit_module 273
+#endif
+
+#if !defined(__NR_sched_setattr)
+#define __NR_sched_setattr 274
+#endif
+
+#if !defined(__NR_sched_getattr)
+#define __NR_sched_getattr 275
+#endif
+
+#if !defined(__NR_renameat2)
+#define __NR_renameat2 276
+#endif
+
+#if !defined(__NR_seccomp)
+#define __NR_seccomp 277
+#endif
+
+#if !defined(__NR_getrandom)
+#define __NR_getrandom 278
+#endif
+
+#if !defined(__NR_memfd_create)
+#define __NR_memfd_create 279
+#endif
+
+#if !defined(__NR_bpf)
+#define __NR_bpf 280
+#endif
+
+#if !defined(__NR_execveat)
+#define __NR_execveat 281
+#endif
+
+#if !defined(__NR_userfaultfd)
+#define __NR_userfaultfd 282
+#endif
+
+#if !defined(__NR_membarrier)
+#define __NR_membarrier 283
+#endif
+
+#if !defined(__NR_mlock2)
+#define __NR_mlock2 284
+#endif
+
+#if !defined(__NR_copy_file_range)
+#define __NR_copy_file_range 285
+#endif
+
+#if !defined(__NR_preadv2)
+#define __NR_preadv2 286
+#endif
+
+#if !defined(__NR_pwritev2)
+#define __NR_pwritev2 287
+#endif
+
+#if !defined(__NR_pkey_mprotect)
+#define __NR_pkey_mprotect 288
+#endif
+
+#if !defined(__NR_pkey_alloc)
+#define __NR_pkey_alloc 289
+#endif
+
+#if !defined(__NR_pkey_free)
+#define __NR_pkey_free 290
+#endif
+
+#if !defined(__NR_statx)
+#define __NR_statx 291
+#endif
+
+#if !defined(__NR_io_pgetevents)
+#define __NR_io_pgetevents 292
+#endif
+
+#if !defined(__NR_rseq)
+#define __NR_rseq 293
+#endif
+
+#if !defined(__NR_kexec_file_load)
+#define __NR_kexec_file_load 294
+#endif
+
+#if !defined(__NR_pidfd_send_signal)
+#define __NR_pidfd_send_signal 424
+#endif
+
+#if !defined(__NR_io_uring_setup)
+#define __NR_io_uring_setup 425
+#endif
+
+#if !defined(__NR_io_uring_enter)
+#define __NR_io_uring_enter 426
+#endif
+
+#if !defined(__NR_io_uring_register)
+#define __NR_io_uring_register 427
+#endif
+
+#if !defined(__NR_open_tree)
+#define __NR_open_tree 428
+#endif
+
+#if !defined(__NR_move_mount)
+#define __NR_move_mount 429
+#endif
+
+#if !defined(__NR_fsopen)
+#define __NR_fsopen 430
+#endif
+
+#if !defined(__NR_fsconfig)
+#define __NR_fsconfig 431
+#endif
+
+#if !defined(__NR_fsmount)
+#define __NR_fsmount 432
+#endif
+
+#if !defined(__NR_fspick)
+#define __NR_fspick 433
+#endif
+
+#if !defined(__NR_pidfd_open)
+#define __NR_pidfd_open 434
+#endif
+
+#if !defined(__NR_clone3)
+#define __NR_clone3 435
+#endif
+
+#if !defined(__NR_close_range)
+#define __NR_close_range 436
+#endif
+
+#if !defined(__NR_openat2)
+#define __NR_openat2 437
+#endif
+
+#if !defined(__NR_pidfd_getfd)
+#define __NR_pidfd_getfd 438
+#endif
+
+#if !defined(__NR_faccessat2)
+#define __NR_faccessat2 439
+#endif
+
+#if !defined(__NR_process_madvise)
+#define __NR_process_madvise 440
+#endif
+
+#if !defined(__NR_epoll_pwait2)
+#define __NR_epoll_pwait2 441
+#endif
+
+#if !defined(__NR_mount_setattr)
+#define __NR_mount_setattr 442
+#endif
+
+#if !defined(__NR_landlock_create_ruleset)
+#define __NR_landlock_create_ruleset 444
+#endif
+
+#if !defined(__NR_landlock_add_rule)
+#define __NR_landlock_add_rule 445
+#endif
+
+#if !defined(__NR_landlock_restrict_self)
+#define __NR_landlock_restrict_self 446
+#endif
+
+#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LOONG64_LINUX_SYSCALLS_H_
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/bpf_audio_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_audio_policy_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_audio_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_audio_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -85,6 +85,7 @@ ResultExpr AudioProcessPolicy::EvaluateS
return Switch(op & ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME))
.Cases({FUTEX_CMP_REQUEUE,
FUTEX_LOCK_PI,
+ FUTEX_LOCK_PI2,
FUTEX_UNLOCK_PI,
FUTEX_WAIT,
FUTEX_WAIT_BITSET,
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/bpf_broker_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_broker_policy_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_broker_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_broker_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -87,6 +87,12 @@ ResultExpr BrokerProcessPolicy::Evaluate
return Allow();
break;
#endif
+#if defined(__NR_statx)
+ case __NR_statx:
+ if (allowed_command_set_.test(syscall_broker::COMMAND_STAT))
+ return Allow();
+ break;
+#endif
#if defined(__NR_lstat)
case __NR_lstat:
if (allowed_command_set_.test(syscall_broker::COMMAND_STAT))
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::Eval
case __NR_sched_setscheduler:
case __NR_sysinfo:
case __NR_uname:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_readlink:
case __NR_stat:
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -80,7 +80,7 @@ ResultExpr GpuProcessPolicy::EvaluateSys
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
case __NR_ftruncate64:
#endif
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_getdents:
#endif
case __NR_getdents64:
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/bpf_network_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_network_policy_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_network_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_network_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -260,7 +260,7 @@ ResultExpr NetworkProcessPolicy::Evaluat
case __NR_fdatasync:
case __NR_fsync:
case __NR_mremap:
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__loongarch__)
case __NR_getdents:
#endif
case __NR_getdents64:
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/bpf_screen_ai_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_screen_ai_policy_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_screen_ai_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_screen_ai_policy_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -37,7 +37,7 @@ ResultExpr ScreenAIProcessPolicy::Evalua
const Arg<int> op(1);
return Switch(op & FUTEX_CMD_MASK)
.Cases(
- {FUTEX_CMP_REQUEUE, FUTEX_LOCK_PI, FUTEX_UNLOCK_PI, FUTEX_WAIT,
+ {FUTEX_CMP_REQUEUE, FUTEX_LOCK_PI, FUTEX_LOCK_PI2, FUTEX_UNLOCK_PI, FUTEX_WAIT,
FUTEX_WAIT_BITSET, FUTEX_WAKE},
Allow())
// Sending ENOSYS tells the Futex backend to use another approach if
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/sandbox/policy/linux/sandbox_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/sandbox_linux.cc
--- a/src/3rdparty/chromium/sandbox/policy/linux/sandbox_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/sandbox/policy/linux/sandbox_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -596,6 +596,7 @@ bpf_dsl::ResultExpr SandboxLinux::Handle
const bpf_dsl::ResultExpr handle_via_broker =
bpf_dsl::Trap(syscall_broker::BrokerClient::SIGSYS_Handler,
broker_process_->GetBrokerClientSignalBased());
+#if !defined(__loongarch__)
if (sysno == __NR_fstatat_default) {
// This may be an fstatat(fd, "", stat_buf, AT_EMPTY_PATH), which should be
// rewritten as fstat(fd, stat_buf). This should be consistent with how the
@@ -606,6 +607,15 @@ bpf_dsl::ResultExpr SandboxLinux::Handle
return bpf_dsl::If((flags & AT_EMPTY_PATH) == AT_EMPTY_PATH,
RewriteFstatatSIGSYS(BPFBasePolicy::GetFSDeniedErrno()))
.Else(handle_via_broker);
+#else
+ if (sysno == __NR_statx) {
+ // This may be a statx(fd, "", AT_EMPTY_PATH, mask, statx_buf), and we allow it.
+ // Otherwise, we expect a statx(AT_FDCWD, path, flags, mask, statx_buf).
+ const bpf_dsl::Arg<int> flags(2);
+ return bpf_dsl::If((flags & AT_EMPTY_PATH) == AT_EMPTY_PATH,
+ bpf_dsl::Allow())
+ .Else(handle_via_broker);
+#endif
} else {
return handle_via_broker;
}