Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2269994pxb; Mon, 11 Jan 2021 05:40:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9piGLm+OgIYab4F4STLyv79lDm+7liJRM+LCJxxjf2MPahqMAYA5eOglc+F/AU5FzpcdW X-Received: by 2002:a17:906:ae0c:: with SMTP id le12mr10847506ejb.283.1610372412948; Mon, 11 Jan 2021 05:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372412; cv=none; d=google.com; s=arc-20160816; b=jPN3cr3UGyRAV9x7qaeLjhh7OPCAD4KDdh+9d9fUeg8gKINfZLiyUAz5JJWmloFFZI v5oTsY/zWos/XG0P5L3uVtGWw7tB/87cYu6vYJVPmaIsZXAelN23kdIBpCdQyrBYIfgL d75ASyRNHZ7/XEA7Jat/ZLisuG1SMMofFycvE0Q9xxFV9WnP0nbxHxNXPyGhPwMwYIX7 hpeKrttjaXu43ASuSz3eWOMWvoly5LH938IgoItJ3GH+PYAMmRPBUnyFFoq/XwjBLh2l qiQqR/hs82i2HTE+iX7NfjXE/q/4hcpohRkZjOdHBfMxkPIVZ2+zIkgnHUcZTOMOk9EL vGCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wnDauEfI3uFZ8mZoQ5kNlk1H2UPEWX/B8aMtuamsH7o=; b=Xm/tq7Oc47At2gyEquiDi5nyQCW81l7T7YXO0wovzGRTYzFB1dM+PXmwODLKw2Qx7X cI1lDus+2dm6DD02S44DmBzEWwcyPvssXE1OpbDVxdqcw2ghy6fXCMOh8QhtxP185JqQ /4DKsKZHgO5dy+xRGdmGurHLxY/L4OrQCKp28AUIaqT4UP1IZzaF3Q8I1QtpKzJ4IBjj 9NACVDWbpaOigw/l75QZX5qq5M81tUWxpTv7nD98UGZjyPFLCWKR5UrtnElF0pSI7U4q LXJ4SqxeupTVtNckQmRkbObdHpg4bccVDGNWYaBkAJQMj8TvUeGwCTt/kf5rG27tAzwg FB2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uQoXbmo1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox13si6665798ejb.70.2021.01.11.05.39.47; Mon, 11 Jan 2021 05:40:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uQoXbmo1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731819AbhAKNgd (ORCPT + 99 others); Mon, 11 Jan 2021 08:36:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:60540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731962AbhAKNNk (ORCPT ); Mon, 11 Jan 2021 08:13:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A9ABB229CA; Mon, 11 Jan 2021 13:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370779; bh=NMxXDtc8MfsJkBGWXGqageMRuBuHhgOkitW4IGQVKo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uQoXbmo1IBKvgJLIKELPo99kEZ4MFU/h2CU7zVTESAM12fvwRNmlyeKZt5n8Y4eG8 7U4v/3Zmpfii88cEn863n2NMC0jNDlRp6EDpe+refojxF6wYuaJHHLUYtgnnPK8Km6 +dnZXVKJrBFXbL+bekIGdEsU+jjb+rymI4ozMAx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e87846c48bf72bc85311@syzkaller.appspotmail.com, Paolo Bonzini Subject: [PATCH 5.4 92/92] KVM: x86: fix shift out of bounds reported by UBSAN Date: Mon, 11 Jan 2021 14:02:36 +0100 Message-Id: <20210111130043.591744897@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Bonzini 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -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);