Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp693736pxv; Thu, 22 Jul 2021 09:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdQZJ+IeyJwiq2Oj184tQU6ZABAB9Sl/vD7IyZyB+lhgM6pWc0z2mmTYIkJ4dc+hAMIA9E X-Received: by 2002:a05:6402:312e:: with SMTP id dd14mr660737edb.33.1626972737751; Thu, 22 Jul 2021 09:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972737; cv=none; d=google.com; s=arc-20160816; b=NGZp5EGYbQRhQfmiyKflfeP7rHFV3FginqC2NPcXezyZ03KO5hjyAtEGb/SOp/Ojzr NJbAPnUaLNXFb1BdVj3vpZWlelegm4IyOmykvv9GQ4Me/4Ij9N5bkVkXd7QEYwFQrKkP /cWFuF4KiNZJjnKxoNmGfwMy46B/1/sI/1K8t+ncelDSpL0ENPt7aSNpAU5m6gJvWp6+ n8hFJjI3jDfcOyVg3TXehM5JgHF5PPKyZcsa9d+7RYc5tre9htEmYDDJ8OR56by8hx4T tXugT0fO/tmEGzMJ5Y4qNE/YAMIxiCL22uaq17oV+i4B09eg5FZDsCwfzvvH+ERh/ZLc dIRw== 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=zjqrBki4bOlnTvqLYRvZQ8TTEDdqmnzyo+Rco70Z7c4=; b=DQPhWwYXUunttKLKn0PtcBIwd9jVNm3pkVy8H2qbwS3rvmi/MMQr5Q3akubRxIZmnW ifkZ+IOHxKlY0deAmcH+mpiYfKP7ZJklw8bE8smt5E2PP5dqZgmyBYV9qpYL8jgNXZYZ oijxNmcSPPQMLqTxM3p3jn5MF1flEBUjMvCRoDdyXW/eQIqpJwT5AM3TNlCAREP+m5m1 yyiPnJaxbkrAv2BBszZ4vXR/l6CDqEQaETmAxOwJ2a/ziz2pf7hEESXSwdMrzSD/DPId KVg4l/KztsPShHU0Pn9Jzomex430VBeJLLvy1z26+inQPdrIxurZ1ddOrz2OCNyDox+e ZfaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GSOGeH1Q; 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 g21si6134368eje.404.2021.07.22.09.51.54; Thu, 22 Jul 2021 09:52:17 -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=GSOGeH1Q; 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 S235384AbhGVQJO (ORCPT + 99 others); Thu, 22 Jul 2021 12:09:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:43382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233418AbhGVQFl (ORCPT ); Thu, 22 Jul 2021 12:05:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFBAB61D10; Thu, 22 Jul 2021 16:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626972376; bh=jWSKzkJ1vsphKuArPC7UbEpDSmeIB1msXfkM5MF16iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSOGeH1Qio79iccIXpCK41nhW75fYwO14/K+HTHXmURMvHTyqV2jod2jvWCcDITq2 kHsALRRnBHFROS7gETDZ4Ua5KqoHKevY5oowUM/9nzFyOGoz7Ze5dYGUl21/lGlPlW rfeF9gDs0GtL9g+yJVhAx1duE/zoCxg/moT90ugg= 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 5.13 091/156] scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 Date: Thu, 22 Jul 2021 18:31:06 +0200 Message-Id: <20210722155631.323355203@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155628.371356843@linuxfoundation.org> References: <20210722155628.371356843@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 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.30.2