Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0cefcf0bbc2d252eb48bff3289fb59c3817dd405
Commit:     0cefcf0bbc2d252eb48bff3289fb59c3817dd405
Parent:     30a5ec982e4cfa955f93c454debaefc4d61d2da6
Author:     Sean Hefty <[EMAIL PROTECTED]>
AuthorDate: Fri Jan 5 12:35:15 2007 -0800
Committer:  Roland Dreier <[EMAIL PROTECTED]>
CommitDate: Sun Jan 7 20:20:08 2007 -0800

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Roland Dreier <[EMAIL PROTECTED]>
---
 drivers/infiniband/core/ucma.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 9f30f9b..e2e8d32 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -213,7 +213,17 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id,
                        goto out;
                }
                ctx->backlog--;
+       } else if (!ctx->uid) {
+               /*
+                * We ignore 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.
+                */
+               kfree(uevent);
+               goto out;
        }
+
        list_add_tail(&uevent->list, &ctx->file->event_list);
        wake_up_interruptible(&ctx->file->poll_wait);
 out:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to