From 67ef04e1ef9d40a76d1e2cb97ffa3adbfa51bdb5 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Thu, 15 Jan 2026 10:45:43 +0100 Subject: executor: sys/linux: Add VCPU fd to `syz_kvm_assert_syzos_uexit` Enhance the debugging capabilities of C reproducers by passing the VCPU file descriptor to the syz_kvm_assert_syzos_uexit function. With access to the VCPU fd, the function can now dump the VCPU's register state upon assertion failure, providing critical context for debugging guest execution issues. --- executor/common_kvm_arm64.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'executor/common_kvm_arm64.h') diff --git a/executor/common_kvm_arm64.h b/executor/common_kvm_arm64.h index 0663dcd1c..58678a9df 100644 --- a/executor/common_kvm_arm64.h +++ b/executor/common_kvm_arm64.h @@ -362,17 +362,32 @@ static long syz_kvm_vgic_v3_setup(volatile long a0, volatile long a1, volatile l #endif #if SYZ_EXECUTOR || __NR_syz_kvm_assert_syzos_uexit -static long syz_kvm_assert_syzos_uexit(volatile long a0, volatile long a1) +static long syz_kvm_assert_syzos_uexit(volatile long a0, volatile long a1, + volatile long a2) { - struct kvm_run* run = (struct kvm_run*)a0; - uint64 expect = a1; +#if !SYZ_EXECUTOR + int cpufd = (int)a0; +#endif + struct kvm_run* run = (struct kvm_run*)a1; + uint64 expect = a2; - if (!run || (run->exit_reason != KVM_EXIT_MMIO) || (run->mmio.phys_addr != ARM64_ADDR_UEXIT)) { + if (!run || (run->exit_reason != KVM_EXIT_MMIO) || + (run->mmio.phys_addr != ARM64_ADDR_UEXIT)) { +#if !SYZ_EXECUTOR + fprintf(stderr, "[SYZOS-DEBUG] Assertion Triggered on VCPU %d\n", cpufd); +#endif errno = EINVAL; return -1; } - if ((((uint64*)(run->mmio.data))[0]) != expect) { + uint64_t actual_code = ((uint64_t*)(run->mmio.data))[0]; + if (actual_code != expect) { +#if !SYZ_EXECUTOR + fprintf(stderr, "[SYZOS-DEBUG] Exit Code Mismatch on VCPU %d\n", cpufd); + fprintf(stderr, " Expected: 0x%lx\n", (unsigned long)expect); + fprintf(stderr, " Actual: 0x%lx\n", + (unsigned long)actual_code); +#endif errno = EDOM; return -1; } @@ -399,4 +414,4 @@ static long syz_kvm_assert_reg(volatile long a0, volatile long a1, volatile long } #endif -#endif // EXECUTOR_COMMON_KVM_ARM64_H \ No newline at end of file +#endif // EXECUTOR_COMMON_KVM_ARM64_H -- cgit mrf-deployment