Message ID | 33abff2233b36a51e468d691cb4327d0294d2734.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 |
-----"Stefan Metzmacher" <metze@samba.org> wrote: ----- >To: "Bernard Metzler" <bmt@zurich.ibm.com> >From: "Stefan Metzmacher" <metze@samba.org> >Date: 05/07/2021 01:39AM >Cc: linux-rdma@vger.kernel.org, "Stefan Metzmacher" <metze@samba.org> >Subject: [EXTERNAL] [PATCH 22/31] rdma/siw: let siw_listen_address() >call siw_cep_set_inuse() early > >We should protect the whole section after siw_cep_alloc(). > >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 | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > >diff --git a/drivers/infiniband/sw/siw/siw_cm.c >b/drivers/infiniband/sw/siw/siw_cm.c >index fe6f7bb4d615..09ae7f7ca82a 100644 >--- a/drivers/infiniband/sw/siw/siw_cm.c >+++ b/drivers/infiniband/sw/siw/siw_cm.c >@@ -1920,6 +1920,8 @@ int siw_create_listen(struct iw_cm_id *id, int >backlog) > if (!cep) > return -ENOMEM; > >+ siw_cep_set_inuse(cep); >+ > rv = sock_create(addr_family, SOCK_STREAM, IPPROTO_TCP, &s); > if (rv < 0) { > siw_dbg(id->device, "sock_create error: %d\n", rv); >@@ -2014,13 +2016,12 @@ int siw_create_listen(struct iw_cm_id *id, >int backlog) > > siw_dbg(id->device, "Listen at laddr %pISp\n", &id->local_addr); > >+ siw_cep_set_free(cep); > return 0; > > error: > siw_dbg(id->device, "failed: %d\n", rv); > >- siw_cep_set_inuse(cep); >- > if (cep->cm_id) { > cep->cm_id->rem_ref(cep->cm_id); > cep->cm_id = NULL; >-- >2.25.1 > > Agreed, makes it easier to read. 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 fe6f7bb4d615..09ae7f7ca82a 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1920,6 +1920,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (!cep) return -ENOMEM; + siw_cep_set_inuse(cep); + rv = sock_create(addr_family, SOCK_STREAM, IPPROTO_TCP, &s); if (rv < 0) { siw_dbg(id->device, "sock_create error: %d\n", rv); @@ -2014,13 +2016,12 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) siw_dbg(id->device, "Listen at laddr %pISp\n", &id->local_addr); + siw_cep_set_free(cep); return 0; error: siw_dbg(id->device, "failed: %d\n", rv); - siw_cep_set_inuse(cep); - if (cep->cm_id) { cep->cm_id->rem_ref(cep->cm_id); cep->cm_id = NULL;
We should protect the whole section after siw_cep_alloc(). 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)