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, 1 Jun 2023 04:45:57 +0000 (23:45 -0500)
commit9279009de8cda56b2a1de640e844a20418da661a
tree92ecbcd0c2f51e423a84f36946fbcddc3bd0c5fc
parent79930bd03bf27a32079bf36bede7a827a643e2ad
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