cifs: fix potential race when tree connecting ipc
authorPaulo Alcantara <pc@manguebit.com>
Tue, 25 Apr 2023 05:42:56 +0000 (02:42 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 4 May 2023 04:29:05 +0000 (23:29 -0500)
commitee20d7c6100752eaf2409d783f4f1449c29ea33d
tree07cce2dd6a63495b59f17b520a8d0ed490c5e169
parent90c49fce1c43e1cc152695e20363ff5087897c09
cifs: fix potential race when tree connecting ipc

Protect access of TCP_Server_Info::hostname when building the ipc tree
name as it might get freed in cifsd thread and thus causing an
use-after-free bug in __tree_connect_dfs_target().  Also, while at it,
update status of IPC tcon on success and then avoid any extra tree
connects.

Cc: stable@vger.kernel.org # v6.2+
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/dfs.c