public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] RDMA/siw: Fix exception handling in siw_accept_newconn()
       [not found] ` <afe30fc6-04c9-528c-f84a-67902b5a6ed8@web.de>
@ 2023-03-19 11:40   ` Leon Romanovsky
       [not found]     ` <1c06e86d-1468-c11a-8344-9563ad6047b5@web.de>
  0 siblings, 1 reply; 9+ messages in thread
From: Leon Romanovsky @ 2023-03-19 11:40 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, linux-rdma, Bernard Metzler, Jason Gunthorpe,
	cocci, LKML

On Sat, Mar 18, 2023 at 08:43:04PM +0100, Markus Elfring wrote:
> Date: Sat, 18 Mar 2023 20:30:12 +0100
> 
> The label “error” was used to jump to another pointer check despite of
> the detail in the implementation of the function “siw_accept_newconn”
> that it was determined already that corresponding variables contained
> still null pointers.
> 
> 1. Use more appropriate labels instead.
> 
> 2. Delete two questionable checks.
> 
> 3. Omit extra initialisations (for the variables “new_cep” and “new_s”)
>    which became unnecessary with this refactoring.
> 
> This issue was detected by using the Coccinelle software.
> 
> Fixes: 6c52fdc244b5ccc468006fd65a504d4ee33743c7 ("rdma/siw: connection management")
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/sw/siw/siw_cm.c | 32 ++++++++++++++----------------
>  1 file changed, 15 insertions(+), 17 deletions(-)

Please read Documentation/process/submitting-patches.rst and resubmit.
Your patch is not valid.

Thanks

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

* Re: [PATCH] RDMA/erdma: Fix exception handling in erdma_accept_newconn()
       [not found] ` <f0f96f74-21d1-f5bf-1086-1c3ce0ea18f5@web.de>
@ 2023-03-19 11:41   ` Leon Romanovsky
  2023-03-19 13:36   ` Cheng Xu
  1 sibling, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2023-03-19 11:41 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, linux-rdma, Cheng Xu, Jason Gunthorpe, Kai Shen,
	Yang Li, cocci, LKML

On Sat, Mar 18, 2023 at 09:15:58PM +0100, Markus Elfring wrote:
> Date: Sat, 18 Mar 2023 21:08:58 +0100
> 
> The label “error” was used to jump to another pointer check despite of
> the detail in the implementation of the function “erdma_accept_newconn”
> that it was determined already that corresponding variables contained
> still null pointers.
> 
> 1. Thus return directly if
>    * the cep state is not the value “ERDMA_EPSTATE_LISTENING”
>      or
>    * a call of the function “erdma_cep_alloc” failed.
> 
> 2. Use more appropriate labels instead.
> 
> 3. Delete two questionable checks.
> 
> 4. Omit extra initialisations (for the variables “new_cep”, “new_s” and “ret”)
>    which became unnecessary with this refactoring.
> 
> 
> This issue was detected by using the Coccinelle software.
> 
> Fixes: 920d93eac8b97778fef48f34f10e58ddf870fc2a ("RDMA/erdma: Add connection management (CM) support")
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/hw/erdma/erdma_cm.c | 39 +++++++++++---------------
>  1 file changed, 17 insertions(+), 22 deletions(-)

Same comment as for your RDMA/siw patch.

Thanks

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

* Re: [PATCH] RDMA/erdma: Fix exception handling in erdma_accept_newconn()
       [not found] ` <f0f96f74-21d1-f5bf-1086-1c3ce0ea18f5@web.de>
  2023-03-19 11:41   ` [PATCH] RDMA/erdma: Fix exception handling in erdma_accept_newconn() Leon Romanovsky
@ 2023-03-19 13:36   ` Cheng Xu
  2025-03-05 14:20     ` [PATCH] RDMA/erdma: Prevent use-after-free " Markus Elfring
  1 sibling, 1 reply; 9+ messages in thread
From: Cheng Xu @ 2023-03-19 13:36 UTC (permalink / raw)
  To: Markus Elfring, kernel-janitors, linux-rdma, Jason Gunthorpe,
	Kai Shen, Leon Romanovsky, Yang Li
  Cc: cocci, LKML



On 3/19/23 4:15 AM, Markus Elfring wrote:
> Date: Sat, 18 Mar 2023 21:08:58 +0100
> 

<...>

> +disassoc_socket:
> +    erdma_socket_disassoc(new_s);
> +    sock_release(new_s);
> +    new_cep->state = ERDMA_EPSTATE_CLOSED;
> +    erdma_cancel_mpatimer(new_cep);
> +put_cep:
> +    erdma_cep_put(new_cep);> +    new_cep->sock = NULL;

Thanks, but this causes an use-after-free issue because new_cep will be
released after last erdma_cep_put being called.

Cheng Xu

>  }
>  
>  static int erdma_newconn_connected(struct erdma_cep *cep)

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

* Re: [PATCH] RDMA/siw: Fix exception handling in siw_accept_newconn()
       [not found]     ` <1c06e86d-1468-c11a-8344-9563ad6047b5@web.de>
@ 2023-03-19 14:11       ` Leon Romanovsky
       [not found]         ` <a03c1d04-a41e-7722-c36a-bd6f61094702@web.de>
  0 siblings, 1 reply; 9+ messages in thread
From: Leon Romanovsky @ 2023-03-19 14:11 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, linux-rdma, Bernard Metzler, Jason Gunthorpe,
	cocci, LKML

On Sun, Mar 19, 2023 at 02:38:03PM +0100, Markus Elfring wrote:
> >> Date: Sat, 18 Mar 2023 20:30:12 +0100
> >>
> >> The label “error” was used to jump to another pointer check despite of
> >> the detail in the implementation of the function “siw_accept_newconn”
> >> that it was determined already that corresponding variables contained
> >> still null pointers.
> >>
> >> 1. Use more appropriate labels instead.
> >>
> >> 2. Delete two questionable checks.
> >>
> >> 3. Omit extra initialisations (for the variables “new_cep” and “new_s”)
> >>    which became unnecessary with this refactoring.
> >>
> >> This issue was detected by using the Coccinelle software.
> >>
> >> Fixes: 6c52fdc244b5ccc468006fd65a504d4ee33743c7 ("rdma/siw: connection management")
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> ---
> >>  drivers/infiniband/sw/siw/siw_cm.c | 32 ++++++++++++++----------------
> >>  1 file changed, 15 insertions(+), 17 deletions(-)
> > Please read Documentation/process/submitting-patches.rst and resubmit.
> > Your patch is not valid.
> 
> 
> What do you find improvable here?

Did you read the guide above?

1. The patch is malformed and doesn't appear in lore and patchworks.
2. "Date ..." in the middle of patch
3. Wrong Fixes line.
4. Patch contains too much and too different things at the same time.

Thanks

> 
> Regards,
> Markus
> 

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

* Re: RDMA/siw: Fix exception handling in siw_accept_newconn()
       [not found]         ` <a03c1d04-a41e-7722-c36a-bd6f61094702@web.de>
@ 2023-03-19 17:37           ` Leon Romanovsky
  0 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2023-03-19 17:37 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, linux-rdma, Bernard Metzler, Jason Gunthorpe,
	cocci, LKML

On Sun, Mar 19, 2023 at 04:40:17PM +0100, Markus Elfring wrote:
> >>>> Date: Sat, 18 Mar 2023 20:30:12 +0100
> >>>>
> >>>> The label “error” was used to jump to another pointer check despite of
> >>>> the detail in the implementation of the function “siw_accept_newconn”
> >>>> that it was determined already that corresponding variables contained
> >>>> still null pointers.
> >>>>
> >>>> 1. Use more appropriate labels instead.
> >>>>
> >>>> 2. Delete two questionable checks.
> >>>>
> >>>> 3. Omit extra initialisations (for the variables “new_cep” and “new_s”)
> >>>>    which became unnecessary with this refactoring.
> >>>>
> >>>> This issue was detected by using the Coccinelle software.
> >>>>
> >>>> Fixes: 6c52fdc244b5ccc468006fd65a504d4ee33743c7 ("rdma/siw: connection management")
> >>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >>>> ---
> >>>>  drivers/infiniband/sw/siw/siw_cm.c | 32 ++++++++++++++----------------
> >>>>  1 file changed, 15 insertions(+), 17 deletions(-)
> >>> Please read Documentation/process/submitting-patches.rst and resubmit.
> >>> Your patch is not valid.
> >>
> >> What do you find improvable here?
> > Did you read the guide above?
> 
> Yes, of course (several times before).

ok, I'm taking my request to resubmit back.
Please retain from posting to RDMA ML. I'm not going to apply any of
your patches.

Thanks

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

* Re: [PATCH 0/2] IB/uverbs: Adjustments for create_qp()
       [not found]   ` <01af2ec9-4758-1fe6-0d74-b30b95c3e9a5@web.de>
@ 2023-04-09  9:59     ` Leon Romanovsky
  0 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2023-04-09  9:59 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, linux-rdma, Daisuke Matsuda, Doug Ledford,
	Jason Gunthorpe, Matan Barak, Max Gurtovoy, Sagi Grimberg,
	Yishai Hadas, cocci, LKML

On Thu, Apr 06, 2023 at 06:10:14PM +0200, Markus Elfring wrote:
> Date: Thu, 6 Apr 2023 17:50:05 +0200
> 
> A few update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (2):
>   Improve exception handling
>   Delete a duplicate check

Like I said it before,
NACK to any RDMA patches from you.

To make it very clear, if you send any patches to RDMA, please add the
following line:

Nacked-by Leon Romanovsky <leon@kernel.org>

Thanks

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

* [PATCH] RDMA/erdma: Prevent use-after-free in erdma_accept_newconn()
  2023-03-19 13:36   ` Cheng Xu
@ 2025-03-05 14:20     ` Markus Elfring
  2025-03-06  8:47       ` Leon Romanovsky
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2025-03-05 14:20 UTC (permalink / raw)
  To: kernel-janitors, linux-rdma, Cheng Xu, Jason Gunthorpe, Kai Shen,
	Leon Romanovsky, Yang Li
  Cc: cocci, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Mar 2025 15:07:51 +0100

The implementation of the function “erdma_accept_newconn” contained
still the statement “new_cep->sock = NULL” after
the function call “erdma_cep_put(new_cep)”.
Thus delete an inappropriate reset action.

Reported-by: Cheng Xu <chengyou@linux.alibaba.com>
Link: https://lore.kernel.org/cocci/167179d0-e1ea-39a8-4143-949ad57294c2@linux.alibaba.com/
Link: https://lkml.org/lkml/2023/3/19/191
Fixes: 920d93eac8b9 ("RDMA/erdma: Add connection management (CM) support")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/erdma/erdma_cm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/erdma/erdma_cm.c b/drivers/infiniband/hw/erdma/erdma_cm.c
index 1b23c698ec25..e0acc185e719 100644
--- a/drivers/infiniband/hw/erdma/erdma_cm.c
+++ b/drivers/infiniband/hw/erdma/erdma_cm.c
@@ -709,7 +709,6 @@ static void erdma_accept_newconn(struct erdma_cep *cep)
 		erdma_cancel_mpatimer(new_cep);

 		erdma_cep_put(new_cep);
-		new_cep->sock = NULL;
 	}

 	if (new_s) {
--
2.48.1


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

* Re: [PATCH] RDMA/erdma: Prevent use-after-free in erdma_accept_newconn()
  2025-03-05 14:20     ` [PATCH] RDMA/erdma: Prevent use-after-free " Markus Elfring
@ 2025-03-06  8:47       ` Leon Romanovsky
  2025-03-06 12:06         ` Cheng Xu
  0 siblings, 1 reply; 9+ messages in thread
From: Leon Romanovsky @ 2025-03-06  8:47 UTC (permalink / raw)
  To: Cheng Xu, Markus Elfring
  Cc: kernel-janitors, linux-rdma, Cheng Xu, Jason Gunthorpe, Kai Shen,
	Yang Li, cocci, LKML, Christophe Leroy

On Wed, Mar 05, 2025 at 03:20:41PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 5 Mar 2025 15:07:51 +0100
> 
> The implementation of the function “erdma_accept_newconn” contained
> still the statement “new_cep->sock = NULL” after
> the function call “erdma_cep_put(new_cep)”.
> Thus delete an inappropriate reset action.
> 
> Reported-by: Cheng Xu <chengyou@linux.alibaba.com>

Cheng, please resubmit this patch, I'm experiencing the same issues as
Christophe has here https://lore.kernel.org/all/20a1a47c-8906-44e8-92e6-9b3e698b1491@web.de
and it looks like Markus continues do not listen to the feedback.

Thanks

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

* Re: [PATCH] RDMA/erdma: Prevent use-after-free in erdma_accept_newconn()
  2025-03-06  8:47       ` Leon Romanovsky
@ 2025-03-06 12:06         ` Cheng Xu
  0 siblings, 0 replies; 9+ messages in thread
From: Cheng Xu @ 2025-03-06 12:06 UTC (permalink / raw)
  To: Leon Romanovsky, Markus Elfring
  Cc: kernel-janitors, linux-rdma, Jason Gunthorpe, Kai Shen, Yang Li,
	cocci, LKML, Christophe Leroy



On 3/6/25 4:47 PM, Leon Romanovsky wrote:
> On Wed, Mar 05, 2025 at 03:20:41PM +0100, Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Wed, 5 Mar 2025 15:07:51 +0100
>>
>> The implementation of the function “erdma_accept_newconn” contained
>> still the statement “new_cep->sock = NULL” after
>> the function call “erdma_cep_put(new_cep)”.
>> Thus delete an inappropriate reset action.
>>
>> Reported-by: Cheng Xu <chengyou@linux.alibaba.com>
> 
> Cheng, please resubmit this patch, I'm experiencing the same issues as
> Christophe has here https://lore.kernel.org/all/20a1a47c-8906-44e8-92e6-9b3e698b1491@web.de
> and it looks like Markus continues do not listen to the feedback.
> 

Hi Leon,

Sure, I just resubmitted the patch, please review and apply.

Thanks,
Cheng Xu

> Thanks

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

end of thread, other threads:[~2025-03-06 12:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <f9303bdc-b1a7-be5e-56c6-dfa8232b8b55@web.de>
     [not found] ` <afe30fc6-04c9-528c-f84a-67902b5a6ed8@web.de>
2023-03-19 11:40   ` [PATCH] RDMA/siw: Fix exception handling in siw_accept_newconn() Leon Romanovsky
     [not found]     ` <1c06e86d-1468-c11a-8344-9563ad6047b5@web.de>
2023-03-19 14:11       ` Leon Romanovsky
     [not found]         ` <a03c1d04-a41e-7722-c36a-bd6f61094702@web.de>
2023-03-19 17:37           ` Leon Romanovsky
     [not found] ` <f0f96f74-21d1-f5bf-1086-1c3ce0ea18f5@web.de>
2023-03-19 11:41   ` [PATCH] RDMA/erdma: Fix exception handling in erdma_accept_newconn() Leon Romanovsky
2023-03-19 13:36   ` Cheng Xu
2025-03-05 14:20     ` [PATCH] RDMA/erdma: Prevent use-after-free " Markus Elfring
2025-03-06  8:47       ` Leon Romanovsky
2025-03-06 12:06         ` Cheng Xu
     [not found] ` <8f785de5-ebe2-edd9-2155-f440acacc643@web.de>
     [not found]   ` <01af2ec9-4758-1fe6-0d74-b30b95c3e9a5@web.de>
2023-04-09  9:59     ` [PATCH 0/2] IB/uverbs: Adjustments for create_qp() Leon Romanovsky

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