diff mbox series

[2/2] arm64: KVM: prevent overflow in inject_abt64

Message ID 20240909103828.16699-3-abelova@astralinux.ru (mailing list archive)
State New, archived
Headers show
Series arm64: KVM: prevent overflow in inject_abt64 | expand

Commit Message

Anastasia Belova Sept. 9, 2024, 10:38 a.m. UTC
ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT = 0x24 << 26.
This operation's result is int with 1 in 32th bit.
While casting this value into u64 (esr is u64) 1
fills 32 highest bits.

Add explicit casting to prevent it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e4fe9e7dc382 ("kvm: arm64: Fix EC field in inject_abt64")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 arch/arm64/kvm/inject_fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c
index b6b2cfff6629..6cb191b799ac 100644
--- a/arch/arm64/kvm/inject_fault.c
+++ b/arch/arm64/kvm/inject_fault.c
@@ -79,7 +79,7 @@  static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr
 		esr |= ((u64)ESR_ELx_EC_IABT_CUR << ESR_ELx_EC_SHIFT);
 
 	if (!is_iabt)
-		esr |= ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT;
+		esr |= (u64)ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT;
 
 	esr |= ESR_ELx_FSC_EXTABT;