Skip to content

Commit

Permalink
smb: client: fix potential race in cifs_put_tcon()
Browse files Browse the repository at this point in the history
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: 4f42a8b ("smb: client: fix DFS interlink failover")
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Paulo Alcantara authored and Steve French committed Dec 6, 2024
1 parent ddca502 commit c32b624
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/smb/client/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2532,16 +2532,14 @@ 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);

/* cancel polling of interfaces */
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) {
Expand Down

0 comments on commit c32b624

Please sign in to comment.