Patch "RDMA/rtrs-clt: destroy sysfs after removing session from active list" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    RDMA/rtrs-clt: destroy sysfs after removing session from active list

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rdma-rtrs-clt-destroy-sysfs-after-removing-session-f.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 432ac735a83e056e92a2273b9f24efed85ae5138
Author: Gioh Kim <gi-oh.kim@xxxxxxxxx>
Date:   Mon Apr 12 10:40:02 2021 +0200

    RDMA/rtrs-clt: destroy sysfs after removing session from active list
    
    [ Upstream commit 7f4a8592ff29f19c5a2ca549d0973821319afaad ]
    
    A session can be removed dynamically by sysfs interface "remove_path" that
    eventually calls rtrs_clt_remove_path_from_sysfs function.  The current
    rtrs_clt_remove_path_from_sysfs first removes the sysfs interfaces and
    frees sess->stats object. Second it removes the session from the active
    list.
    
    Therefore some functions could access non-connected session and access the
    freed sess->stats object even-if they check the session status before
    accessing the session.
    
    For instance rtrs_clt_request and get_next_path_min_inflight check the
    session status and try to send IO to the session.  The session status
    could be changed when they are trying to send IO but they could not catch
    the change and update the statistics information in sess->stats object,
    and generate use-after-free problem.
    (see: "RDMA/rtrs-clt: Check state of the rtrs_clt_sess before reading its
    stats")
    
    This patch changes the rtrs_clt_remove_path_from_sysfs to remove the
    session from the active session list and then destroy the sysfs
    interfaces.
    
    Each function still should check the session status because closing or
    error recovery paths can change the status.
    
    Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
    Link: https://lore.kernel.org/r/20210412084002.33582-1-gi-oh.kim@xxxxxxxxx
    Signed-off-by: Gioh Kim <gi-oh.kim@xxxxxxxxx>
    Reviewed-by: Jack Wang <jinpu.wang@xxxxxxxxx>
    Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 6ff97fbf8756..7db550ba25d7 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -2803,8 +2803,8 @@ int rtrs_clt_remove_path_from_sysfs(struct rtrs_clt_sess *sess,
 	} while (!changed && old_state != RTRS_CLT_DEAD);
 
 	if (likely(changed)) {
-		rtrs_clt_destroy_sess_files(sess, sysfs_self);
 		rtrs_clt_remove_path_from_arr(sess);
+		rtrs_clt_destroy_sess_files(sess, sysfs_self);
 		kobject_put(&sess->kobj);
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux