Skip to content

Commit 8a1335c

Browse files
authored
Merge pull request #4766 from jokemanfire/loog
Add audit support for loong64
2 parents a85b5fc + 859feb8 commit 8a1335c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

libcontainer/seccomp/patchbpf/enosys_linux.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ const uintptr_t C_FILTER_FLAG_NEW_LISTENER = SECCOMP_FILTER_FLAG_NEW_LISTENER;
5858
#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
5959
#endif
6060
61+
// TODO: If loongarch support is not fully merged, at some point we will want to remove this.
62+
#ifndef AUDIT_ARCH_LOONGARCH64
63+
#ifndef EM_LOONGARCH
64+
#define EM_LOONGARCH 258
65+
#endif
66+
#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
67+
#endif
68+
6169
// We use the AUDIT_ARCH_* values because those are the ones used by the kernel
6270
// and SCMP_ARCH_* sometimes has fake values (such as SCMP_ARCH_X32). But we
6371
// use <seccomp.h> so we get libseccomp's fallback definitions of AUDIT_ARCH_*.
@@ -78,6 +86,7 @@ const uint32_t C_AUDIT_ARCH_PPC64LE = AUDIT_ARCH_PPC64LE;
7886
const uint32_t C_AUDIT_ARCH_S390 = AUDIT_ARCH_S390;
7987
const uint32_t C_AUDIT_ARCH_S390X = AUDIT_ARCH_S390X;
8088
const uint32_t C_AUDIT_ARCH_RISCV64 = AUDIT_ARCH_RISCV64;
89+
const uint32_t C_AUDIT_ARCH_LOONGARCH64 = AUDIT_ARCH_LOONGARCH64; //nolint:godot // C code, not Go comment.
8190
*/
8291
import "C"
8392

@@ -217,6 +226,8 @@ func scmpArchToAuditArch(arch libseccomp.ScmpArch) (linuxAuditArch, error) {
217226
return linuxAuditArch(C.C_AUDIT_ARCH_S390X), nil
218227
case libseccomp.ArchRISCV64:
219228
return linuxAuditArch(C.C_AUDIT_ARCH_RISCV64), nil
229+
case libseccomp.ArchLOONGARCH64:
230+
return linuxAuditArch(C.C_AUDIT_ARCH_LOONGARCH64), nil
220231
default:
221232
return invalidArch, fmt.Errorf("unknown architecture: %v", arch)
222233
}

0 commit comments

Comments
 (0)