Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net
@ 2025-08-12 13:37 Håkon Bugge
  2025-08-12 13:49 ` Parav Pandit
  0 siblings, 1 reply; 4+ messages in thread
From: Håkon Bugge @ 2025-08-12 13:37 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky, Chiara Meiohas,
	Michael Guralnik, Mark Bloch, Yuyu Li, Patrisious Haddad,
	Zhu Yanjun, Yishai Hadas, Parav Pandit, Dr. David Alan Gilbert,
	Wang Liang
  Cc: stable, Håkon Bugge, Junxian Huang, linux-rdma, linux-kernel

If rdma_dev_init_net() has an early return because the supplied net is
the default init_net, we need to call rdma_nl_net_exit() before
returning.

Fixes: 4e0f7b907072 ("RDMA/core: Implement compat device/sysfs tree in net namespace")
Cc: stable@vger.kernel.org
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
---
 drivers/infiniband/core/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 3145cb34a1d20..ec5642e70c5db 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1203,8 +1203,10 @@ static __net_init int rdma_dev_init_net(struct net *net)
 		return ret;
 
 	/* No need to create any compat devices in default init_net. */
-	if (net_eq(net, &init_net))
+	if (net_eq(net, &init_net)) {
+		rdma_nl_net_exit(rnet);
 		return 0;
+	}
 
 	ret = xa_alloc(&rdma_nets, &rnet->id, rnet, xa_limit_32b, GFP_KERNEL);
 	if (ret) {
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net
  2025-08-12 13:37 [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net Håkon Bugge
@ 2025-08-12 13:49 ` Parav Pandit
  2025-08-12 15:10   ` Mark Bloch
  0 siblings, 1 reply; 4+ messages in thread
From: Parav Pandit @ 2025-08-12 13:49 UTC (permalink / raw)
  To: Håkon Bugge, Jason Gunthorpe, Leon Romanovsky,
	Chiara Meiohas, Michael Guralnik, Mark Bloch, Yuyu Li,
	Patrisious Haddad, Zhu Yanjun, Yishai Hadas,
	Dr. David Alan Gilbert, Wang Liang
  Cc: stable@vger.kernel.org, Junxian Huang, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org



> From: Håkon Bugge <haakon.bugge@oracle.com>
> Sent: 12 August 2025 07:08 PM
> 
> If rdma_dev_init_net() has an early return because the supplied net is the
> default init_net, we need to call rdma_nl_net_exit() before returning.
>
Not really.
We still need to create the netlink socket so that rdma commands can be operational in init_net.

However, there is a bug in incorrectly cleaning up the init_net during ib_core driver unload flow.

I reviewed a fix internally from Mark Bloch for it.
It should be posted anytime soon from Leon's queue.

Mark,
Can you please comment on plan to post the fix to rdma-rc?

 
> Fixes: 4e0f7b907072 ("RDMA/core: Implement compat device/sysfs tree in net
> namespace")
> Cc: stable@vger.kernel.org
> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
> ---
>  drivers/infiniband/core/device.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 3145cb34a1d20..ec5642e70c5db 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -1203,8 +1203,10 @@ static __net_init int rdma_dev_init_net(struct net
> *net)
>  		return ret;
> 
>  	/* No need to create any compat devices in default init_net. */
> -	if (net_eq(net, &init_net))
> +	if (net_eq(net, &init_net)) {
> +		rdma_nl_net_exit(rnet);
>  		return 0;
> +	}
> 
>  	ret = xa_alloc(&rdma_nets, &rnet->id, rnet, xa_limit_32b,
> GFP_KERNEL);
>  	if (ret) {
> --
> 2.43.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net
  2025-08-12 13:49 ` Parav Pandit
@ 2025-08-12 15:10   ` Mark Bloch
  2025-09-09 13:05     ` Haakon Bugge
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Bloch @ 2025-08-12 15:10 UTC (permalink / raw)
  To: Parav Pandit, Håkon Bugge, Jason Gunthorpe, Leon Romanovsky,
	Chiara Meiohas, Michael Guralnik, Yuyu Li, Patrisious Haddad,
	Zhu Yanjun, Yishai Hadas, Dr. David Alan Gilbert, Wang Liang
  Cc: stable@vger.kernel.org, Junxian Huang, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org



On 12/08/2025 16:49, Parav Pandit wrote:
> 
> 
>> From: Håkon Bugge <haakon.bugge@oracle.com>
>> Sent: 12 August 2025 07:08 PM
>>
>> If rdma_dev_init_net() has an early return because the supplied net is the
>> default init_net, we need to call rdma_nl_net_exit() before returning.
>>
> Not really.
> We still need to create the netlink socket so that rdma commands can be operational in init_net.
> 
> However, there is a bug in incorrectly cleaning up the init_net during ib_core driver unload flow.
> 
> I reviewed a fix internally from Mark Bloch for it.
> It should be posted anytime soon from Leon's queue.
> 
> Mark,
> Can you please comment on plan to post the fix to rdma-rc?

Leon is reviewing it now, once he’s finished, he’ll send it.

Mark

> 
>  
>> Fixes: 4e0f7b907072 ("RDMA/core: Implement compat device/sysfs tree in net
>> namespace")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
>> ---
>>  drivers/infiniband/core/device.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
>> index 3145cb34a1d20..ec5642e70c5db 100644
>> --- a/drivers/infiniband/core/device.c
>> +++ b/drivers/infiniband/core/device.c
>> @@ -1203,8 +1203,10 @@ static __net_init int rdma_dev_init_net(struct net
>> *net)
>>  		return ret;
>>
>>  	/* No need to create any compat devices in default init_net. */
>> -	if (net_eq(net, &init_net))
>> +	if (net_eq(net, &init_net)) {
>> +		rdma_nl_net_exit(rnet);
>>  		return 0;
>> +	}
>>
>>  	ret = xa_alloc(&rdma_nets, &rnet->id, rnet, xa_limit_32b,
>> GFP_KERNEL);
>>  	if (ret) {
>> --
>> 2.43.5
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net
  2025-08-12 15:10   ` Mark Bloch
@ 2025-09-09 13:05     ` Haakon Bugge
  0 siblings, 0 replies; 4+ messages in thread
From: Haakon Bugge @ 2025-09-09 13:05 UTC (permalink / raw)
  To: Mark Bloch
  Cc: Parav Pandit, Jason Gunthorpe, Leon Romanovsky, Chiara Meiohas,
	Michael Guralnik, Yuyu Li, Patrisious Haddad, Zhu Yanjun,
	Yishai Hadas, Dr. David Alan Gilbert, Wang Liang,
	stable@vger.kernel.org, Junxian Huang, OFED mailing list,
	linux-kernel@vger.kernel.org



> On 12 Aug 2025, at 17:10, Mark Bloch <mbloch@nvidia.com> wrote:
> 
> 
> 
> On 12/08/2025 16:49, Parav Pandit wrote:
>> 
>> 
>>> From: Håkon Bugge <haakon.bugge@oracle.com>
>>> Sent: 12 August 2025 07:08 PM
>>> 
>>> If rdma_dev_init_net() has an early return because the supplied net is the
>>> default init_net, we need to call rdma_nl_net_exit() before returning.
>>> 
>> Not really.
>> We still need to create the netlink socket so that rdma commands can be operational in init_net.
>> 
>> However, there is a bug in incorrectly cleaning up the init_net during ib_core driver unload flow.
>> 
>> I reviewed a fix internally from Mark Bloch for it.
>> It should be posted anytime soon from Leon's queue.
>> 
>> Mark,
>> Can you please comment on plan to post the fix to rdma-rc?
> 
> Leon is reviewing it now, once he’s finished, he’ll send it.

I am happy to review it (or may be I missed it?).


Thxs, Håkon


> 
> Mark
> 
>> 
>> 
>>> Fixes: 4e0f7b907072 ("RDMA/core: Implement compat device/sysfs tree in net
>>> namespace")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
>>> ---
>>> drivers/infiniband/core/device.c | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
>>> index 3145cb34a1d20..ec5642e70c5db 100644
>>> --- a/drivers/infiniband/core/device.c
>>> +++ b/drivers/infiniband/core/device.c
>>> @@ -1203,8 +1203,10 @@ static __net_init int rdma_dev_init_net(struct net
>>> *net)
>>> return ret;
>>> 
>>> /* No need to create any compat devices in default init_net. */
>>> - if (net_eq(net, &init_net))
>>> + if (net_eq(net, &init_net)) {
>>> + rdma_nl_net_exit(rnet);
>>> return 0;
>>> + }
>>> 
>>> ret = xa_alloc(&rdma_nets, &rnet->id, rnet, xa_limit_32b,
>>> GFP_KERNEL);
>>> if (ret) {
>>> --
>>> 2.43.5



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-09 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 13:37 [PATCH rdma-next 1/1] RDMA/core: Fix socket leak in rdma_dev_init_net Håkon Bugge
2025-08-12 13:49 ` Parav Pandit
2025-08-12 15:10   ` Mark Bloch
2025-09-09 13:05     ` Haakon Bugge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox