Add AUDIT_ARCH_* constants from linux/audit.h#5311
Conversation
a11befc to
759ef16
Compare
This comment has been minimized.
This comment has been minimized.
759ef16 to
564f325
Compare
Architecture identification constants for seccomp BPF filters. https://github.com/torvalds/linux/blob/master/include/uapi/linux/audit.h#L389-L451
564f325 to
7dd182f
Compare
|
Can you just use https://docs.rs/linux-raw-sys/latest/linux_raw_sys/ptrace/index.html? We're trying to slim down the number of kernel bindings libc has. |
|
@tgross35 Thanks for the review and pointing me to linux-raw-sys::ptrace! After looking at actual usage patterns in the ecosystem, I think there's still a case for keeping them in libc. Let me explain: Key Points1. libc already has the seccomp APIlibc provides
AUDIT_ARCH_* constants are used primarily for architecture validation in seccomp BPF filters they complete this API. 2. Production projects are hardcoding because they use libc, not linux-raw-sysrust-vmm/seccompiler (used by Firecracker 35k stars): pub const AUDIT_ARCH_X86_64: u32 = 62 | 0x8000_0000 | 0x4000_0000;
pub const AUDIT_ARCH_AARCH64: u32 = 183 | 0x8000_0000 | 0x4000_0000;
pub const AUDIT_ARCH_RISCV64: u32 = 243 | 0x8000_0000 | 0x4000_0000;Their dependencies (Cargo.toml):
youki container runtime (7.5k stars) same pattern: hardcodes values, uses libc. 3. Current ecosystem patternProjects using AUDIT_ARCH for seccomp (GitHub Code Search):
The constants exist in linux-raw-sys::ptrace, but they're in the Question about libc's directionI understand the goal to reduce kernel bindings in libc. I'd like to understand the criteria better so I can contribute more effectively in the future: Should constants that are companions to existing libc APIs be included in libc? For example:
Or is the policy to move all kernel-specific constants to linux-raw-sys regardless of their relationship to existing libc APIs? Understanding this policy would help me (and projects like rust-vmm/seccompiler) make the right architectural decisions. If the direction is "use linux-raw-sys for kernel constants even when tied to libc APIs", that's valuable guidance for future contributions and I can help document that pattern. What do you think? |
Description
Add missing
AUDIT_ARCH_*architecture identification constants for Linux.These constants are defined in the kernel's
linux/audit.hand are used with seccomp BPF filters to validate system call architecture. They allow programs to ensure syscalls are being made from the expected architecture, which is critical for security-sensitive applications using seccomp.This adds:
__AUDIT_ARCH_64BIT,__AUDIT_ARCH_LE,__AUDIT_ARCH_CONVENTION_MASK,__AUDIT_ARCH_CONVENTION_MIPS64_N32AUDIT_ARCH_X86_64,AUDIT_ARCH_AARCH64,AUDIT_ARCH_ARM, etc.These constants have existed in the kernel for years but were never added to libc. Projects needing them (firecracker, seccompiler, etc.) have been hardcoding the values instead.
Sources
Checklist
libc-test/semverhave been updated*LASTor*MAX1 << Ninstead of hex literals for bit shiftscargo test -p libc-test --target x86_64-unknown-linux-gnu)@rustbot label +stable-nominated