KVM: x86: fix shift out of bounds reported by UBSAN
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 22 Dec 2020 10:20:43 +0000 (05:20 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jan 2021 19:18:26 +0000 (20:18 +0100)
commit563135ec664ffb80a2297e94d618b04b228a1262
tree439f09818e2850b0cba3d138657820802ff0f21c
parent02ccda90ef7e23a225b68789bce9e8353f9caa1f
KVM: x86: fix shift out of bounds reported by UBSAN

commit 2f80d502d627f30257ba7e3655e71c373b7d1a5a 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>
arch/x86/kvm/mmu.h