Skip to content

Commit 9ac0fdc

Browse files
sys/linux/tests: add a seed that unrolls syz_kvm_vgic_v3_setup()
Provide a test case that replaces syz_kvm_vgic_v3_setup() with a sequence of 5 KVM ioctls.
1 parent 11c5b3f commit 9ac0fdc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# requires: arch=arm64 -threaded
3+
#
4+
r0 = openat$kvm(0, &AUTO='/dev/kvm\x00', 0x0, 0x0)
5+
r1 = ioctl$KVM_CREATE_VM(r0, AUTO, 0x0)
6+
r2 = syz_kvm_setup_syzos_vm(r1, &(0x7f0000c00000/0x400000)=nil)
7+
r3 = syz_kvm_add_vcpu(r2, &AUTO={0x0, &AUTO=[@irq_setup={AUTO, AUTO, {0x1, 0x20}}], AUTO}, 0x0, 0x0)
8+
#
9+
# Implementing syz_kvm_vgic_v3_setup(r1, 0x1, 0x100) using raw ioctls:
10+
#
11+
ioctl$KVM_CREATE_DEVICE(r1, AUTO, &AUTO={0x7, <r4=>0xffffffffffffffff, 0x0})
12+
ioctl$KVM_SET_DEVICE_ATTR(r4, AUTO, &AUTO=@attr_arm64={0x0, 0x3, 0x0, &AUTO=0x100})
13+
ioctl$KVM_SET_DEVICE_ATTR(r4, AUTO, &AUTO=@attr_arm64={0x0, 0x0, 0x2, &AUTO=0x08000000})
14+
ioctl$KVM_SET_DEVICE_ATTR(r4, AUTO, &AUTO=@attr_arm64={0x0, 0x0, 0x5, &AUTO=0x400000080a0000})
15+
ioctl$KVM_SET_DEVICE_ATTR(r4, AUTO, &AUTO=@attr_arm64={0x0, 0x4, 0x0, 0x0})
16+
17+
ioctl$KVM_RUN(r3, AUTO, 0x0)
18+
#
19+
# Calling KVM_RUN here again would result in infinite loop.
20+
# Instead, signal SPI 32 (0x1000020), so that the guest can execute another uexit in the IRQ handler.
21+
#
22+
ioctl$KVM_IRQ_LINE(r1, AUTO, &AUTO={0x1000020, 0x1})
23+
ioctl$KVM_RUN(r3, AUTO, 0x0)

0 commit comments

Comments
 (0)