From patchwork Thu Sep 26 05:57:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anumula Murali Mohan Reddy X-Patchwork-Id: 13812815 Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C92451D5AD0 for ; Thu, 26 Sep 2024 05:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=12.32.117.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727330079; cv=none; b=RKtdKOi1Z1K70PBvrX9z4smSqs3l7KmK5eTIITDYSyfxwRR+lR7Wal6rLxlRnkmzPNg5Nvx612Rm8/Hz90jRjVhpSXEjBZhDTEvoX/RZhWfyiv4RO417F7/j67XRLny+vZvhmswxVwc/pZyE245oxQFinAdc7FVXnBl/SvoKaq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727330079; c=relaxed/simple; bh=rhOfCmZFlddORS+wLY5ARJJyh5WkUI2OJXt9nnsAcyM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EwLa/o89qLQkZ5TxIN5Q8wWKK6rzgkj9PvHCs+SKm41fivd2LUsuDppY9kV6ne7PaiU3LxTKJi7GpegoaAWS06YpLDF57qSM5CiWRBKiccY7SAXWNrRtAfmL107pevT4QQ5PRMuKH0Wuhd82LSyRMksEa89mT9lrRoUXCS+jIg4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=chelsio.com; spf=pass smtp.mailfrom=chelsio.com; arc=none smtp.client-ip=12.32.117.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=chelsio.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chelsio.com Received: from beagle5.blr.asicdesigners.com (beagle5.blr.asicdesigners.com [10.193.80.119]) by stargate.chelsio.com (8.14.7/8.14.7) with ESMTP id 48Q5sO24025821; Wed, 25 Sep 2024 22:54:25 -0700 From: Anumula Murali Mohan Reddy To: jgg@nvidia.com, leonro@nvidia.com Cc: linux-rdma@vger.kernel.org, Anumula Murali Mohan Reddy , Potnuri Bharat Teja Subject: [PATCH for-next] RDMA/cxgb4: fix kernel panic for RDMA loopback test over VLAN Date: Thu, 26 Sep 2024 11:27:05 +0530 Message-Id: <20240926055705.77998-1-anumula@chelsio.com> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ip_dev_find() always returns real net_device address, whether traffic is running on a vlan or real device, if traffic is over vlan, further derefencing real net_device address leads to kernel panic. This patch fixes the issue by using vlan_dev_real_dev(). Signed-off-by: Anumula Murali Mohan Reddy Signed-off-by: Potnuri Bharat Teja --- drivers/infiniband/hw/cxgb4/cm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index b3757c6a0457..21146663cdac 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -2086,7 +2086,7 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, err = -ENOMEM; if (n->dev->flags & IFF_LOOPBACK) { if (iptype == 4) - pdev = ip_dev_find(&init_net, *(__be32 *)peer_ip); + pdev = __ip_dev_find(&init_net, *(__be32 *)peer_ip, false); else if (IS_ENABLED(CONFIG_IPV6)) for_each_netdev(&init_net, pdev) { if (ipv6_chk_addr(&init_net, @@ -2101,10 +2101,11 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, err = -ENODEV; goto out; } + if (is_vlan_dev(pdev)) + pdev = vlan_dev_real_dev(pdev); ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t, n, pdev, rt_tos2priority(tos)); if (!ep->l2t) { - dev_put(pdev); goto out; } ep->mtu = pdev->mtu; @@ -2119,7 +2120,6 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, ep->rss_qid = cdev->rdev.lldi.rxq_ids[ cxgb4_port_idx(pdev) * step]; set_tcp_window(ep, (struct port_info *)netdev_priv(pdev)); - dev_put(pdev); } else { pdev = get_real_dev(n->dev); ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,