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@xxxxxxxxxx> Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx> -- Kees Cook