Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp449879iog; Mon, 13 Jun 2022 06:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMpMFgDUySHK7u/vni3wxj/WKQr2AyZXgtBa7e/67CdbV1XVNlzr8IeJPsgXOWxIMGlTTi X-Received: by 2002:a63:844a:0:b0:3fc:e1a0:b80d with SMTP id k71-20020a63844a000000b003fce1a0b80dmr49059006pgd.616.1655125525654; Mon, 13 Jun 2022 06:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125525; cv=none; d=google.com; s=arc-20160816; b=M4c5OFG2ttmRQMPKfYkizmAYzyiIAScASwlAQQDgS43IGg+HiBFmWShxtkCMqKLy2l 5C+0oZU4F0FLKACcfqW09CYG6+jhU/2YpGrv+GAwxcDNXpD/ekvN/tWmEAtQb1tjCCCA +pLIpbdoEY0P8SOn00OfZhsPwu4p1XfxTeY1x1rXpJf8g4Fvr2fnwxHCru2fmrd+2ueC SlNCKnAydLzjQjbK/x4Oak7V2kXEC/tDsmeKpQag1d2Zq61U80+TSANVZP3ZUUBd4agg oWC0cWES382/KsWHKFa9ZrStJfdy+VSrQgXXf93KUoNKFDdKddJrwytq7In79L+RX5CB sHLQ== 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=dLZhGbNv2mN3ZxjJRrG02VIOhRL24tJFnrm+ymbvKgw=; b=oL96YQclsilylHgKyzqxqXi9vSlSyf7U2+y+3EaC8ZuX/gnyVDZjf172svM0S7aR40 qQMTX3sGG9lfkpsEhlqhIVCRIEWzkeQO4Zt+B8sl5Wz/HA+QCyW6hbEf62FRsaHxjgwK KjCFUyiQEI8dKGrbPF5LoHOXZAFnsPo4tsP+LzxQhVQ3c5QJJHGPSiHsSggCPdDJpL+4 rnAD3eOM5ljWmqN80JGm567hPljh9mEXaBOdisg2EeRoeKP2TyZWFSp4db1PMAW2fY9D YYhxHDs9ofApV8T3sQorTZdho5wIHblFH6gn9566I97UcBfSLR9m0Fc0X4A+EfxHIeGz BtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XZrB/CA3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x137-20020a63318f000000b003fcc8b0443csi10934469pgx.234.2022.06.13.06.05.06; Mon, 13 Jun 2022 06:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XZrB/CA3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1354545AbiFMLdM (ORCPT + 99 others); Mon, 13 Jun 2022 07:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354308AbiFML3T (ORCPT ); Mon, 13 Jun 2022 07:29:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E8A63EF16; Mon, 13 Jun 2022 03:43:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DEE8D60F9A; Mon, 13 Jun 2022 10:43:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE5CBC34114; Mon, 13 Jun 2022 10:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116995; bh=rxf+5mUCLVk1ZPGMwJN0/U1Zl7xVwG3EKf9U5j4w30s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZrB/CA3LBeRKQfYF0irUlJv4e1L++cKEoknE0j4z3jGwcWnAleNGYrgDs1B/w3zD TUixXk67Zz7Q49KxR+reXUeEx/n4ozQ4mzCrQqj+tKFYgmGpjYYkPgmBtTQV3M2xgv LxlRM8T4NrE0n1X0nZcVHOmRDJGh5kmXH208qj2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Marciniszyn , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 5.4 249/411] RDMA/hfi1: Fix potential integer multiplication overflow errors Date: Mon, 13 Jun 2022 12:08:42 +0200 Message-Id: <20220613094936.238950151@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dennis Dalessandro commit f93e91a0372c922c20d5bee260b0f43b4b8a1bee upstream. When multiplying of different types, an overflow is possible even when storing the result in a larger type. This is because the conversion is done after the multiplication. So arithmetic overflow and thus in incorrect value is possible. Correct an instance of this in the inter packet delay calculation. Fix by ensuring one of the operands is u64 which will promote the other to u64 as well ensuring no overflow. Cc: stable@vger.kernel.org Fixes: 7724105686e7 ("IB/hfi1: add driver files") Link: https://lore.kernel.org/r/20220520183712.48973.29855.stgit@awfm-01.cornelisnetworks.com Reviewed-by: Mike Marciniszyn Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/hfi1/init.c +++ b/drivers/infiniband/hw/hfi1/init.c @@ -543,7 +543,7 @@ void set_link_ipg(struct hfi1_pportdata u16 shift, mult; u64 src; u32 current_egress_rate; /* Mbits /sec */ - u32 max_pkt_time; + u64 max_pkt_time; /* * max_pkt_time is the maximum packet egress time in units * of the fabric clock period 1/(805 MHz).