diff options
| author | Weijie Gao | 2024-12-22 10:28:12 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2024-12-22 16:04:11 +0000 |
| commit | 42d3937654508b04da64969f9d764ac2ec411904 (patch) | |
| tree | 1ba724a9f82389a07292074a2fad58b27626c719 | |
| parent | fd01fb852302a2683d09ee1c2193d7c51e2b0ba8 (diff) | |
| download | procd-42d3937654508b04da64969f9d764ac2ec411904.tar.gz | |
jail/seccomp: add support for loongarch64
Add support for loongarch64 in utrace and ujail.
Signed-off-by: Weijie Gao <hackpascal@gmail.com>
| -rw-r--r-- | jail/seccomp-bpf.h | 3 | ||||
| -rw-r--r-- | jail/seccomp-oci.c | 2 | ||||
| -rw-r--r-- | trace/trace.c | 6 |
3 files changed, 8 insertions, 3 deletions
diff --git a/jail/seccomp-bpf.h b/jail/seccomp-bpf.h index 077483f..e6384db 100644 --- a/jail/seccomp-bpf.h +++ b/jail/seccomp-bpf.h @@ -80,6 +80,9 @@ struct seccomp_data { #elif defined(__i386__) # define REG_SYSCALL REG_EAX # define ARCH_NR AUDIT_ARCH_I386 +#elif defined(__loongarch_lp64) +# define REG_SYSCALL regs[11] +# define ARCH_NR AUDIT_ARCH_LOONGARCH64 #elif defined(__mips__) # define REG_SYSCALL regs[2] # if __BYTE_ORDER == __LITTLE_ENDIAN diff --git a/jail/seccomp-oci.c b/jail/seccomp-oci.c index f089ac6..9ef43d1 100644 --- a/jail/seccomp-oci.c +++ b/jail/seccomp-oci.c @@ -119,6 +119,8 @@ static uint32_t resolve_architecture(char *archname) return AUDIT_ARCH_ARM; else if (!strcmp(archname, "SCMP_ARCH_AARCH64")) return AUDIT_ARCH_AARCH64; + else if (!strcmp(archname, "SCMP_ARCH_LOONGARCH64")) + return AUDIT_ARCH_LOONGARCH64; else if (!strcmp(archname, "SCMP_ARCH_MIPS")) return AUDIT_ARCH_MIPS; else if (!strcmp(archname, "SCMP_ARCH_MIPS64")) diff --git a/trace/trace.c b/trace/trace.c index e257d89..47c2fef 100644 --- a/trace/trace.c +++ b/trace/trace.c @@ -48,7 +48,7 @@ #define _offsetof(a, b) __builtin_offsetof(a,b) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -#if defined (__aarch64__) +#if defined (__aarch64__) || defined(__loongarch_lp64) #include <linux/ptrace.h> #elif defined(__amd64__) #define reg_syscall_nr _offsetof(struct user, regs.orig_rax) @@ -226,7 +226,7 @@ static void tracer_cb(struct uloop_process *c, int ret) if (WIFSTOPPED(ret) || (ret >> 16)) { if (WSTOPSIG(ret) & 0x80) { if (!tracee->in_syscall) { -#ifdef __aarch64__ +#if defined(__aarch64__) || defined(__loongarch_lp64) int syscall = -1; struct ptrace_syscall_info ptsi = {.op=PTRACE_SYSCALL_INFO_ENTRY}; if (ptrace(PTRACE_GET_SYSCALL_INFO, c->pid, sizeof(ptsi), &ptsi) != -1) @@ -260,7 +260,7 @@ static void tracer_cb(struct uloop_process *c, int ret) } else if ((ret >> 16) == PTRACE_EVENT_STOP) { /* Nothing special to do here */ } else if ((ret >> 8) == (SIGTRAP | (PTRACE_EVENT_SECCOMP << 8))) { -#ifdef __aarch64__ +#if defined(__aarch64__) || defined(__loongarch_lp64) int syscall = -1; struct ptrace_syscall_info ptsi = {.op=PTRACE_SYSCALL_INFO_SECCOMP}; if (ptrace(PTRACE_GET_SYSCALL_INFO, c->pid, sizeof(ptsi), &ptsi) != -1) |