Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3707398pxv; Mon, 26 Jul 2021 09:54:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBpGTaiBFNdm9cIPN1G2SgMMV7ZmNRcOmXtF9Wl6EP7UWnwF0flz0jcU6u5VDUU2Mnrw+M X-Received: by 2002:a05:6e02:b4a:: with SMTP id f10mr14061598ilu.280.1627318446465; Mon, 26 Jul 2021 09:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318446; cv=none; d=google.com; s=arc-20160816; b=rMVZ8ffku5P9JtwIqB12/AYH3msXFBsXZ5ISnZetRCyzJFK+WBWBwsspbhOczbQ1X4 TGX/+cyTEob2otInmBKGcUPPgdg6F36b4xkCGhshWXCldS6L+PZGUm1CYQl1DnTwb2pV h4lJYFyZLd+mWqk7OgQp07iuNGwKoScM5ZWI/nmsj/uZBSV+dHt1A3c6XroNgaEEKu8f B89NVY2JyAjJq+RKRClBO1jYYROqO/xZspsVKMS+CIeDTKda/Nv8moJYaaInx2F5Faij zQncMdKBbb2v6t244i6lLZuN//8yQl5JGiEqEmMPXJwe6JGbDiCNGf0sTcucYPf/uBr3 HBwg== 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=Op8RM3NJA6BPiRcw+Xj5Dguc5h0wYrkxmEOliH5g+w8=; b=VPASzdSo6bEy0u4qIJ+kV6c5qsKCZBpgtPJRSPAbGPMjSAnxa/a/bK2dgznKVmzKFN nfsU+wNQuXnLFzCU9kGOkdP94YrqasV1bubPnH76/lxWZe6R6MKMmIlhC9FxHIwfRPVH ovZPBH20fFK/NiCggS/ysyX2LxZc+Er4sZefOi2raWlghMyUsQ/jAvRNxdKqnqjBQeHd Gv6p/DO4Y+nYCgghVSuMfSnWPumHsDV9sLFc5xGK9kJYrzGbe14iha5e86OxASstrXvG oNfKcX1RzLOLcDNAPe/BAftCncVROoYVLpPb+FlQ7twmlzUugfuRLfaOZRphCP8TDUOi M5vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KfD0LVuq; 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 f17si444673ion.28.2021.07.26.09.53.54; Mon, 26 Jul 2021 09:54:06 -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=KfD0LVuq; 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 S237077AbhGZPUy (ORCPT + 99 others); Mon, 26 Jul 2021 11:20:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:51578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236352AbhGZPLC (ORCPT ); Mon, 26 Jul 2021 11:11:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D45860F44; Mon, 26 Jul 2021 15:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314691; bh=WbcAoORSEo3xrjNUt8TS+8PA0uazBmuXqcBbv3NVmi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KfD0LVuqpSNDAkPaaeB6d7yq1GeAJJqhLg4ZOlATGcVydoUU/GxGhJ5uns88aMnA/ geJselLsiDq6PiohK0pV3yWSetTqNsWG7bnFhLuPbEoBSjrDBQKvgZ4mbqv7pH/Cvo Fs+gmVWLOjBrRmWKdeCibsJsG+ylpxgMgcrffbmc= 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.19 030/120] scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 Date: Mon, 26 Jul 2021 17:38:02 +0200 Message-Id: <20210726153833.360530713@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153832.339431936@linuxfoundation.org> References: <20210726153832.339431936@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 49e02e874553..fe15746af520 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