Re: [PATCH 11/24] KVM: Take memory protections into account in kvm_read/write_guest()
From: Edgecombe, Rick P
Date: Thu Jul 16 2026 - 15:18:01 EST
On Thu, 2026-07-16 at 14:14 -0400, Paolo Bonzini wrote:
> @@ -3261,6 +3261,10 @@ static int __kvm_read_guest_page(struct kvm_memory_slot *slot, gfn_t gfn,
> addr = gfn_to_hva_memslot_prot(slot, gfn, NULL);
> if (kvm_is_error_hva(addr))
> return -EFAULT;
> +
> + if (!kvm_mem_attributes_may_read_gfn(kvm, gfn))
> + return -EFAULT;
> +
> r = __copy_from_user(data, (void __user *)addr + offset, len);
> if (r)
> return -EFAULT;
Since the emulate kvm_fetch_guest_virt() path ends up calling this, probably
somewhere the execute attribute needs to be checked too. I don't know how much
of a concern it is in practice.