2021-06-21 21:34:01

by Steve French

[permalink] [raw]
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 <[email protected]>

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


Attachments:
0001-smbdirect-missing-rc-checks-while-waiting-for-rdma-e.patch (1.63 kB)

2021-06-22 06:52:58

by Long Li

[permalink] [raw]
Subject: RE: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events

> 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 <[email protected]>
>
> 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 <[email protected]>

2021-06-22 15:26:47

by Tom Talpey

[permalink] [raw]
Subject: Re: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events

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 <[email protected]>
>
> 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 <[email protected]>

Tom.

2021-06-22 17:10:58

by Steve French

[permalink] [raw]
Subject: Re: [SMBDIRECT][PATCH] missing rc checks while waiting for SMB3 over RDMA events

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 <[email protected]> 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 <[email protected]>
> >
> > 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 <[email protected]>
>
> Tom.



--
Thanks,

Steve


Attachments:
0001-smbdirect-missing-rc-checks-while-waiting-for-rdma-e.patch (1.84 kB)