]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
RDS: IB: Destroy rdma_cm_id when unloading module
authorAvinash Repaka <avinash.repaka@oracle.com>
Fri, 21 Oct 2016 22:34:19 +0000 (15:34 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 13 Sep 2017 04:29:39 +0000 (21:29 -0700)
rdma_cm_id is not being destroyed as part of module_exit(). This would
lead to memory corruption and eventual node crash if rds_rdma module is
unloaded.

To avoid this, stop listening(destroy rdma_cm_id) as the first step of
unloading the module and curb any more connection attempts.

This undoes the change made by commit 4d4692145bf7 ("RDS: Drop stale
iWARP support")

Orabug: 26089296

Signed-off-by: Avinash Repaka <avinash.repaka@oracle.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
net/rds/rdma_transport.c

index 1cd260a0f8f97af2a3fb8d0dfe81ac90a5db9ac6..2d673a1e09c3f14460dfcadbc03cf5f218d7b5a8 100644 (file)
@@ -44,6 +44,8 @@
 
 #define RDS_REJ_CONSUMER_DEFINED 28
 
+static struct rdma_cm_id *rds_rdma_listen_id;
+
 int unload_allowed __initdata;
 
 module_param_named(module_unload_allowed, unload_allowed, int, 0);
@@ -385,6 +387,7 @@ static int rds_rdma_listen_init(void)
 
        rdsdebug("cm %p listening on port %u\n", cm_id, RDS_PORT);
 
+       rds_rdma_listen_id = cm_id;
        cm_id = NULL;
 out:
        if (cm_id)
@@ -392,6 +395,15 @@ out:
        return ret;
 }
 
+static void rds_rdma_listen_stop(void)
+{
+       if (rds_rdma_listen_id) {
+               rdsdebug("cm %p\n", rds_rdma_listen_id);
+               rdma_destroy_id(rds_rdma_listen_id);
+               rds_rdma_listen_id = NULL;
+       }
+}
+
 #define MODULE_NAME "rds_rdma"
 
 int __init rds_rdma_init(void)
@@ -427,6 +439,8 @@ module_init(rds_rdma_init);
 
 void rds_rdma_exit(void)
 {
+       /* stop listening first to ensure no new connections are attempted */
+       rds_rdma_listen_stop();
        /* cancel initial ib failover work if still active*/
        cancel_delayed_work_sync(&riif_dlywork);
        rds_ib_exit();