Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp415369imm; Mon, 2 Jul 2018 14:04:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcIPGulITMIGpsOum59/5bZFBHzJCr70n4DtdXe5fa2iy/002pQ+jim5QPSNT/L/jPrqq+I X-Received: by 2002:a62:b02:: with SMTP id t2-v6mr26937842pfi.36.1530565446077; Mon, 02 Jul 2018 14:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530565446; cv=none; d=google.com; s=arc-20160816; b=kqfwpQD+rqusv3wWzinSke1G6G6lC9cXP3C/FXBxBqbZbDZ9L5FoyIdrKZRnlVbrgL fQTMxdg/fnkTwAbN6hXiRUqDHpLUQKD6g8HUnBnOu3ayIIT/XRZwcOHQPs4+qV9JbWyo rtLaRtQQqQTLWj4j0D4E0fdpC10tBp9H5BZuocFcsq5trecuVvr+ULCbYohW2F3g5+7F v02qR6yNqqF4jo46kHY9WVHBsVRhnhjbP59QW5SZ9qKLRBADXYbAjlqZM27vCkbiJ+JK 0uRjl+bxXRuewsg3zH9sSP1d4EymhPLz9aPKezQSjLaiiIc8+QO2DHjwyRLbKiUeJVIG 7G3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:message-id:date :mime-version:dkim-signature:arc-authentication-results; bh=BehkCuOEOmmlpKtkCglP7vVPMQq/4eUyR2IGQHQpdsQ=; b=PpXDTSWRlLLOKXBeReoCQ8pZ2RW4pdEqJcTHQR4NBIEczZuC4zhAukYmwooueh7Kzo Mzzy1BsD5XRb3iiTnRlMPaVezpcoEOOlZG+M6SbM7HtXalfnKNQqkmF+EyTyJQizZbpR 83gCWuR3ymeSjVtSIWm80o8F82R6Vc0wJBqb67Vcdpoa7lj9uIJYOHVBn/+4AOq7fW3l G2GVNVZhsDp5a94KzOpb2jFYSztG6rXovYpAmWGG/Yp1U1faCrCL/SOOvofPhc0BQrEk YhlmjF82uIO84nD8LkctDmra+8l3udBWDV1b/8lg3C8Y0rf5E/sp/KgmV+tVFp2QtHnK TcFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=saczxlD7; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186-v6si4994644pfd.234.2018.07.02.14.03.50; Mon, 02 Jul 2018 14:04:06 -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=@google.com header.s=20161025 header.b=saczxlD7; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753014AbeGBVDB (ORCPT + 99 others); Mon, 2 Jul 2018 17:03:01 -0400 Received: from mail-qk0-f201.google.com ([209.85.220.201]:32772 "EHLO mail-qk0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbeGBVDA (ORCPT ); Mon, 2 Jul 2018 17:03:00 -0400 Received: by mail-qk0-f201.google.com with SMTP id j189-v6so18075958qkf.0 for ; Mon, 02 Jul 2018 14:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=BehkCuOEOmmlpKtkCglP7vVPMQq/4eUyR2IGQHQpdsQ=; b=saczxlD7LczlogxB8lqT2XYDb1MIBCcg2XM1LFpPiU3PAcbCgatmkuWK4bIZkiBclj rxzDa7+3j29wayhr87ioPZN2hze+9FZGPpfrhaFnbGwuI/BYSqJQwC7ZdrgDZ+XENr6T cJek0UdzGH33A/q67vikiWgam4Yn5ZDsWsA0AYzFJz6jfkLImHTjTu4VgoHd+eks6M+M AkouUhVylLWxyKDCGo4mIxMHdSBH+tfYPooQHuvBLGCMBSUmY2pmKdps6NEDfAbDnWZN 3CEn1er9wNOMNHzsPGHIoNcjWZFwz0+OGMw44d1ueLZnPFI2ncbE/Usrv/uVev8waAc8 jKMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=BehkCuOEOmmlpKtkCglP7vVPMQq/4eUyR2IGQHQpdsQ=; b=TBUX01czQ/yB5XrfMH+CBlD2xB069OXafIqYlLOsfDsLYBcB6520AMp/+PkxQhQleL B0BmDdcEEkx3rIUI58oBKU7Oa9EHQArUkOKwW9TbqEHWJyCg1gnvWDDa6STwop2bws4r q/8zK+5yhmEPorHihQSU7ABOhQuelBS2vzQSsDEi5LYNc2ZznGwlZH4nt5sIysP3qgDn QYKlslLNqlzoKdBYQq46i9q+GmDvaWXlZa6EoeYlsUr+PAtJMO1sZXfVsJ2j7OGb5PB+ wAD7unllspMbdCC6V27E41+3uJE8s8N5XYyYrxH7UC40w0KvsDnD8LqDFpEO0hN8AQ9J AUzA== X-Gm-Message-State: APt69E0ks0ex4f+JCceHA00XTj99urc3FF7NAF+6mrrc4D7HukoX95pF Y0FcLcucwM+mzVkWHmDPNaFuQxlMFA== MIME-Version: 1.0 X-Received: by 2002:ac8:c85:: with SMTP id n5-v6mr14595604qti.60.1530565379282; Mon, 02 Jul 2018 14:02:59 -0700 (PDT) Date: Mon, 2 Jul 2018 14:02:34 -0700 Message-Id: <20180702210234.107361-1-tarick@google.com> X-Mailer: git-send-email 2.18.0.399.gad0ab374a1-goog Subject: [PATCH] IB/mlx4: Test port number before querying type. From: Tarick Bedeir To: Yishai Hadas , Doug Ledford , Jason Gunthorpe Cc: edumazet@google.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Tarick Bedeir Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) return; + ah_attr->type = rdma_ah_find_type(&ibdev->ib_dev, port_num); if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) rdma_ah_set_sl(ah_attr, ((path->sched_queue >> 3) & 0x7) | -- 2.18.0.399.gad0ab374a1-goog