diff mbox series

net/rds: fix WARNING in rds_conn_connect_if_down

Message ID tencent_25067C49AB2EDF6EE5CC95A7FA86C992F806@qq.com (mailing list archive)
State Superseded
Headers show
Series net/rds: fix WARNING in rds_conn_connect_if_down | expand

Commit Message

Edward Adam Davis March 3, 2024, 4:18 a.m. UTC
If connection isn't established yet, get_mr() will fail, trigger connection after
get_mr().

Fixes: 584a8279a44a ("RDS: RDMA: return appropriate error on rdma map failures") 
Reported-and-tested-by: syzbot+d4faee732755bba9838e@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 net/rds/rdma.c | 3 +++
 net/rds/send.c | 6 +-----
 2 files changed, 4 insertions(+), 5 deletions(-)

Comments

Simon Horman March 4, 2024, 5:07 p.m. UTC | #1
On Sun, Mar 03, 2024 at 12:18:57PM +0800, Edward Adam Davis wrote:
> If connection isn't established yet, get_mr() will fail, trigger connection after
> get_mr().
> 
> Fixes: 584a8279a44a ("RDS: RDMA: return appropriate error on rdma map failures") 
> Reported-and-tested-by: syzbot+d4faee732755bba9838e@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
>  net/rds/rdma.c | 3 +++
>  net/rds/send.c | 6 +-----
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/net/rds/rdma.c b/net/rds/rdma.c
> index fba82d36593a..a4e3c5de998b 100644
> --- a/net/rds/rdma.c
> +++ b/net/rds/rdma.c
> @@ -301,6 +301,9 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
>  			kfree(sg);
>  		}
>  		ret = PTR_ERR(trans_private);
> +		/* Trigger connection so that its ready for the next retry */
> +		if (ret == -ENODEV)
> +			rds_conn_connect_if_down(cp->cp_conn);

Hi Edward,

Elsewhere in this function it is assumed that cp may be NULL.
Does that need to be taken into account here too?

Flagged by Smatch.

>  		goto out;
>  	}
>  
> diff --git a/net/rds/send.c b/net/rds/send.c
> index 5e57a1581dc6..fa1640628b2f 100644
> --- a/net/rds/send.c
> +++ b/net/rds/send.c
> @@ -1313,12 +1313,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
>  
>  	/* Parse any control messages the user may have included. */
>  	ret = rds_cmsg_send(rs, rm, msg, &allocated_mr, &vct);
> -	if (ret) {
> -		/* Trigger connection so that its ready for the next retry */
> -		if (ret ==  -EAGAIN)
> -			rds_conn_connect_if_down(conn);
> +	if (ret) 

nit: checkpatch warns that there is a trailing space on the line above.

>  		goto out;
> -	}
>  
>  	if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) {
>  		printk_ratelimited(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n",
Edward Adam Davis March 5, 2024, 12:12 a.m. UTC | #2
On Mon, 4 Mar 2024 17:07:07 +0000, Simon Horman wrote:
> > If connection isn't established yet, get_mr() will fail, trigger connection after
> > get_mr().
> > 
> > Fixes: 584a8279a44a ("RDS: RDMA: return appropriate error on rdma map failures") 
> > Reported-and-tested-by: syzbot+d4faee732755bba9838e@syzkaller.appspotmail.com
> > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > ---
> >  net/rds/rdma.c | 3 +++
> >  net/rds/send.c | 6 +-----
> >  2 files changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/net/rds/rdma.c b/net/rds/rdma.c
> > index fba82d36593a..a4e3c5de998b 100644
> > --- a/net/rds/rdma.c
> > +++ b/net/rds/rdma.c
> > @@ -301,6 +301,9 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
> >  			kfree(sg);
> >  		}
> >  		ret = PTR_ERR(trans_private);
> > +		/* Trigger connection so that its ready for the next retry */
> > +		if (ret == -ENODEV)
> > +			rds_conn_connect_if_down(cp->cp_conn);
> 
> Hi Edward,
> 
> Elsewhere in this function it is assumed that cp may be NULL.
> Does that need to be taken into account here too?
Don't worry about this, if it is NULL, the get_mr() return value will not be -ENODEV.
> 
> Flagged by Smatch.
> 
> >  		goto out;
> >  	}
> >  
> > diff --git a/net/rds/send.c b/net/rds/send.c
> > index 5e57a1581dc6..fa1640628b2f 100644
> > --- a/net/rds/send.c
> > +++ b/net/rds/send.c
> > @@ -1313,12 +1313,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
> >  
> >  	/* Parse any control messages the user may have included. */
> >  	ret = rds_cmsg_send(rs, rm, msg, &allocated_mr, &vct);
> > -	if (ret) {
> > -		/* Trigger connection so that its ready for the next retry */
> > -		if (ret ==  -EAGAIN)
> > -			rds_conn_connect_if_down(conn);
> > +	if (ret) 
> 
> nit: checkpatch warns that there is a trailing space on the line above.
I will send a V2 version patch to correct this warning.

BR,
Edward
Simon Horman March 5, 2024, 12:20 p.m. UTC | #3
On Tue, Mar 05, 2024 at 08:12:03AM +0800, Edward Adam Davis wrote:
> On Mon, 4 Mar 2024 17:07:07 +0000, Simon Horman wrote:
> > > If connection isn't established yet, get_mr() will fail, trigger connection after
> > > get_mr().
> > > 
> > > Fixes: 584a8279a44a ("RDS: RDMA: return appropriate error on rdma map failures") 
> > > Reported-and-tested-by: syzbot+d4faee732755bba9838e@syzkaller.appspotmail.com
> > > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > > ---
> > >  net/rds/rdma.c | 3 +++
> > >  net/rds/send.c | 6 +-----
> > >  2 files changed, 4 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/net/rds/rdma.c b/net/rds/rdma.c
> > > index fba82d36593a..a4e3c5de998b 100644
> > > --- a/net/rds/rdma.c
> > > +++ b/net/rds/rdma.c
> > > @@ -301,6 +301,9 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
> > >  			kfree(sg);
> > >  		}
> > >  		ret = PTR_ERR(trans_private);
> > > +		/* Trigger connection so that its ready for the next retry */
> > > +		if (ret == -ENODEV)
> > > +			rds_conn_connect_if_down(cp->cp_conn);
> > 
> > Hi Edward,
> > 
> > Elsewhere in this function it is assumed that cp may be NULL.
> > Does that need to be taken into account here too?
> Don't worry about this, if it is NULL, the get_mr() return value will not be -ENODEV.

Thanks, understood.
diff mbox series

Patch

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index fba82d36593a..a4e3c5de998b 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -301,6 +301,9 @@  static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
 			kfree(sg);
 		}
 		ret = PTR_ERR(trans_private);
+		/* Trigger connection so that its ready for the next retry */
+		if (ret == -ENODEV)
+			rds_conn_connect_if_down(cp->cp_conn);
 		goto out;
 	}
 
diff --git a/net/rds/send.c b/net/rds/send.c
index 5e57a1581dc6..fa1640628b2f 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -1313,12 +1313,8 @@  int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
 
 	/* Parse any control messages the user may have included. */
 	ret = rds_cmsg_send(rs, rm, msg, &allocated_mr, &vct);
-	if (ret) {
-		/* Trigger connection so that its ready for the next retry */
-		if (ret ==  -EAGAIN)
-			rds_conn_connect_if_down(conn);
+	if (ret) 
 		goto out;
-	}
 
 	if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) {
 		printk_ratelimited(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n",