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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67222fe0-7bf0-ec7a-0791-a4d48391a15e@redhat.com>
Date:   Fri, 29 Apr 2022 16:45:03 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Mingwei Zhang <mizhang@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86/mmu: fix potential races when walking host page
 table

On 4/29/22 16:35, Sean Christopherson wrote:
> On Fri, Apr 29, 2022, Paolo Bonzini wrote:
>>> +out:
>>> +	local_irq_restore(flags);
>>> +	return level;
>>> +}
>>> +EXPORT_SYMBOL_GPL(kvm_lookup_address_level_in_mm);
>>
>> Exporting is not needed.
>>
>> Thanks for writing the walk code though.  I'll adapt it and integrate the
>> patch.
> 
> But why are we fixing this only in KVM?  I liked the idea of stealing perf's
> implementation because it was a seemlingly perfect fit and wouldn't introduce
> new code (ignoring wrappers, etc...).
> 
> We _know_ that at least one subsystem is misusing lookup_address_in_pgd() and
> given that its wrappers are exported, I highly doubt KVM is the only offender.
> It really feels like we're passing the buck here by burying the fix in KVM.

There are two ways to do it:

* having a generic function in mm/.  The main issue there is the lack of 
a PG_LEVEL_{P4D,PUD,PMD,PTE} enum at the mm/ level.  We could use 
(ctz(x) - 12) / 9 to go from size to level, but it's ugly and there 
could be architectures with heterogeneous page table sizes.

* having a generic function in arch/x86/.  In this case KVM seems to be 
the odd one that doesn't need the PTE.  For example vc_slow_virt_to_phys 
needs the PTE, and needs the size rather than the "level" per se.

So for now I punted, while keeping open the door for moving code from 
arch/x86/kvm/ to mm/ if anyone else (even other KVM ports) need the same 
logic.

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ