lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d5f528c2-3518-4251-a50b-2d1f36c1662e@intel.com>
Date: Thu, 12 Jun 2025 13:41:30 +0800
From: Xiaoyao Li <xiaoyao.li@...el.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org, seanjc@...gle.com,
 yan.y.zhao@...el.com
Subject: Re: [PATCH] KVM: x86/mmu: Reject direct bits in gpa passed to
 KVM_PRE_FAULT_MEMORY

On 6/12/2025 1:34 PM, Paolo Bonzini wrote:
> On Thu, Jun 12, 2025 at 7:29 AM Xiaoyao Li <xiaoyao.li@...el.com> wrote:
>>
>> On 6/12/2025 12:49 PM, Paolo Bonzini wrote:
>>> Only let userspace pass the same addresses that were used in KVM_SET_USER_MEMORY_REGION
>>> (or KVM_SET_USER_MEMORY_REGION2); gpas in the the upper half of the address space
>>> are an implementation detail of TDX and KVM.
>>>
>>> Extracted from a patch by Sean Christopherson <seanjc@...gle.com>.
>>>
>>> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
>>> ---
>>>    arch/x86/kvm/mmu/mmu.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
>>> index a4040578b537..4e06e2e89a8f 100644
>>> --- a/arch/x86/kvm/mmu/mmu.c
>>> +++ b/arch/x86/kvm/mmu/mmu.c
>>> @@ -4903,6 +4903,9 @@ long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
>>>        if (!vcpu->kvm->arch.pre_fault_allowed)
>>>                return -EOPNOTSUPP;
>>>
>>> +     if (kvm_is_gfn_alias(vcpu->kvm, gpa_to_gfn(range->gpa)))
>>> +             return -EINVAL;
>>
>> Do we need to worry about the case (range->gpa + range->size) becomes alias?
> 
> No, because the function only processes a single page and everything
> in the non-aliased part of the address space *can* be prefaulted.
> 
> KVM's generic kvm_vcpu_pre_fault_memory() call will see the EINVAL on
> a later invocation and will stop processing the part of the request
> that is has the shared/direct bit set.

reasonable..

Reviewed-by: Xiaoyao Li <xiaoyao.li@...el.com>

> Paolo
> 
>>
>>>        /*
>>>         * reload is efficient when called repeatedly, so we can do it on
>>>         * every iteration.
>>
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ