Re: [PATCH 1/3] KVM: x86: Fix out-of-bounds access in kvm_recalculate_phys_map()

Sean Christopherson
2023-05-26T22:27:18Z

On Fri, May 26, 2023, Michal Luczaj wrote:
> On 5/26/23 18:17, Sean Christopherson wrote:
> > On Fri, May 26, 2023, Michal Luczaj wrote:
> >> Maybe it's not important, but what about moving xapic_id_mismatch
> >> (re)initialization after "retry:"?
> >
> > Oof, good catch. I think it makes sense to move max_id (re)initialization too,
> > even though I can't imagine it would matter in practice.
>
> Right, I forgot that max APIC ID can decrease along the way.

Actually, we don't want to reset max_id. That would allow userspace or the guest
to put KVM into an infinite loop, e.g. by toggling the APIC of the vCPU with the
highest x2APIC ID between enabled and disabled. The downside of not shrinking the
size is quite negligible.