mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-18 18:28:52 -04:00
KVM: s390: selftests: Verify reject memory region operations for ucontrol VMs
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 7816e58967 ("kvm: s390: Reject memory region operations for ucontrol VMs")
Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20241107141024.238916-4-schlameuss@linux.ibm.com
[frankja@linux.ibm.com: Fixed patch prefix]
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Message-ID: <20241107141024.238916-4-schlameuss@linux.ibm.com>
This commit is contained in:
committed by
Janosch Frank
parent
0185fbc6a2
commit
89be254457
@@ -440,6 +440,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;
|
||||
|
||||
Reference in New Issue
Block a user