All of lore.kernel.org
 help / color / mirror / Atom feed
* [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events
@ 2021-06-21 21:32 Steve French
  2021-06-22  6:49 ` Long Li
  2021-06-22 15:18 ` Tom Talpey
  0 siblings, 2 replies; 4+ messages in thread
From: Steve French @ 2021-06-21 21:32 UTC (permalink / raw)
  To: Long Li; +Cc: CIFS, LKML

[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]

    There were two places where we weren't checking for error
    (e.g. ERESTARTSYS) while waiting for rdma resolution.

    Addresses-Coverity: 1462165 ("Unchecked return value")
   Signed-off-by: Steve French <stfrench@microsoft.com>

diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
index 10dfe5006792..ae07732f750f 100644
--- a/fs/cifs/smbdirect.c
+++ b/fs/cifs/smbdirect.c
@@ -572,8 +572,11 @@ static struct rdma_cm_id *smbd_create_id(
                log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
                goto out;
        }
-       wait_for_completion_interruptible_timeout(
+       rc = wait_for_completion_interruptible_timeout(
                &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+       /* -ERESTARTSYS, returned when interrupted, is the only rc mentioned */
+       if (rc < 0)
+               goto out;
        rc = info->ri_rc;
        if (rc) {
                log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
@@ -586,8 +589,10 @@ static struct rdma_cm_id *smbd_create_id(
                log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
                goto out;
        }
-       wait_for_completion_interruptible_timeout(
+       rc = wait_for_completion_interruptible_timeout(
                &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+       if (rc < 0)  /* e.g. if interrupted and returns -ERESTARTSYS */
+               goto out
        rc = info->ri_rc;
        if (rc) {
                log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);


-- 
Thanks,

Steve

[-- Attachment #2: 0001-smbdirect-missing-rc-checks-while-waiting-for-rdma-e.patch --]
[-- Type: text/x-patch, Size: 1672 bytes --]

From 9bf42caeb95d8a5bf672348e5deba583f8233713 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Mon, 21 Jun 2021 16:25:20 -0500
Subject: [PATCH] smbdirect: missing rc checks while waiting for rdma events

There were two places where we weren't checking for error
(e.g. ERESTARTSYS) while waiting for rdma resolution.

Addresses-Coverity: 1462165 ("Unchecked return value")
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smbdirect.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
index 10dfe5006792..ae07732f750f 100644
--- a/fs/cifs/smbdirect.c
+++ b/fs/cifs/smbdirect.c
@@ -572,8 +572,11 @@ static struct rdma_cm_id *smbd_create_id(
 		log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
 		goto out;
 	}
-	wait_for_completion_interruptible_timeout(
+	rc = wait_for_completion_interruptible_timeout(
 		&info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+	/* -ERESTARTSYS, returned when interrupted, is the only rc mentioned */
+	if (rc < 0)
+		goto out;
 	rc = info->ri_rc;
 	if (rc) {
 		log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
@@ -586,8 +589,10 @@ static struct rdma_cm_id *smbd_create_id(
 		log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
 		goto out;
 	}
-	wait_for_completion_interruptible_timeout(
+	rc = wait_for_completion_interruptible_timeout(
 		&info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+	if (rc < 0)  /* e.g. if interrupted and returns -ERESTARTSYS */
+		goto out
 	rc = info->ri_rc;
 	if (rc) {
 		log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
-- 
2.30.2


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

* RE: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events
  2021-06-21 21:32 [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events Steve French
@ 2021-06-22  6:49 ` Long Li
  2021-06-22 15:18 ` Tom Talpey
  1 sibling, 0 replies; 4+ messages in thread
From: Long Li @ 2021-06-22  6:49 UTC (permalink / raw)
  To: Steve French; +Cc: CIFS, LKML

> Subject: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over
> RDMA events
> 
>     There were two places where we weren't checking for error
>     (e.g. ERESTARTSYS) while waiting for rdma resolution.
> 
>     Addresses-Coverity: 1462165 ("Unchecked return value")
>    Signed-off-by: Steve French <stfrench@microsoft.com>
> 
> diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index
> 10dfe5006792..ae07732f750f 100644
> --- a/fs/cifs/smbdirect.c
> +++ b/fs/cifs/smbdirect.c
> @@ -572,8 +572,11 @@ static struct rdma_cm_id *smbd_create_id(
>                 log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
>                 goto out;
>         }
> -       wait_for_completion_interruptible_timeout(
> +       rc = wait_for_completion_interruptible_timeout(
>                 &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
> +       /* -ERESTARTSYS, returned when interrupted, is the only rc mentioned
> */
> +       if (rc < 0)
> +               goto out;
>         rc = info->ri_rc;
>         if (rc) {
>                 log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
> @@ -586,8 +589,10 @@ static struct rdma_cm_id *smbd_create_id(
>                 log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
>                 goto out;
>         }
> -       wait_for_completion_interruptible_timeout(
> +       rc = wait_for_completion_interruptible_timeout(
>                 &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
> +       if (rc < 0)  /* e.g. if interrupted and returns -ERESTARTSYS */
> +               goto out
>         rc = info->ri_rc;
>         if (rc) {
>                 log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
> 
> 
> --
> Thanks,
> 
> Steve

Reviewed-by: Long Li <longli@microsoft.com>

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

* Re: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events
  2021-06-21 21:32 [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events Steve French
  2021-06-22  6:49 ` Long Li
@ 2021-06-22 15:18 ` Tom Talpey
  2021-06-22 17:09   ` Steve French
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Talpey @ 2021-06-22 15:18 UTC (permalink / raw)
  To: Steve French, Long Li; +Cc: CIFS, LKML

On 6/21/2021 5:32 PM, Steve French wrote:
>      There were two places where we weren't checking for error
>      (e.g. ERESTARTSYS) while waiting for rdma resolution.
> 
>      Addresses-Coverity: 1462165 ("Unchecked return value")
>     Signed-off-by: Steve French <stfrench@microsoft.com>
> 
> diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
> index 10dfe5006792..ae07732f750f 100644
> --- a/fs/cifs/smbdirect.c
> +++ b/fs/cifs/smbdirect.c
> @@ -572,8 +572,11 @@ static struct rdma_cm_id *smbd_create_id(
>                  log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
>                  goto out;
>          }
> -       wait_for_completion_interruptible_timeout(
> +       rc = wait_for_completion_interruptible_timeout(
>                  &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
> +       /* -ERESTARTSYS, returned when interrupted, is the only rc mentioned */

Suggest the same comment text as the one below, this one seems uncertain.

> +       if (rc < 0)
> +               goto out;
>          rc = info->ri_rc;
>          if (rc) {
>                  log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
> @@ -586,8 +589,10 @@ static struct rdma_cm_id *smbd_create_id(
>                  log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
>                  goto out;
>          }
> -       wait_for_completion_interruptible_timeout(
> +       rc = wait_for_completion_interruptible_timeout(
>                  &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
> +       if (rc < 0)  /* e.g. if interrupted and returns -ERESTARTSYS */

delete "and"?

> +               goto out

Missing a semicolon.     ^^^

>          rc = info->ri_rc;
>          if (rc) {
>                  log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
> 
> 

One meta-comment. There's no message logged for these ERESTARTSYS cases.
That might be confusing in the log, if they lead to failure.

Reviewed-By: Tom Talpey <tom@talpey.com>

Tom.

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

* Re: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events
  2021-06-22 15:18 ` Tom Talpey
@ 2021-06-22 17:09   ` Steve French
  0 siblings, 0 replies; 4+ messages in thread
From: Steve French @ 2021-06-22 17:09 UTC (permalink / raw)
  To: Tom Talpey; +Cc: Long Li, CIFS, LKML

[-- Attachment #1: Type: text/plain, Size: 2274 bytes --]

patch updated with Tom's suggestions - let me know if I have missed anything.


On Tue, Jun 22, 2021 at 10:18 AM Tom Talpey <tom@talpey.com> wrote:
>
> On 6/21/2021 5:32 PM, Steve French wrote:
> >      There were two places where we weren't checking for error
> >      (e.g. ERESTARTSYS) while waiting for rdma resolution.
> >
> >      Addresses-Coverity: 1462165 ("Unchecked return value")
> >     Signed-off-by: Steve French <stfrench@microsoft.com>
> >
> > diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
> > index 10dfe5006792..ae07732f750f 100644
> > --- a/fs/cifs/smbdirect.c
> > +++ b/fs/cifs/smbdirect.c
> > @@ -572,8 +572,11 @@ static struct rdma_cm_id *smbd_create_id(
> >                  log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
> >                  goto out;
> >          }
> > -       wait_for_completion_interruptible_timeout(
> > +       rc = wait_for_completion_interruptible_timeout(
> >                  &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
> > +       /* -ERESTARTSYS, returned when interrupted, is the only rc mentioned */
>
> Suggest the same comment text as the one below, this one seems uncertain.
>
> > +       if (rc < 0)
> > +               goto out;
> >          rc = info->ri_rc;
> >          if (rc) {
> >                  log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
> > @@ -586,8 +589,10 @@ static struct rdma_cm_id *smbd_create_id(
> >                  log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
> >                  goto out;
> >          }
> > -       wait_for_completion_interruptible_timeout(
> > +       rc = wait_for_completion_interruptible_timeout(
> >                  &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
> > +       if (rc < 0)  /* e.g. if interrupted and returns -ERESTARTSYS */
>
> delete "and"?
>
> > +               goto out
>
> Missing a semicolon.     ^^^
>
> >          rc = info->ri_rc;
> >          if (rc) {
> >                  log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
> >
> >
>
> One meta-comment. There's no message logged for these ERESTARTSYS cases.
> That might be confusing in the log, if they lead to failure.
>
> Reviewed-By: Tom Talpey <tom@talpey.com>
>
> Tom.



-- 
Thanks,

Steve

[-- Attachment #2: 0001-smbdirect-missing-rc-checks-while-waiting-for-rdma-e.patch --]
[-- Type: text/x-patch, Size: 1882 bytes --]

From 0555b221528e9cb11f5766dcdee19c809187e42e Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Mon, 21 Jun 2021 16:25:20 -0500
Subject: [PATCH] smbdirect: missing rc checks while waiting for rdma events

There were two places where we weren't checking for error
(e.g. ERESTARTSYS) while waiting for rdma resolution.

Addresses-Coverity: 1462165 ("Unchecked return value")
Reviewed-by: Tom Talpey <tom@talpey.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smbdirect.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
index 10dfe5006792..31ef64eb7fbb 100644
--- a/fs/cifs/smbdirect.c
+++ b/fs/cifs/smbdirect.c
@@ -572,8 +572,13 @@ static struct rdma_cm_id *smbd_create_id(
 		log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
 		goto out;
 	}
-	wait_for_completion_interruptible_timeout(
+	rc = wait_for_completion_interruptible_timeout(
 		&info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+	/* e.g. if interrupted returns -ERESTARTSYS */
+	if (rc < 0) {
+		log_rdma_event(ERR, "rdma_resolve_addr timeout rc: %i\n", rc);
+		goto out;
+	}
 	rc = info->ri_rc;
 	if (rc) {
 		log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
@@ -586,8 +591,13 @@ static struct rdma_cm_id *smbd_create_id(
 		log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
 		goto out;
 	}
-	wait_for_completion_interruptible_timeout(
+	rc = wait_for_completion_interruptible_timeout(
 		&info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+	/* e.g. if interrupted returns -ERESTARTSYS */
+	if (rc < 0)  {
+		log_rdma_event(ERR, "rdma_resolve_addr timeout rc: %i\n", rc);
+		goto out;
+	}
 	rc = info->ri_rc;
 	if (rc) {
 		log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
-- 
2.30.2


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

end of thread, other threads:[~2021-06-22 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 21:32 [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events Steve French
2021-06-22  6:49 ` Long Li
2021-06-22 15:18 ` Tom Talpey
2021-06-22 17:09   ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.