Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3652508pxv; Mon, 26 Jul 2021 08:46:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4O9ghZJxytTuwe6T9isIaTFLLRxSuFQrKsFwUgf8s3jx/xGUky2Kgq72d18PKm2Qx+ojR X-Received: by 2002:a17:906:839a:: with SMTP id p26mr4966561ejx.547.1627314407565; Mon, 26 Jul 2021 08:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627314407; cv=none; d=google.com; s=arc-20160816; b=tzkrWFYplH1zS/lnoszzys6ljdhRQrF2Oi/Ka/7yyyswn/QSYt5WDRkkam6j+PA3Se pLHj0qdXgxV6PBqIIkcGPCBOlhWTDBY7COHeZHXLWwfzDczOSMmtB0xB+9UMRh692fuo 51pKCB3u1HS8HxAAX/8NnKo4nqvxq9bTzTTJK0k9yS9xPScLjD2Jben24+QkKVvbdTck 1mtyGCQnvHaFkYNmqYHX5CG/ZD9lGJ6h7VOGvIj1JIJTFQDCzmyVybaQjOMpwXwmJOtX 2fT4O9nHthb9J44whYplwqL8PSXg0OmUnpChMvXGqTC9ipPqHP7KN/yI2gL9XSWP/Tqx vk/w== 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=SgDyzNPHyRRWYW7PwgCsuuw66EcX7vTvICrYZyJD8aU=; b=PrfX8d6e3iF2Aof4DNmkWixOkLiqVl0yN81vItPSLDT89odQPocO8Pi77zVWvlMMCl XkbOCTzqHtWZl1LLDnqinm/sE3V/MdTDlGVDT4R0tdlp0Jp/iJzrPfaRDEiGGR7G6xha ptHnsRuwLHDcb9guB9fowvkAB2rK7Q22uKSYeOvlSGSJpwv6brASPy+NgqBIRM/Wxn1E uNkWl0x7wDzF9g1bQRIiRG6Zy1b8RfBZUTc3e7gOz91LOsXbOaQER2sE6Ud4NCs9uj5+ +7ZTx3LVqB/E8Cri7UHh2CCUGiZgat9IxcLB3Fp1KQP/ZxRACIkcky4alnjXpGunJX5Q cePA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qESf6IxE; 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 e23si220645ejj.438.2021.07.26.08.46.23; Mon, 26 Jul 2021 08:46:47 -0700 (PDT) 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=qESf6IxE; 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 S235369AbhGZPDW (ORCPT + 99 others); Mon, 26 Jul 2021 11:03:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:41968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235582AbhGZPC2 (ORCPT ); Mon, 26 Jul 2021 11:02:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 92CA960F37; Mon, 26 Jul 2021 15:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314177; bh=EOn9u7CR6/zKn+iKpJ5wP4mwdhdoEP+PkurRyOi8y00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qESf6IxEla2hd4jBFo+PL0W3U/BqAT6Ggx7qXatOP6zb7IS2lU387Nj0Vr7lA3e/B cRRpQm2frLH0fGBAfHQZx/5PMLdJcGYIwuMOPNNZoPBs6HHmKBatVf7+mUTeobz1Ty Vt+cCLLa7FPbyK6+Mus73YDsU6CPG3fd+aw/9HJc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 13/60] scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 Date: Mon, 26 Jul 2021 17:38:27 +0200 Message-Id: <20210726153825.285737873@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153824.868160836@linuxfoundation.org> References: <20210726153824.868160836@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: Colin Ian King [ Upstream commit 332a9dd1d86f1e7203fc7f0fd7e82f0b304200fe ] The shifting of the u8 integer returned fom ahc_inb(ahc, port+3) by 24 bits to the left will be promoted to a 32 bit signed int and then sign-extended to a u64. In the event that the top bit of the u8 is set then all then all the upper 32 bits of the u64 end up as also being set because of the sign-extension. Fix this by casting the u8 values to a u64 before the 24 bit left shift. [ This dates back to 2002, I found the offending commit from the git history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git, commit f58eb66c0b0a ("Update aic7xxx driver to 6.2.10...") ] Link: https://lore.kernel.org/r/20210621151727.20667-1-colin.king@canonical.com Signed-off-by: Colin Ian King Signed-off-by: Martin K. Petersen Addresses-Coverity: ("Unintended sign extension") Signed-off-by: Sasha Levin --- drivers/scsi/aic7xxx/aic7xxx_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index def3208dd290..9b5832b46dec 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -500,7 +500,7 @@ ahc_inq(struct ahc_softc *ahc, u_int port) return ((ahc_inb(ahc, port)) | (ahc_inb(ahc, port+1) << 8) | (ahc_inb(ahc, port+2) << 16) - | (ahc_inb(ahc, port+3) << 24) + | (((uint64_t)ahc_inb(ahc, port+3)) << 24) | (((uint64_t)ahc_inb(ahc, port+4)) << 32) | (((uint64_t)ahc_inb(ahc, port+5)) << 40) | (((uint64_t)ahc_inb(ahc, port+6)) << 48) -- 2.30.2