]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: fix potential race in cifs_put_tcon()
authorPaulo Alcantara <pc@manguebit.com>
Fri, 6 Dec 2024 14:49:07 +0000 (11:49 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:35:22 +0000 (18:35 +0200)
commit c32b624fa4f7ca5a2ff217a0b1b2f1352bb4ec11 upstream.

dfs_cache_refresh() delayed worker could race with cifs_put_tcon(), so
make sure to call list_replace_init() on @tcon->dfs_ses_list after
kworker is cancelled or finished.

Fixes: 4f42a8b54b5c ("smb: client: fix DFS interlink failover")
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/client/connect.c

index 33a292dabdb879406112e1e25333b14b14774b37..0588896c44567d4efeb5f1882a426dd5e4fc8812 100644 (file)
@@ -2557,9 +2557,6 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
 
        list_del_init(&tcon->tcon_list);
        tcon->status = TID_EXITING;
-#ifdef CONFIG_CIFS_DFS_UPCALL
-       list_replace_init(&tcon->dfs_ses_list, &ses_list);
-#endif
        spin_unlock(&tcon->tc_lock);
        spin_unlock(&cifs_tcp_ses_lock);
 
@@ -2567,6 +2564,7 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
        cancel_delayed_work_sync(&tcon->query_interfaces);
 #ifdef CONFIG_CIFS_DFS_UPCALL
        cancel_delayed_work_sync(&tcon->dfs_cache_work);
+       list_replace_init(&tcon->dfs_ses_list, &ses_list);
 #endif
 
        if (tcon->use_witness) {