Patch "cifs: unlock chan_lock before calling cifs_put_tcp_session" has been added to the 5.16-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

    cifs: unlock chan_lock before calling cifs_put_tcp_session

to the 5.16-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:
     cifs-unlock-chan_lock-before-calling-cifs_put_tcp_se.patch
and it can be found in the queue-5.16 subdirectory.

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



commit 64b09ba8409b4f559cf94c0f4008ea50dac37a67
Author: Shyam Prasad N <sprasad@xxxxxxxxxxxxx>
Date:   Sat Jan 29 09:32:33 2022 +0000

    cifs: unlock chan_lock before calling cifs_put_tcp_session
    
    [ Upstream commit 489f710a738e24d887823a010b8b206b4124e26f ]
    
    While removing an smb session, we need to free up the
    tcp session for each channel for that session. We were
    doing this with chan_lock held. This results in a
    cyclic dependency with cifs_tcp_ses_lock.
    
    For now, unlock the chan_lock temporarily before calling
    cifs_put_tcp_session. This should not cause any problem
    for now, since we do not remove channels anywhere else.
    And this code segment will not be called by two threads.
    
    When we do implement the code for removing channels, we
    will need to execute proper ref counting here.
    
    Signed-off-by: Shyam Prasad N <sprasad@xxxxxxxxxxxxx>
    Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index cefd0e9623ba9..fb69524a992bb 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1796,13 +1796,9 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
 		int i;
 
 		for (i = 1; i < chan_count; i++) {
-			/*
-			 * note: for now, we're okay accessing ses->chans
-			 * without chan_lock. But when chans can go away, we'll
-			 * need to introduce ref counting to make sure that chan
-			 * is not freed from under us.
-			 */
+			spin_unlock(&ses->chan_lock);
 			cifs_put_tcp_session(ses->chans[i].server, 0);
+			spin_lock(&ses->chan_lock);
 			ses->chans[i].server = NULL;
 		}
 	}



[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