Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp693690imm; Wed, 4 Jul 2018 04:26:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcuXKO01xaEnryDJGbILIbhnkh91XQgDn25AjrGWZvvaK8zZEroTo3BpMa9qKcjKGLuoZlS X-Received: by 2002:a62:fd06:: with SMTP id p6-v6mr1738046pfh.167.1530703601509; Wed, 04 Jul 2018 04:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530703601; cv=none; d=google.com; s=arc-20160816; b=Zxhn8OV09oyuLgGB2pR81JoOPi0ejZsUKWUmUIn2uCi8wB7lS0E4gjL/MDv41bwJJH sYgDsG9cHVMcTKN+ItW+vsLb66l/Dh35ruHBfzORigl2Fcn5vZagoUjuyvjMVoCILkAR GS9qeNXAPci3Hit9QQEdjruQDDJfFEPY20FkV1YKOMTD4J7dtefubulU5dWkoVjpuZF/ et+lUlP1WF7z9Fdmx98fa9OA+a5j8Tki+oTpC5AXk5yzXQUs5PQc6CG/6kg70twcUgpa ptxOe6taxWjvSqxOTX9xgBxo5tyBv5CcDxLvDki5/TVa5FtM8oWb5ZZOK4ZUGzVc87nM eChQ== 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:dkim-signature:arc-authentication-results; bh=YmHaOUdifUoWeOI0rxdHreEsLUqjI/hK9MltdvrdlrE=; b=FSQrDCClfirWy1GRPr+HRcSLc0cTF7EPuIoJk+cu5GwGPMmlH0amtDopE96QM1svhj lU1GUVrivfo8SZzitUocQTCo02Av/ZsX2Iq3FrylCnTo1flcUfz4fhlpsZR/AJSAXxbY q/wVWpQ2iZjtASXc48uh2JRF0DXLW0OtyMJetnJ4sW9cfeHcwdG0iXEgUcYJ1ls2ule8 aZMIOWvCF7EjYUW4E823BcWMNX6i/NsfHL3DxbT6C5eghcQqKRpkZdd+gg32zxudR/FH KHwVjGKf8kD91/ezAJphmfGPTENhu6Cn/yozYv2a5m+Ui4TsPihNaEoxpAjEgP6ktF8X I3Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="E/LP7s3f"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l33-v6si3218359pgm.350.2018.07.04.04.26.26; Wed, 04 Jul 2018 04:26:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="E/LP7s3f"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933214AbeGDLZm (ORCPT + 99 others); Wed, 4 Jul 2018 07:25:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:58870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932576AbeGDLZj (ORCPT ); Wed, 4 Jul 2018 07:25:39 -0400 Received: from localhost (unknown [193.47.165.251]) (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 B1D1E208B6; Wed, 4 Jul 2018 11:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530703539; bh=TpYjtRXL1q58vFqqFI9x8XKzAnp90qSBGvz3c9Xh/6I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E/LP7s3fTTLGQNDtP1QDzO2tsOBOlPMgi3TKmd8looa/qzuLEiCCkeLut+QwM1KDK 19KiiolVaqOF/ix/jEB/xObnvCOVVD64E+WgIwsrkPFi6Q/9EtAmxSEqswrWePhFEA 6zi8pGPq3Loipub03hb7IbYtr57uRRFIks1rraAw= Date: Wed, 4 Jul 2018 14:25:36 +0300 From: Leon Romanovsky To: Tarick Bedeir Cc: Yishai Hadas , dledford@redhat.com, jgg@ziepe.ca, Eric Dumazet , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] IB/mlx4: Test port number before querying type. Message-ID: <20180704112536.GN3014@mtr-leonro.mtl.com> References: <20180702210234.107361-1-tarick@google.com> <20180703062111.GC3014@mtr-leonro.mtl.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NJSRbAqOy4NeGDns" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --NJSRbAqOy4NeGDns Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jul 03, 2018 at 07:44:25AM -0700, Tarick Bedeir wrote: > On Mon, Jul 2, 2018 at 11:21 PM Leon Romanovsky wrote: > > > > On Mon, Jul 02, 2018 at 02:02:34PM -0700, Tarick Bedeir wrote: > > > rdma_ah_find_type() can reach into ib_device->port_immutable with a > > > potentially out-of-bounds port number, so check that the port number is > > > valid first. > > > > > > Fixes: 44c58487d51a ("IB/core: Define 'ib' and 'roce' rdma_ah_attr types") > > > Signed-off-by: Tarick Bedeir > > > --- > > > drivers/infiniband/hw/mlx4/qp.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c > > > index f045491f2c14..4f1dabecf9a5 100644 > > > --- a/drivers/infiniband/hw/mlx4/qp.c > > > +++ b/drivers/infiniband/hw/mlx4/qp.c > > > @@ -4034,9 +4034,9 @@ static void to_rdma_ah_attr(struct mlx4_ib_dev *ibdev, > > > u8 port_num = path->sched_queue & 0x40 ? 2 : 1; > > > > > > memset(ah_attr, 0, sizeof(*ah_attr)); > > > - ah_attr->type = rdma_ah_find_type(&ibdev->ib_dev, port_num); > > > if (port_num == 0 || port_num > dev->caps.num_ports) > > > > Did you get any warning from any checker about out-of-bounds access? > > Indeed, I observed a KASAN warning for an out-of-bounds read in > to_rdma_ah_attr(). > > > According to the line above, port_num can be 2 or 1 which are valid ports for mlx4 > > and the check above doesn't do much. > > There are mlx4 devices with only one port. Thanks, I never saw such device, but found one on ebay :). Reviewed-by: Leon Romanovsky --NJSRbAqOy4NeGDns Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJbPK6wAAoJEORje4g2clinE/0P/1KOJLHRI5cY9hwSqHSowxGs CxY9Ll55LxDcJICOdNXHJEq4IPZ+GvKaz+d10Tg6bTTxFm87YLJDgInRQ/Qud7// QlQ4CAdILhzxk2R5+MZAfb3QQ5UIby9eF8RJiwvLTKM6B1z6pg3ZYHveM3adGNeC x0WqOxsL0fhwY7CkWy3w0d0qGJUBEUApdT4rMesh2QlszuWpfD2NjmWNRFmDZAqx O+7QuV3GLz70gEOfJMlyRZDwbLMHnK3n8XPF5aksxJ120Z1i9J1edA06zIirPQLM vjdi27Bfy6yu4R8GB3ewHLahxWpm4IqU7EMr4oQQVLY61+rbtMuM7zZUGnabdWAU la/5eaXNy64lug5lPA9yRgsVgfT3o3ULlEtGUjxPVu/88CqMvHWx5nWd/6Ov4h7L HURmNNBAkvBpu8OTIff482ZwqC74CNY4MEdV7anQZ59uPYCUXx4LRRQ2j2CkF2Q1 J0FEBDOsKQUxE/hoDa9YrtEDe4URTr5CSJ6/tq9g7HsV5dFI2FOYg2jSlHVdEGVy UXrrI40oEOdcuJIlxbjUDLgGUksS1Gw/2jIJrJCTdm4B2rjNm0btl7PTEIn5l/Yk QLDoZmjfctampO0SlPGvvTWT+0wg2QjGYahw/X9t96VmsfZHAxkHuwU38TWhFyAe /DeqShfGBBDO8/Nro5ch =a4Nn -----END PGP SIGNATURE----- --NJSRbAqOy4NeGDns--