Only architecturally defined exceptions in the range [0, 31] may have error codes. The caller to x86_exception_has_error_code() should ensure that the vector operand is in the range [0, 31]. Note that the one existing call site already does the right thing. Cc: Marc Orr <marcorr@xxxxxxxxxx> Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx> --- arch/x86/kvm/x86.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 224cd0a47568..88dae0225a92 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -116,6 +116,8 @@ static inline bool x86_exception_has_error_code(unsigned int vector) BIT(NP_VECTOR) | BIT(SS_VECTOR) | BIT(GP_VECTOR) | BIT(PF_VECTOR) | BIT(AC_VECTOR); + if (WARN_ONCE(vector >= 32, "vector 0x%x too large", vector)) + return false; return (1U << vector) & exception_has_error_code; } -- 2.19.1.568.g152ad8e336-goog