Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3868124pxj; Mon, 21 Jun 2021 08:18:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5n5UAv39h1JcEjSdCokWvhUV12VOxRZos6aKYoQQLzHVXTfWA08w1cnvn4X5OyrwxmJRX X-Received: by 2002:a92:4a02:: with SMTP id m2mr14540579ilf.58.1624288717590; Mon, 21 Jun 2021 08:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624288717; cv=none; d=google.com; s=arc-20160816; b=R72Nuc58lxNxqbuOasueSB9b0KYuTsq8Zwvj1wSI8fVv6hGbgIYpSdammpw7sYHcY+ bRtuUlRGZfi6Wqtp8l/RO9OOK24MjfRLMuu/3qXENgXw50TWCuQz3GSPRXl+ybi87E6r naLbN5tppWmKEthavPsUUZVo2AToCpQsSxULMaxOc6csztp3h41TY7fSN23FbWeYVW+6 ZHkg4PruT/fd9sEVLi1mIIP7tdXGYoMMn4i6P8IuWZz9oujDLoDTBjRd94ohL+lPmBn9 fgstiScWSnhp+YNs9lQqfhczRSDbTXZ61ohoWeSbfkRobPpfAqbRX+YKf7mMmwtEqasf qLEQ== 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 :message-id:date:subject:cc:to:from; bh=TUnMrU58/phmp1hi7uSq/mzrTbVXHlLFIwbheKOSd48=; b=txZgS2/SAVmxl8gLvWTxO4eFl6OOyxBRP57cdA143QLaFuaaaYD73+QgkbgfszqSv9 zHYZS+BLiYm36eq6cOfRQPJMmzjXDQccMl4H30baRXx7JhYW67Q1SWUSVxhREBC9jY8U sZ9T+ocgCcl4Guy+bAUpQY1a3yO5bJOwHiaC9Xtlk2zKKY+186TFkOrB3ySH722webNr APkwOhNE8PtZcs0Y1FuGbpq68+xqSNb23EQahf6wi550hcLn0Gv97BAgBp/SghxpEwa3 DZBglJr7vS8gDUf1ccxJD+NTNmq6uoNvQ3OyIiezDHy1Z4IobiDAXI824EA6tn4H5Gpc ofaA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si14030566ilj.6.2021.06.21.08.18.16; Mon, 21 Jun 2021 08:18:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhFUPTs (ORCPT + 99 others); Mon, 21 Jun 2021 11:19:48 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:50788 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbhFUPTp (ORCPT ); Mon, 21 Jun 2021 11:19:45 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lvLfz-0001Of-OX; Mon, 21 Jun 2021 15:17:27 +0000 From: Colin King To: Hannes Reinecke , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 Date: Mon, 21 Jun 2021 16:17:27 +0100 Message-Id: <20210621151727.20667-1-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 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 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...") ] Addresses-Coverity: ("Unintended sign extension") Signed-off-by: Colin Ian King --- 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 4b04ab8908f8..a396f048a031 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -493,7 +493,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.31.1