Messages in this thread | | | Date | Thu, 26 May 2022 08:33:03 -0700 | From | Kees Cook <> | Subject | Re: [PATCH 1/4] KVM: x86: Grab regs_dirty in local 'unsigned long' |
| |
On Wed, May 25, 2022 at 10:26:01PM +0000, Sean Christopherson wrote: > Capture ctxt->regs_dirty in a local 'unsigned long' instead of casting > ctxt->regs_dirty to an 'unsigned long *' for use in for_each_set_bit(). > The bitops helpers really do read the entire 'unsigned long', even though > the walking of the read value is capped at the specified size. I.e. KVM > is reading memory beyond ctxt->regs_dirty. Functionally it's not an > issue because regs_dirty is in the middle of x86_emulate_ctxt, i.e. KVM > is just reading its own memory, but relying on that coincidence is gross > and unsafe.
Right; there have bean a handful of other bitops-using-stuff-cast-to-ulong that has been recently fixed elsewhere. Better to get them all squashed. :)
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
-- Kees Cook
| |