RDMA/ucma: Don't report events with invalid user context
authorSean Hefty <sean.hefty@intel.com>
Fri, 5 Jan 2007 20:35:15 +0000 (12:35 -0800)
committerRoland Dreier <rolandd@cisco.com>
Mon, 8 Jan 2007 04:20:08 +0000 (20:20 -0800)
commit0cefcf0bbc2d252eb48bff3289fb59c3817dd405
tree26e7a0e770ef20a6200d129cafe6669573f5a04b
parent30a5ec982e4cfa955f93c454debaefc4d61d2da6
RDMA/ucma: Don't report events with invalid user context

There's a problem with how rdma cm events are reported to userspace
that can lead to application crashes.

When a new connection request arrives, a context for the connection is
allocated in the kernel.  The connection event is then reported to
userspace.  The userspace library retrieves the event and allocates
its own context for the connection.  The userspace context is
associated with the kernel's context when accepting.  This allows the
kernel to give userspace context with other events.

A problem occurs if a second event for the same connection occurs
before the user has had a chance to call accept.  The userspace
context has not yet been set, which causes the librdmacm to crash.
(This has been seen when the app takes too long to call accept,
resulting in the remote side timing out and rejecting the connection)

Fix this by ignoring events for new connections until userspace has
set their context.  This can only happen if an error occurs on a new
connection before the user accepts it.  This is okay, since the accept
will just fail later.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/ucma.c