Message ID | 20241008074253.370481-4-schlameuss@linux.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 89be2544579932a7d5cdb5e534dfd00624c5f39f |
Headers | show |
Series | selftests: kvm: s390: Add ucontrol memory selftests | expand |
On 10/8/24 9:42 AM, Christoph Schlameuss wrote: > Add a test case verifying KVM_SET_USER_MEMORY_REGION and > KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. > > Executing this test case on not patched kernels will cause a null > pointer dereference in the host kernel. > This is fixed with commit: > commit 7816e58967d0 ("kvm: s390: Reject memory region operations for ucontrol VMs") I'm going to remove the "commit" prefix from the line above when picking.
On 10/8/24 2:56 PM, Janosch Frank wrote: > On 10/8/24 9:42 AM, Christoph Schlameuss wrote: >> Add a test case verifying KVM_SET_USER_MEMORY_REGION and >> KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. >> >> Executing this test case on not patched kernels will cause a null >> pointer dereference in the host kernel. >> This is fixed with commit: >> commit 7816e58967d0 ("kvm: s390: Reject memory region operations for ucontrol VMs") > > I'm going to remove the "commit" prefix from the line above when picking. > Argh, just found out that this is a checkpatch enforced style... Alright then.
On Tue Oct 8, 2024 at 3:03 PM CEST, Janosch Frank wrote: > On 10/8/24 2:56 PM, Janosch Frank wrote: > > On 10/8/24 9:42 AM, Christoph Schlameuss wrote: > >> Add a test case verifying KVM_SET_USER_MEMORY_REGION and > >> KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. > >> > >> Executing this test case on not patched kernels will cause a null > >> pointer dereference in the host kernel. > >> This is fixed with commit: > >> commit 7816e58967d0 ("kvm: s390: Reject memory region operations for ucontrol VMs") > > > > I'm going to remove the "commit" prefix from the line above when picking. > > > > Argh, just found out that this is a checkpatch enforced style... > Alright then. Yes, sadly I did not find a way here so that checkstyle is completely happy with this :/
diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index f022322a00d4..5185620a21eb 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -400,6 +400,28 @@ static void uc_assert_diag44(FIXTURE_DATA(uc_kvm) * self) TEST_ASSERT_EQ(0x440000, sie_block->ipb); } +TEST_F(uc_kvm, uc_no_user_region) +{ + struct kvm_userspace_memory_region region = { + .slot = 1, + .guest_phys_addr = self->code_gpa, + .memory_size = VM_MEM_EXT_SIZE, + .userspace_addr = (uintptr_t)self->code_hva, + }; + struct kvm_userspace_memory_region2 region2 = { + .slot = 1, + .guest_phys_addr = self->code_gpa, + .memory_size = VM_MEM_EXT_SIZE, + .userspace_addr = (uintptr_t)self->code_hva, + }; + + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION, ®ion)); + ASSERT_EQ(EINVAL, errno); + + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION2, ®ion2)); + ASSERT_EQ(EINVAL, errno); +} + TEST_F(uc_kvm, uc_map_unmap) { struct kvm_sync_regs *sync_regs = &self->run->s.regs;