Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp396990pxk; Fri, 11 Sep 2020 09:48:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4veyT+ZLzVBAEUlvOKrRPOTzZaMwPBOq8/T7KBv2SybW7WS96OiB+esX/+8UpjA5QeZ2V X-Received: by 2002:a17:906:7102:: with SMTP id x2mr2886105ejj.260.1599842906163; Fri, 11 Sep 2020 09:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599842906; cv=none; d=google.com; s=arc-20160816; b=ip8kArdTEjwN3bKRTv5XPbKtSbFpfvzjt9b7cjPWhFZfTAdy30Fk4psV0C1tQSAQPL SftfBQLUz59wqz3NEXZ1p8diaSwkUprsdBRFydPiMYRrswTLDNrK7AfeikOuLB94iSsr IVDDfyBUSpeAdy9InsDoPQPsQVU5ol+Itq3OPwisLwHgXITdBk0my5owgD1WZhOXqfZo zVijKfyN1jwVtwreDcUYRFPfAQFwpCBuVdkGAdSIPf3CBDGi/2VGbW08xzTT3foQ/JrA 0VU+fjcfrrNA41n7EXgBIwDZ/e0Qwkbgx36pVBsCV9YE9dKbBZ5ERmMi8wugahPc+gcV WnGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fKH62RHsQPufwfeHyLjH4/dIZ+1Euvv6ymhhbfJcy7I=; b=FOifhJV5MNoYT5Hkh6epIM/Ra+PP7g+aZdKcLKYrN9b6iS9NQkIjjIMJ63wjYExyuz B6Q6HLkRJjiI7kk/qlLoF+/mliOwvqvEsxtUEqHcTRRnrplv0wZhD8do6H4f+k/2oK66 4/IwhBmR9L2nyX3sYl1EHIPgOZInHyvWDpaqFOy8Ivi46CqjClTW6NGW4MBRyls0nycq cBNxgOgYLuANXtC5oMM+q22LlT7AYII5ARJZratCZm4WfjC1DiFGlfT9/20SRbzDfpK9 Gh4MODG4PQgUTD4IqdTZKFQrOayixQYTRhXOEGov8i+on4d9u0U1wC03zYO5c84x/UR/ Zk3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hycLCDxu; 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=fail (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 j20si1701907edt.233.2020.09.11.09.48.03; Fri, 11 Sep 2020 09:48:26 -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=@kernel.org header.s=default header.b=hycLCDxu; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726432AbgIKQrW (ORCPT + 99 others); Fri, 11 Sep 2020 12:47:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbgIKPIE (ORCPT ); Fri, 11 Sep 2020 11:08:04 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30122223C6; Fri, 11 Sep 2020 12:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829117; bh=4Xk5YfXF6sqYijZ5aWjpFFEN3fF6lqguy/KbKh6p48k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hycLCDxuMJV15lE9re3Ios9fis84chndcLYUTiNbw5WPP+fi9upjqeL/R79LodMaY bmxVSC+FFEHVvHB1mkwhpcp4udll22qy8X0770ese3OIgNFz20HO9NZgRVhdO7KDAn XzwEBnOHremxgm9FxaiMeKE/6fiE3iRQbcDhbp54= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shung-Hsi Yu , "David S. Miller" Subject: [PATCH 4.9 66/71] net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init() Date: Fri, 11 Sep 2020 14:46:50 +0200 Message-Id: <20200911122508.228000858@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shung-Hsi Yu commit cbedcb044e9cc4e14bbe6658111224bb923094f4 upstream. On machines with much memory (> 2 TByte) and log_mtts_per_seg == 0, a max_order of 31 will be passed to mlx_buddy_init(), which results in s = BITS_TO_LONGS(1 << 31) becoming a negative value, leading to kvmalloc_array() failure when it is converted to size_t. mlx4_core 0000:b1:00.0: Failed to initialize memory region table, aborting mlx4_core: probe of 0000:b1:00.0 failed with error -12 Fix this issue by changing the left shifting operand from a signed literal to an unsigned one. Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters") Signed-off-by: Shung-Hsi Yu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx4/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -114,7 +114,7 @@ static int mlx4_buddy_init(struct mlx4_b goto err_out; for (i = 0; i <= buddy->max_order; ++i) { - s = BITS_TO_LONGS(1 << (buddy->max_order - i)); + s = BITS_TO_LONGS(1UL << (buddy->max_order - i)); buddy->bits[i] = kcalloc(s, sizeof (long), GFP_KERNEL | __GFP_NOWARN); if (!buddy->bits[i]) { buddy->bits[i] = vzalloc(s * sizeof(long));