Skip to contentSkip to conversation

iser-target: Fix possible use-after-free in connection establishment error

PATCH In review Sagi Grimberg 8 participants 12 messages Nov 26, 2017 – Jan 14, 2018 4 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iser-target: Fix possible use-after-free in connection establishment error

In case we fail to establish the connection we must drain our pre-posted login recieve work request before continuing safely with connection teardown.

---
 drivers/infiniband/ulp/isert/ib_isert.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/ulp/isert/ib_isert.c +1 -0
index ceabdb85df8b..9d4785ba24cb 100644
@@ -741,6 +741,7 @@ isert_connect_error(struct rdma_cm_id *cma_id)
 {
 	struct isert_conn *isert_conn = cma_id->qp->qp_context;
 
+	ib_drain_qp(isert_conn->qp);
 	list_del_init(&isert_conn->node);
 	isert_conn->cm_id = NULL;
 	isert_put_conn(isert_conn);
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20171126133104.22710-1-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org

#2 lore raw

Oops,

This should go via the target tree, CCing target-devel and nab

Quoted 16 lines · Sagi Grimberg

In case we fail to establish the connection we must drain our pre-posted login recieve work request before continuing safely with connection teardown.

---
  drivers/infiniband/ulp/isert/ib_isert.c | 1 +
  1 file changed, 1 insertion(+)
drivers/infiniband/ulp/isert/ib_isert.c +0 -0
index ceabdb85df8b..9d4785ba24cb 100644

drivers/infiniband/ulp/isert/ib_isert.c isert_connect_error(struct rdma_cm_id *cma_id) · line 747

Quoted 7 lines
drivers/infiniband/ulp/isert/ib_isert.c +1 -0
@@ -741,6 +741,7 @@ isert_connect_error(struct rdma_cm_id *cma_id)
  {
  	struct isert_conn *isert_conn = cma_id->qp->qp_context;
 
+	ib_drain_qp(isert_conn->qp);
  	list_del_init(&isert_conn->node);
  	isert_conn->cm_id = NULL;
  	isert_put_conn(isert_conn);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 19 lines · Sagi Grimberg
Quoted 18 lines

In case we fail to establish the connection we must drain our pre-posted login recieve work request before continuing safely with connection teardown.

---
  drivers/infiniband/ulp/isert/ib_isert.c | 1 +
  1 file changed, 1 insertion(+)
drivers/infiniband/ulp/isert/ib_isert.c +0 -0
index ceabdb85df8b..9d4785ba24cb 100644
@@ -741,6 +741,7 @@ isert_connect_error(struct rdma_cm_id *cma_id)
  {
  	struct isert_conn *isert_conn = cma_id->qp->qp_context;
 
Quoted 4 lines

drivers/infiniband/ulp/isert/ib_isert.c isert_connect_error(struct rdma_cm_id *cma_id) · line 747

Quoted 4 lines
drivers/infiniband/ulp/isert/ib_isert.c +1 -0
+	ib_drain_qp(isert_conn->qp);
  	list_del_init(&isert_conn->node);
  	isert_conn->cm_id = NULL;
  	isert_put_conn(isert_conn);

With this patch our test behaves as expected.

Thanks,
Ram

A message that is not in the archive (sent off-list or not yet received): 3676820c-544e-8ced-859a-ade8e6a0ef53-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org

#5 lore raw

SGkgU2FnaSwNCg0KPiA+IFJlcG9ydGVkLWJ5OiBBbXJhbmksIFJhbSA8UmFtLkFtcmFuaUBjYXZp dW0uY29tPg0KPiA+IFNpZ25lZC1vZmYtYnk6IFNhZ2kgR3JpbWJlcmcgPHNhZ2lAZ3JpbWJlcmcu bWU+DQo+ID4gLS0tDQo+ID4gICBkcml2ZXJzL2luZmluaWJhbmQvdWxwL2lzZXJ0L2liX2lzZXJ0 LmMgfCAxICsNCj4gPiAgIDEgZmlsZSBjaGFuZ2VkLCAxIGluc2VydGlvbigrKQ0KPiA+DQo+ID4g ZGlmZiAtLWdpdCBhL2RyaXZlcnMvaW5maW5pYmFuZC91bHAvaXNlcnQvaWJfaXNlcnQuYyBiL2Ry aXZlcnMvaW5maW5pYmFuZC91bHAvaXNlcnQvaWJfaXNlcnQuYw0KPiA+IGluZGV4IGNlYWJkYjg1 ZGY4Yi4uOWQ0Nzg1YmEyNGNiIDEwMDY0NA0KPiA+IC0tLSBhL2RyaXZlcnMvaW5maW5pYmFuZC91 bHAvaXNlcnQvaWJfaXNlcnQuYw0KPiA+ICsrKyBiL2RyaXZlcnMvaW5maW5pYmFuZC91bHAvaXNl cnQvaWJfaXNlcnQuYw0KPiA+IEBAIC03NDEsNiArNzQxLDcgQEAgaXNlcnRfY29ubmVjdF9lcnJv cihzdHJ1Y3QgcmRtYV9jbV9pZCAqY21hX2lkKQ0KPiA+ICAgew0KPiA+ICAgCXN0cnVjdCBpc2Vy dF9jb25uICppc2VydF9jb25uID0gY21hX2lkLT5xcC0+cXBfY29udGV4dDsNCj4gPg0KPiA+ICsJ aWJfZHJhaW5fcXAoaXNlcnRfY29ubi0+cXApOw0KPiA+ICAgCWxpc3RfZGVsX2luaXQoJmlzZXJ0 X2Nvbm4tPm5vZGUpOw0KPiA+ICAgCWlzZXJ0X2Nvbm4tPmNtX2lkID0gTlVMTDsNCj4gPiAgIAlp c2VydF9wdXRfY29ubihpc2VydF9jb25uKTsNCj4gPg0KPiAtLQ0KDQpJZiBpdCdzIG5vdCBhbHJl YWR5IGNvbW1pdHRlZCwgY2FuIHlvdSBhZGQgYSAiRml4ZXM6IiBzbyBzdGFibGUgbWFpbnRhaW5l cnMgd2lsbCBjYXRjaCBpdD8NCg0KVGhhbmtzLA0KUmFtDQoNCg==
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw
Quoted 2 lines

If it's not already committed, can you add a "Fixes:" so stable maintainers will catch it?

I'm not sure at all that there is a clear cut commit that this fixes, both the target code and the rdma interface code changed a lot so I can't find any clear indication which broke this.

I can send a separate patch to stable from when we introduced ib_drain_qp though.

#7 lore raw

hi Guys,
did we forget taking this fix to mainline/stable or we found another solution ?

Quoted 14 lines · Sagi Grimberg
Quoted 2 lines

If it's not already committed, can you add a "Fixes:" so stable maintainers will catch it?

I'm not sure at all that there is a clear cut commit that this fixes, both the target code and the rdma interface code changed a lot so I can't find any clear indication which broke this.

I can send a separate patch to stable from when we introduced ib_drain_qp though.

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to [email protected]
More majordomo info at  https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvger.kernel.org%2Fmajordomo-info.html&data=02%7C01%7Cmaxg%40mellanox.com%7C18cac1be99bb4d99661c08d5377b08c6%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636475923920075321&sdata=WDJ6wr2o8jFyyGdHcLo06EhE18GTz9wUbF%2BezWzkGbc%3D&reserved=0 

-Max.

#8 lore raw
Quoted 3 lines · Max Gurtovoy

hi Guys,
did we forget taking this fix to mainline/stable or we found another solution ?

I thought it was going to NAB's tree.. My mistake, I put it back into patchworks and it will get into for-next

Jason

A message that is not in the archive (sent off-list or not yet received): 20180109171718.GC4518-uk2M96/[email protected]

#10 lore raw
Quoted 4 lines

I thought it was going to NAB's tree.. My mistake, I put it back into patchworks and it will get into for-next

Jason

Thanks.
BTW, you can use for-rc, as it is a bug fix.

Ram

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
In reply to Jason Gunthorpe
Quoted 7 lines · Jason Gunthorpe
Quoted 3 lines · Max Gurtovoy

hi Guys,
did we forget taking this fix to mainline/stable or we found another solution ?

I thought it was going to NAB's tree.. My mistake, I put it back into patchworks and it will get into for-next

In fairness, the email thread said exactly that. But, it never got picked up by NAB. And being that it's in our tree and calling an rdma- core function, it can easily enough go through our tree, so I applied it to for-rc.

Signature · 3 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD
#12 lore raw
Quoted 6 lines · Doug Ledford
Quoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Max Gurtovoy

hi Guys,
did we forget taking this fix to mainline/stable or we found another solution ?

Quoted 7 lines
Quoted 2 lines

I thought it was going to NAB's tree.. My mistake, I put it back into patchworks and it will get into for-next

In fairness, the email thread said exactly that. But, it never got picked up by NAB. And being that it's in our tree and calling an rdma- core function, it can easily enough go through our tree, so I applied it to for-rc.

Thanks Sagi + Ram, and Doug for picking this up.

Per the earlier discussion, it looks like this needs a stable CC, right..? As Sagi mentioned, it's not clear if this is a regression vs. generic RDMA READ/WRITE API logic, or a day one issue.

So how about adding a 4.7+ stable tag, to match commit a060b5629..?

#13 lore raw
Quoted 15 lines · Nicholas A. Bellinger
Quoted 6 lines · Doug Ledford
Quoted 5 lines · Jason Gunthorpe
Quoted 3 lines · Max Gurtovoy

hi Guys,
did we forget taking this fix to mainline/stable or we found another solution ?

Quoted 7 lines
Quoted 2 lines

I thought it was going to NAB's tree.. My mistake, I put it back into patchworks and it will get into for-next

In fairness, the email thread said exactly that. But, it never got picked up by NAB. And being that it's in our tree and calling an rdma- core function, it can easily enough go through our tree, so I applied it to for-rc.

Quoted 7 lines

Thanks Sagi + Ram, and Doug for picking this up.

Per the earlier discussion, it looks like this needs a stable CC, right..? As Sagi mentioned, it's not clear if this is a regression vs. generic RDMA READ/WRITE API logic, or a day one issue.

So how about adding a 4.7+ stable tag, to match commit a060b5629..?

That can be done:

Fixes a060b5629ab0 ("IB/core: generic RDMA READ/WRITE API")
Cc <[email protected]> # 4.7+

Doug: I took your wip/dl-for-rc branch, revised the commit message and pushed it to for-rc.

Jason

A message that is not in the archive (sent off-list or not yet received): 20180113180841.GB32353-uk2M96/[email protected]

#15 lore raw

Thanks Jason for picking it up, and sorry for the
late reply on this.

Quoted 3 lines

That can be done:

Fixes a060b5629ab0 ("IB/core: generic RDMA READ/WRITE API")

This patch is not the offending patch, if at all its this one:

Fixes 572a143489a1 ("iser-target: Use ib_drain_qp")

But, the missing qp drain existed way before this commit.
I think any fixes tag would be confusing as there isn't a clear culprit for this one...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html