Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3662813pxv; Mon, 26 Jul 2021 08:58:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKmkcFEcI0yomp9MdoY4OTtSkNy5EU3QfE92owVgNyXS16eA/pW1GvFvlZZN9EZ/+tpqnE X-Received: by 2002:a02:90d0:: with SMTP id c16mr17047520jag.106.1627315089937; Mon, 26 Jul 2021 08:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315089; cv=none; d=google.com; s=arc-20160816; b=pya8PBpom1zNLTNYW10k/1sAChaNVlmHyRiXnV07LH1cSmp80pyg7Szijr8W1zzQ0w Gd93VY21LJnNGQmDLX3dL8y1qm3LrLNu0UEUHEBOm9eOoZJs81xt6NIlAsgLdIe7YwOV ePVBas+4G9j1Rb9zvbjqtIkmwa4+Ys/zveRhBlfSPqo94u9tkuacjRwPsKSGej82cdoZ 57fpZSS3JesyM0loIHCqRGpykoO8RdaqPIRC2MZWuVqhyFgapm4LRcgLTZAnd1wg9lys NYURNSG/EhVQKU2ZS7N4qdb25aITjbnNzW10NOVsfNBUj4MF+sO0EF0FfW5YySn0y+gf WOdg== 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=jcYU5gk+9QvMcBSuN/19OKMkBRAYA/eK04FckxCwg0Q=; b=BoG135d13eAX8hLEDO0B+VLoduoiu5tzsAsffcJmGM6pT8kB+cHyQ24Uka43MDbprY 005WRYPSr78QzFku9rHSPiMxe3qLvyBQe9/AcUgyazfBam3XRIP8b9eiwsxMVKtrDlmt R+Vgh8DJ9MKyXe9cIpexEQUac3qUrkyQkmNgC9ui06XOG38gxBbT/wFHC90F7JRJAVzt 2arQKDRhRIc6LcJpCxLVxc7z3xX45fvsft+P3SCpFhXN0VPdkaeFFkqpQ29RjEbc3a79 dLRTa39u2qf6GbE4GKPy+kweS3rbPu6J3GZyHYhi0ypJ161Y4fHJaHF4OBk8sUCZPT9c GL/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RfRXAX2+; 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 i187si297155iof.20.2021.07.26.08.57.58; Mon, 26 Jul 2021 08:58:09 -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=RfRXAX2+; 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 S237646AbhGZPQP (ORCPT + 99 others); Mon, 26 Jul 2021 11:16:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236318AbhGZPHm (ORCPT ); Mon, 26 Jul 2021 11:07:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 228DF60F02; Mon, 26 Jul 2021 15:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314490; bh=0VNRZxuTAkaRJ2bD4WVRiPrGodwVuwGHq71wMt1He48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RfRXAX2+dnj4Ft+5m8shbcB9AfM+J3zwkPwWfT1NSB2Jq4EPBf/7UWj7LnqYw0gPa G+52AMi5iCa1YnAdwcj9RjKh5WjH5h+pXa0+XwqRCkgVdF+tpxs1qx84+J14sFrCSx ieTSN5FwELWuGcsmR8z9+SxtJRKrOh5O4DF8yduQ= 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.14 20/82] scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 Date: Mon, 26 Jul 2021 17:38:20 +0200 Message-Id: <20210726153828.814757744@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153828.144714469@linuxfoundation.org> References: <20210726153828.144714469@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 fdbb0a3dc9b4..6929aa13adc3 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