Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4184239pxk; Tue, 8 Sep 2020 12:54:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKQdaqXM7rRwx0EDoYBkufsqwrz3+UjdVDZ6p5dHgPI++pr1pvheHfLS15Cjdw1qv+KMt0 X-Received: by 2002:a17:906:375a:: with SMTP id e26mr82048ejc.552.1599594865091; Tue, 08 Sep 2020 12:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599594865; cv=none; d=google.com; s=arc-20160816; b=GuoYAMe2WbtT6Nhy91nJiIfDekULm776g3R1Wc50qcsGpQRV4Fup9j4rmvpUAWQQI4 kY5j8rUDkNf7N1WDZ6Lsnj+Z+75EQRbwHfTxKjpVemcxDJetXF3gxckYHLxEJDuhQKyI ewe5OKzho6p9gIKTSzYT4saOMErqjISUWggOsLAsXMOmD9Mfvlrd0IoKUJtW+N0xO7Ln 8nS8kgTWOBU4kzQxR/yZ0MGM0Qqtnjyji8aFhRSngI6AQsVd9IeHQCJmzo+k97AzE1ld qfa35EGnOe2rWO1pCGUYRrI9+1vt2W9ndnrcj6BDp3fFGOmz+E7N6oeO+VyC8jfTRoyB OGPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=iq8hTv0QHExl3ILdcz9EazEVkoXgy3wjircPnAa7Kjo=; b=eHHmRDrchoOfKV8U8f8mD0K3WCafvjENCG5ArBmdV/aIwxmzzLizZij/jtGR2HPjrT cIrB5udYR+cwIJUDTco3S4bZlhwtjv5ohQHzdwjjlNzLoietwnVR+B2ZX7zr3NyMVxyN fdy1UV/j6/jCvjcTzUKWbIQ3nHV1hJBed60ECLOa9LMdHe4Z9jpfS/hel/IUSxVuhkET u/noczVtfLAbvpMSdzMKT0Fb6YkR6LZ1GHINse0QsFLus52QMHNsvDoHqgq5D8FDZymS WtZARs+XjIJnSbFCG74sw//3kjXr2Ukf+lNXBM9X3qd9qJOpxZcBPNSBqF0zUFYWuKo6 InVw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si29080ejd.405.2020.09.08.12.54.02; Tue, 08 Sep 2020 12:54:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732447AbgIHTxY (ORCPT + 99 others); Tue, 8 Sep 2020 15:53:24 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:46598 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730662AbgIHTxR (ORCPT ); Tue, 8 Sep 2020 15:53:17 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 9157E1C0B87; Tue, 8 Sep 2020 21:53:11 +0200 (CEST) Date: Tue, 8 Sep 2020 21:53:11 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Shung-Hsi Yu , "David S. Miller" , Sasha Levin Subject: Re: [PATCH 4.19 41/88] net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init() Message-ID: <20200908195311.GC6758@duo.ucw.cz> References: <20200908152221.082184905@linuxfoundation.org> <20200908152223.178555420@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UPT3ojh+0CqEDtpF" Content-Disposition: inline In-Reply-To: <20200908152223.178555420@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --UPT3ojh+0CqEDtpF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > On machines with much memory (> 2 TByte) and log_mtts_per_seg =3D=3D 0, a > max_order of 31 will be passed to mlx_buddy_init(), which results in > s =3D BITS_TO_LONGS(1 << 31) becoming a negative value, leading to > kvmalloc_array() failure when it is converted to size_t. >=20 > mlx4_core 0000:b1:00.0: Failed to initialize memory region table, abort= ing > mlx4_core: probe of 0000:b1:00.0 failed with error -12 >=20 > Fix this issue by changing the left shifting operand from a signed litera= l to > an unsigned one. Will we still have problems with > 4 TByte machines? Should the computation be done in u64? Best regards, Pavel > 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: Sasha Levin > +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c > @@ -114,7 +114,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, = int max_order) > goto err_out; > =20 > for (i =3D 0; i <=3D buddy->max_order; ++i) { > - s =3D BITS_TO_LONGS(1 << (buddy->max_order - i)); > + s =3D BITS_TO_LONGS(1UL << (buddy->max_order - i)); > buddy->bits[i] =3D kvmalloc_array(s, sizeof(long), GFP_KERNEL | __GFP_= ZERO); > if (!buddy->bits[i]) > goto err_out_free; --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --UPT3ojh+0CqEDtpF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCX1fhJwAKCRAw5/Bqldv6 8rSiAJ0SDlKpMvw+OEk/HI9lrjlcK2+O6wCguY0eWqm2yogCIc5Ym9GDPYo7I2k= =xI+r -----END PGP SIGNATURE----- --UPT3ojh+0CqEDtpF--