diff mbox series

[for-next] RDMA/cxgb4: fix kernel panic for RDMA loopback test over VLAN

Message ID 20240926055705.77998-1-anumula@chelsio.com (mailing list archive)
State Superseded
Headers show
Series [for-next] RDMA/cxgb4: fix kernel panic for RDMA loopback test over VLAN | expand

Commit Message

Anumula Murali Mohan Reddy Sept. 26, 2024, 5:57 a.m. UTC
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 <anumula@chelsio.com>
Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Leon Romanovsky Sept. 26, 2024, 6:05 a.m. UTC | #1
On Thu, Sep 26, 2024 at 11:27:05AM +0530, Anumula Murali Mohan Reddy wrote:
> 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().

Please add kernel panic message and Fixes tag to the commit message.

Thanks

> 
> Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
> Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
> ---
>  drivers/infiniband/hw/cxgb4/cm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
Anumula Murali Mohan Reddy Sept. 26, 2024, 10:47 a.m. UTC | #2
Hi Leon Romanovsky,

My apologies, I hurriedly mistyped. Issue is not panic but a connection error .
Please ignore this patch. I will send a new patch with right subject line.

Thanks & Regards,
Murali

-----Original Message-----
From: Leon Romanovsky <leon@kernel.org> 
Sent: 26 September 2024 11:35
To: Anumula Murali Mohan Reddy <anumula@chelsio.com>
Cc: jgg@nvidia.com; linux-rdma@vger.kernel.org; Potnuri Bharat Teja <bharat@chelsio.com>
Subject: Re: [PATCH for-next] RDMA/cxgb4: fix kernel panic for RDMA loopback test over VLAN

On Thu, Sep 26, 2024 at 11:27:05AM +0530, Anumula Murali Mohan Reddy wrote:
> 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().

Please add kernel panic message and Fixes tag to the commit message.

Thanks

> 
> Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
> Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
> ---
>  drivers/infiniband/hw/cxgb4/cm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

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,