Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp685113pxv; Thu, 22 Jul 2021 09:41:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzSEKjsHhm9O3+LO9mEVa+8AUYpQ6KYhjGGmilMVy8uOoeyeyHterUHBvZB57k/KT2zVIV X-Received: by 2002:a02:7348:: with SMTP id a8mr392120jae.116.1626972107711; Thu, 22 Jul 2021 09:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972107; cv=none; d=google.com; s=arc-20160816; b=eL9J79hGaLZdofQleFmkQ5Oo4SMVzuE3awJVt2aUcKP6aIUOJ04GFCY2PM+tfUu8NI Ib7sr9JgfhukWdheOLoRiQu9gSFYjSF8qAe8CCaDVtEGQKTRmD+CCGh4zNaQ1w4vB0cM kWynM9C0sIUedmsT+kjPdx44DbO6bHkbXxz9QikrAJ48YHNAl2MVJvjgB3Jc0EHGG8kQ FQT4aFX9QoMY7bdPRNzykoIru4z2ZT7zT8qVqUSAym61RDg7JLfAW0vwKhh83OS/NVJn v/5WCCkOzCKeq/q+q2C1n7tq/xK2ju2hpkXBYdpkLLN2tinDOIeoJ/2afMf+Bwo7jkD3 I39w== 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=ewaI4gVhOkvTOEXKeHW2Xwrggh3ZVp3G5DdsvT+sips=; b=gvAaNYUKIw3IemwkeSvRILadP7lczt9YIApG+wZRJPep+877VDfPFdY5ixL6FaOPeh jUICpKm9IUyiiTYIMAJuFA+w015VYNg3jJIL+2QRZEYzLAUAS/x0ezvDEu7/ABdEIqcf D0DnBGN2YsN9oDYfcFfZM6X4ihDEs+U8kmWRTf75h/tYVEtdWAWmJiUlp5mhEseZi5dS o/fFkJXp/EXw7oe0q82YSf2DeaGonrE/oRwkB1YRny0us/iOIL0PKKdSqdGH5MBHrNJV IURJrJi+rijjlgz92IQPccStlqokII7oBOa/azyaw3I9lOcaD70306YPAEFOqP1b09ez zAcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yJc7qnjA; 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 h2si31379786ils.86.2021.07.22.09.41.35; Thu, 22 Jul 2021 09:41: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=yJc7qnjA; 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 S233264AbhGVQAB (ORCPT + 99 others); Thu, 22 Jul 2021 12:00:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:34698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232960AbhGVP5x (ORCPT ); Thu, 22 Jul 2021 11:57:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF14261378; Thu, 22 Jul 2021 16:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626971908; bh=3nQWxeAB87beCZKNA4PKkDHoR1yS12Zk9pLhwBjaa5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yJc7qnjALebZSabnKboaVM299aCFIrDQeZiAolNde/WbdJYkRvFqoUB7XiqPJp6gT b7et3HpoC6lchfH61C7uors6X7wAd3njILV7SlsR2bkb3qtQdbYLjat69PFeStAhkY L0JRV4nwaW/aLO7p0amahD0WiEfXpA5ZjGGJfe8U= 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.10 071/125] scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 Date: Thu, 22 Jul 2021 18:31:02 +0200 Message-Id: <20210722155627.044005265@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155624.672583740@linuxfoundation.org> References: <20210722155624.672583740@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 725bb7f58054..12fed15dec66 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