Skip to contentSkip to conversation

crash in librdmacm

DISCUSSION Bernd Schubert 3 participants 5 messages Jan 31, 2013 – Feb 1, 2013 3 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

Hi all,

we got a bug report from a customer that FhGFS server daemons frequently crash. Looking into it, we are almost sure it is related to librdmacm/kernel-ib. So the crash in librdmacm resolves to:

Quoted 4 lines

(gdb) l *(rdma_get_cm_event+0x102) 0x3d6dc04522 is in rdma_get_cm_event (src/cma.c:1975).
1970 break;
1971 default:

Quoted 8 lines
1972                    evt->id_priv = (void *) (uintptr_t) resp.uid;
1973                    evt->event.id = &evt->id_priv->id;
1974                    evt->event.status = resp.status;
1975                    if (ucma_is_ud_qp(evt->id_priv->id.qp_type))

1976 ucma_copy_ud_event(evt, &resp.param.ud);
1977 else
1978 ucma_copy_conn_event(evt, &resp.param.conn);
1979 break;

Now the complete shows that the issue comes up directly after initiating a connection and we are just querying the file descriptor for events. So from our point of view there is not much we can do about it.

Possibly this is already fixed by commit 418edaaba96e58112b15c82b4907084e2a9caf42 and this commit is also not yet in the latest RHEL kernel being used on the customer system. However, the commit messages states it is for RDMA_CM_EVENT_ESTABLISHED only, while the resolved address above points to another event. Does the commit really on fix this event or would it also fix further events?

While looking where file->mut is being set, I notice that in ucma_create_id() the call of ucma_alloc_ctx() is protected by a mutex, but the mutex is immediately given up after that call. In ucma_alloc_ctx() the ctx is already added to file->ctx_list, but the ctx->uid and ctx->cm_id are then modified outside a mutex in ucma_create_id(). Shouldn't the mutex_unlock() be done after assigning those values?

Looking further, I also notice that 'enum rdma_cm_event_type' does not initialize a single value. AFAIK, according to the C standard at least the first value has to be initialized, otherwise the compiler is free to assign random values. This is certainly fine for in-kernel enums, however, as kernel and user space need to use the same numbers this probably should be improved. Shall I write a patch, assigning the first value to 0 for kernel and lib definitions?

Thanks,
Bernd

--
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 (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e 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
In reply to a message not in the archive

PiB3ZSBnb3QgYSBidWcgcmVwb3J0IGZyb20gYSBjdXN0b21lciB0aGF0IEZoR0ZTIHNlcnZlciBk YWVtb25zIGZyZXF1ZW50bHkNCj4gY3Jhc2guIExvb2tpbmcgaW50byBpdCwgd2UgYXJlIGFsbW9z dCBzdXJlIGl0IGlzIHJlbGF0ZWQgdG8NCj4gbGlicmRtYWNtL2tlcm5lbC1pYi4gU28gdGhlIGNy YXNoIGluIGxpYnJkbWFjbSByZXNvbHZlcyB0bzoNCj4gDQo+ID4gKGdkYikgbCAqKHJkbWFfZ2V0 X2NtX2V2ZW50KzB4MTAyKQ0KPiA+IDB4M2Q2ZGMwNDUyMiBpcyBpbiByZG1hX2dldF9jbV9ldmVu dCAoc3JjL2NtYS5jOjE5NzUpLg0KPiA+IDE5NzAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0K PiA+IDE5NzEgICAgICAgICAgICBkZWZhdWx0Og0KPiA+IDE5NzIgICAgICAgICAgICAgICAgICAg IGV2dC0+aWRfcHJpdiA9ICh2b2lkICopICh1aW50cHRyX3QpIHJlc3AudWlkOw0KPiA+IDE5NzMg ICAgICAgICAgICAgICAgICAgIGV2dC0+ZXZlbnQuaWQgPSAmZXZ0LT5pZF9wcml2LT5pZDsNCj4g PiAxOTc0ICAgICAgICAgICAgICAgICAgICBldnQtPmV2ZW50LnN0YXR1cyA9IHJlc3Auc3RhdHVz Ow0KPiA+IDE5NzUgICAgICAgICAgICAgICAgICAgIGlmICh1Y21hX2lzX3VkX3FwKGV2dC0+aWRf cHJpdi0+aWQucXBfdHlwZSkpDQo+ID4gMTk3NiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1 Y21hX2NvcHlfdWRfZXZlbnQoZXZ0LCAmcmVzcC5wYXJhbS51ZCk7DQo+ID4gMTk3NyAgICAgICAg ICAgICAgICAgIC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3NpZ25pbmcNCj4g dGhvc2UgdmFsdWVzPw0KDQpJdCBzaG91bGRuJ3QgbWF0dGVyLCBhcyBsb25nIGFzIHRoZSB1aWQg YW5kIGNtX2lkIGFyZSBzZXQgYmVmb3JlIGFueSBldmVudHMgY2FuIGJlIGdlbmVyYXRlZC4gIEV2 ZW50cyBhcmUgbm90IGdlbmVyYXRlZCBvbiBuZXdseSBjcmVhdGVkIGlkJ3MuDQogDQotIFNlYW4N Cg==
--
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): 1828884A29C6694DAF28B7E6B8A8237357D423D5-P5GAC/[email protected]

#5 lore raw
Quoted 29 lines · Sean
Quoted 21 lines

we got a bug report from a customer that FhGFS server daemons frequently crash. Looking into it, we are almost sure it is related to librdmacm/kernel-ib. So the crash in librdmacm resolves to:

Quoted 10 lines

(gdb) l *(rdma_get_cm_event+0x102) 0x3d6dc04522 is in rdma_get_cm_event (src/cma.c:1975). 1970
break; 1971 default: 1972
evt->id_priv = (void *) (uintptr_t) resp.uid; 1973 evt->event.id = &evt->id_priv->id; 1974
evt->event.status = resp.status; 1975 if
(ucma_is_ud_qp(evt->id_priv->id.qp_type)) 1976 ucma_copy_ud_event(evt, &resp.param.ud); 1977
else 1978 ucma_copy_conn_event(evt,
&resp.param.conn); 1979 break;

Now the complete shows that the issue comes up directly after initiating a connection and we are just querying the file descriptor for events. So from our point of view there is not much we can do about it.

Quoted 7 lines

Possibly this is already fixed by commit 418edaaba96e58112b15c82b4907084e2a9caf42 and this commit is also not yet in the latest RHEL kernel being used on the customer system. However, the commit messages states it is for RDMA_CM_EVENT_ESTABLISHED only, while the resolved address above points to another event. Does the commit really on fix this event or would it also fix further events?

Quoted 8 lines

The above commit fixes an issue where the uid can be returned 0 from the kernel.

A call to resolve an address should not have this issue. The issue is limited to connections formed from a listen request. The reason for this is that passive side connections create the kernel id first, which is then linked up with the user space id. Active side processing creates the user space id, then the kernel id.

Hmm, I think there is a misunderstanding. Actually I meant the server side, so indeed the connection and crash are formed from the listen request. Could we somehow also fix or at least catch the issue from librdmacm, e.g. by checking for uid=0, see the patch below? Probably the patch is not sufficient, as the event needs to be deleted somehow, is there a way to do that without further processing it?

Quoted 11 lines
Quoted 7 lines

While looking where file->mut is being set, I notice that in ucma_create_id() the call of ucma_alloc_ctx() is protected by a mutex, but the mutex is immediately given up after that call. In ucma_alloc_ctx() the ctx is already added to file->ctx_list, but the ctx->uid and ctx->cm_id are then modified outside a mutex in ucma_create_id(). Shouldn't the mutex_unlock() be done after assigning those values?

It shouldn't matter, as long as the uid and cm_id are set before any events can be generated. Events are not generated on newly created id's.

Ah, thanks.

Thanks,
Bernd

rdma_get_cm_event: Check for a 0 uid

---
 src/cma.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
src/cma.c +14 -0
index ff9b426..236cbd9 100755
@@ -1929,6 +1929,8 @@ retry:
 		break;
 	case RDMA_CM_EVENT_CONNECT_REQUEST:
 		evt->id_priv = (void *) (uintptr_t) resp.uid;
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		if (ucma_is_ud_qp(evt->id_priv->id.qp_type))
 			ucma_copy_ud_event(evt, &resp.param.ud);
 		else
@@ -1941,6 +1943,8 @@ retry:
 	case RDMA_CM_EVENT_CONNECT_RESPONSE:
 		ucma_copy_conn_event(evt, &resp.param.conn);
 		evt->event.status = ucma_process_conn_resp(evt->id_priv);
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		if (!evt->event.status)
 			evt->event.event = RDMA_CM_EVENT_ESTABLISHED;
 		else {
@@ -1949,6 +1953,8 @@ retry:
 		}
 		break;
 	case RDMA_CM_EVENT_ESTABLISHED:
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		if (ucma_is_ud_qp(evt->id_priv->id.qp_type)) {
 			ucma_copy_ud_event(evt, &resp.param.ud);
 			break;
@@ -1957,6 +1963,8 @@ retry:
 		ucma_copy_conn_event(evt, &resp.param.conn);
 		break;
 	case RDMA_CM_EVENT_REJECTED:
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		if (evt->id_priv->connect_error) {
 			ucma_complete_event(evt->id_priv);
 			goto retry;
@@ -1965,6 +1973,8 @@ retry:
 		ucma_modify_qp_err(evt->event.id);
 		break;
 	case RDMA_CM_EVENT_DISCONNECTED:
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		if (evt->id_priv->connect_error) {
 			ucma_complete_event(evt->id_priv);
 			goto retry;
@@ -1974,6 +1984,8 @@ retry:
 	case RDMA_CM_EVENT_MULTICAST_JOIN:
 		evt->mc = (void *) (uintptr_t) resp.uid;
 		evt->id_priv = evt->mc->id_priv;
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		evt->event.id = &evt->id_priv->id;
 		ucma_copy_ud_event(evt, &resp.param.ud);
 		evt->event.param.ud.private_data = evt->mc->context;
@@ -1989,6 +2001,8 @@ retry:
 		break;
 	default:
 		evt->id_priv = (void *) (uintptr_t) resp.uid;
+		if (!evt->id_priv)
+			return ERR(EINVAL); /* kernel bug? */
 		evt->event.id = &evt->id_priv->id;
 		evt->event.status = resp.status;
 		if (ucma_is_ud_qp(evt->id_priv->id.qp_type))

--
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): 510BFD0F.1060803-mPn0NPGs4xGatNDF+KUbs4QuADTiUCJX@public.gmane.org

#7 lore raw

PiBDb3VsZCB3ZSBzb21laG93IGFsc28gZml4IG9yIGF0IGxlYXN0IGNhdGNoIHRoZSBpc3N1ZSBm cm9tIGxpYnJkbWFjbSwgZS5nLg0KPiBieSBjaGVja2luZyBmb3IgdWlkPTAsIHNlZSB0aGUgcGF0 Y2ggYmVsb3c/IFByb2JhYmx5IHRoZSBwYXRjaCBpcyBub3QNCj4gc3VmZmljaWVudCwgYXMgdGhl IGV2ZW50IG5lZWRzIHRvIGJlIGRlbGV0ZWQgc29tZWhvdywgaXMgdGhlcmUgYSB3YXkgdG8gZG8N Cj4gdGhhdCB3aXRob3V0IGZ1cnRoZXIgcHJvY2Vzc2luZyBpdD8NCg0KRXhjZWxsZW50IGlkZWEh ICBJdCBzaG91bGQgYmUgc2FmZSB0byBpZ25vcmUgZXJyb3IgZXZlbnRzIHdoZXJlIHRoZSB1aWQg aXMgbm90IHNldC4gIEkgd2FudCB0byBzZWUgaWYgdGhlcmUncyBhIHdheSB0byBoYW5kbGUgJ2dv b2QnIGV2ZW50cyB3aGVyZSB0aGUgdWlkIGlzIG5vdCBzZXQsIHBvc3NpYmx5IGJ5IHNlYXJjaGlu ZyBmb3IgdGhlIGNvcnJlY3QgdXNlciBzcGFjZSBpZCB1c2luZyBhZGRyZXNzIGluZm9ybWF0aW9u LiAgSSdtIGNvbmNlcm5lZCB0aGF0IGRpc2NhcmRpbmcgc3VjaCBldmVudHMgY291bGQgcmVzdWx0 IGluIGNsaWVudHMgaGFuZ2luZywgd2FpdGluZyBmb3Igc29tZSBldmVudCB0aGF0IG5ldmVyIG9j Y3Vycy4NCg0KLSBTZWFuDQoNCg==
--
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