From 3ea4a0797d7d3fa11e2fc4cca5619b3037d21993 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Thu, 17 Sep 2020 03:05:18 +0000 Subject: [PATCH] vmm: seccomp: unify AArch64 and x86_64 FTRUNCATE syscall The definition of libc::SYS_ftruncate on AArch64 is different from that on x86_64. This commit unifies the previously hard-coded syscall number for AArch64. Signed-off-by: Henry Wang --- vmm/src/seccomp_filters.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vmm/src/seccomp_filters.rs b/vmm/src/seccomp_filters.rs index 0a62c63ff..889ce2097 100644 --- a/vmm/src/seccomp_filters.rs +++ b/vmm/src/seccomp_filters.rs @@ -108,6 +108,12 @@ const KVM_GET_SUPPORTED_CPUID: u64 = 0xc008_ae05; const KVM_CREATE_DEVICE: u64 = 0xc00c_aee0; const KVM_GET_REG_LIST: u64 = 0xc008_aeb0; +// The definition of libc::SYS_ftruncate on AArch64 is different from that on x86_64. +#[cfg(target_arch = "aarch64")] +pub const SYS_FTRUNCATE: libc::c_long = 46; +#[cfg(target_arch = "x86_64")] +pub const SYS_FTRUNCATE: libc::c_long = 77; + fn create_vmm_ioctl_seccomp_rule_common() -> Result, Error> { Ok(or![ and![Cond::new(1, ArgLen::DWORD, Eq, FIOCLEX)?], @@ -300,12 +306,7 @@ fn vmm_thread_rules() -> Result, Error> { allow_syscall(libc::SYS_fork), allow_syscall(libc::SYS_fstat), allow_syscall(libc::SYS_fsync), - #[cfg(target_arch = "x86_64")] - allow_syscall(libc::SYS_ftruncate), - #[cfg(target_arch = "aarch64")] - // The definition of libc::SYS_ftruncate is missing on AArch64. - // Use a hard-code number instead. - allow_syscall(46), + allow_syscall(SYS_FTRUNCATE), #[cfg(target_arch = "aarch64")] allow_syscall(libc::SYS_faccessat), #[cfg(target_arch = "aarch64")]