From 859feb8e449c6fc65e0405b35eb6b07a667037d2 Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Thu, 15 May 2025 20:11:49 +0800 Subject: [PATCH] build(seccomp): Add audit support for loong64 Co-authored-by: Rodrigo Campos Signed-off-by: jokemanfire --- libcontainer/seccomp/patchbpf/enosys_linux.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libcontainer/seccomp/patchbpf/enosys_linux.go b/libcontainer/seccomp/patchbpf/enosys_linux.go index 86de31378..e663fda33 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux.go @@ -58,6 +58,14 @@ const uintptr_t C_FILTER_FLAG_NEW_LISTENER = SECCOMP_FILTER_FLAG_NEW_LISTENER; #define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #endif +// TODO: If loongarch support is not fully merged, at some point we will want to remove this. +#ifndef AUDIT_ARCH_LOONGARCH64 +#ifndef EM_LOONGARCH +#define EM_LOONGARCH 258 +#endif +#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#endif + // We use the AUDIT_ARCH_* values because those are the ones used by the kernel // and SCMP_ARCH_* sometimes has fake values (such as SCMP_ARCH_X32). But we // use so we get libseccomp's fallback definitions of AUDIT_ARCH_*. @@ -78,6 +86,7 @@ const uint32_t C_AUDIT_ARCH_PPC64LE = AUDIT_ARCH_PPC64LE; const uint32_t C_AUDIT_ARCH_S390 = AUDIT_ARCH_S390; const uint32_t C_AUDIT_ARCH_S390X = AUDIT_ARCH_S390X; const uint32_t C_AUDIT_ARCH_RISCV64 = AUDIT_ARCH_RISCV64; +const uint32_t C_AUDIT_ARCH_LOONGARCH64 = AUDIT_ARCH_LOONGARCH64; //nolint:godot // C code, not Go comment. */ import "C" @@ -217,6 +226,8 @@ func scmpArchToAuditArch(arch libseccomp.ScmpArch) (linuxAuditArch, error) { return linuxAuditArch(C.C_AUDIT_ARCH_S390X), nil case libseccomp.ArchRISCV64: return linuxAuditArch(C.C_AUDIT_ARCH_RISCV64), nil + case libseccomp.ArchLOONGARCH64: + return linuxAuditArch(C.C_AUDIT_ARCH_LOONGARCH64), nil default: return invalidArch, fmt.Errorf("unknown architecture: %v", arch) }