Message ID | cb0c051ce8001ec125c74148e172bfba2be831be.1620343860.git.metze@samba.org (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | rdma/siw: fix a lot of deadlocks and use after free bugs | expand |
--- Bernard Metzler, PhD Tech. Leader High Performance I/O, Principal Research Staff IBM Zurich Research Laboratory Saeumerstrasse 4 CH-8803 Rueschlikon, Switzerland +41 44 724 8605 -----"Stefan Metzmacher" <metze@samba.org> wrote: ----- >To: "Bernard Metzler" <bmt@zurich.ibm.com> >From: "Stefan Metzmacher" <metze@samba.org> >Date: 05/07/2021 01:37AM >Cc: linux-rdma@vger.kernel.org, "Stefan Metzmacher" <metze@samba.org> >Subject: [EXTERNAL] [PATCH 05/31] rdma/siw: make use of >kernel_{bind,connect,listen}() > >That's nicer than dereferencing socket structures. > >This prepares making rdma_connect()/siw_connect() non-blocking >in order to avoid deadlocks in the callers. > >Fixes: 6c52fdc244b5 ("rdma/siw: connection management") >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Cc: Bernard Metzler <bmt@zurich.ibm.com> >Cc: linux-rdma@vger.kernel.org >--- > drivers/infiniband/sw/siw/siw_cm.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > >diff --git a/drivers/infiniband/sw/siw/siw_cm.c >b/drivers/infiniband/sw/siw/siw_cm.c >index 145ab6e4e0ed..e21cde84306e 100644 >--- a/drivers/infiniband/sw/siw/siw_cm.c >+++ b/drivers/infiniband/sw/siw/siw_cm.c >@@ -1319,11 +1319,11 @@ static int kernel_bindconnect(struct socket >*s, struct sockaddr *laddr, > return rv; > } > >- rv = s->ops->bind(s, laddr, size); >+ rv = kernel_bind(s, laddr, size); > if (rv < 0) > return rv; > >- rv = s->ops->connect(s, raddr, size, flags); >+ rv = kernel_connect(s, raddr, size, flags); > > return rv < 0 ? rv : 0; > } >@@ -1787,8 +1787,8 @@ int siw_create_listen(struct iw_cm_id *id, int >backlog) > if (ipv4_is_zeronet(laddr->sin_addr.s_addr)) > s->sk->sk_bound_dev_if = sdev->netdev->ifindex; > >- rv = s->ops->bind(s, (struct sockaddr *)laddr, >- sizeof(struct sockaddr_in)); >+ rv = kernel_bind(s, (struct sockaddr *)laddr, >+ sizeof(struct sockaddr_in)); > } else { > struct sockaddr_in6 *laddr = &to_sockaddr_in6(id->local_addr); > >@@ -1805,8 +1805,8 @@ int siw_create_listen(struct iw_cm_id *id, int >backlog) > if (ipv6_addr_any(&laddr->sin6_addr)) > s->sk->sk_bound_dev_if = sdev->netdev->ifindex; > >- rv = s->ops->bind(s, (struct sockaddr *)laddr, >- sizeof(struct sockaddr_in6)); >+ rv = kernel_bind(s, (struct sockaddr *)laddr, >+ sizeof(struct sockaddr_in6)); > } > if (rv) { > siw_dbg(id->device, "socket bind error: %d\n", rv); >@@ -1826,7 +1826,7 @@ int siw_create_listen(struct iw_cm_id *id, int >backlog) > rv, backlog); > goto error; > } >- rv = s->ops->listen(s, backlog); >+ rv = kernel_listen(s, backlog); > if (rv) { > siw_dbg(id->device, "listen error %d\n", rv); > goto error; >-- >2.25.1 > > Yes, thanks. Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 145ab6e4e0ed..e21cde84306e 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1319,11 +1319,11 @@ static int kernel_bindconnect(struct socket *s, struct sockaddr *laddr, return rv; } - rv = s->ops->bind(s, laddr, size); + rv = kernel_bind(s, laddr, size); if (rv < 0) return rv; - rv = s->ops->connect(s, raddr, size, flags); + rv = kernel_connect(s, raddr, size, flags); return rv < 0 ? rv : 0; } @@ -1787,8 +1787,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (ipv4_is_zeronet(laddr->sin_addr.s_addr)) s->sk->sk_bound_dev_if = sdev->netdev->ifindex; - rv = s->ops->bind(s, (struct sockaddr *)laddr, - sizeof(struct sockaddr_in)); + rv = kernel_bind(s, (struct sockaddr *)laddr, + sizeof(struct sockaddr_in)); } else { struct sockaddr_in6 *laddr = &to_sockaddr_in6(id->local_addr); @@ -1805,8 +1805,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (ipv6_addr_any(&laddr->sin6_addr)) s->sk->sk_bound_dev_if = sdev->netdev->ifindex; - rv = s->ops->bind(s, (struct sockaddr *)laddr, - sizeof(struct sockaddr_in6)); + rv = kernel_bind(s, (struct sockaddr *)laddr, + sizeof(struct sockaddr_in6)); } if (rv) { siw_dbg(id->device, "socket bind error: %d\n", rv); @@ -1826,7 +1826,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) rv, backlog); goto error; } - rv = s->ops->listen(s, backlog); + rv = kernel_listen(s, backlog); if (rv) { siw_dbg(id->device, "listen error %d\n", rv); goto error;
That's nicer than dereferencing socket structures. This prepares making rdma_connect()/siw_connect() non-blocking in order to avoid deadlocks in the callers. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher <metze@samba.org> Cc: Bernard Metzler <bmt@zurich.ibm.com> Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)