1
0
Fork 0

KVM: x86: fix shift out of bounds reported by UBSAN

commit 2f80d502d6 upstream.

Since we know that e >= s, we can reassociate the left shift,
changing the shifted number from 1 to 2 in exchange for
decreasing the right hand side by 1.

Reported-by: syzbot+e87846c48bf72bc85311@syzkaller.appspotmail.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5.4-rM2-2.2.x-imx-squashed
Paolo Bonzini 2020-12-22 05:20:43 -05:00 committed by Greg Kroah-Hartman
parent a9d49da7ed
commit 7795afa0d7
1 changed files with 1 additions and 1 deletions

View File

@ -48,7 +48,7 @@ static inline u64 rsvd_bits(int s, int e)
if (e < s)
return 0;
return ((1ULL << (e - s + 1)) - 1) << s;
return ((2ULL << (e - s)) - 1) << s;
}
void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value, u64 access_mask);