summaryrefslogtreecommitdiffstats
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
authorPaulo Alcantara <pc@cjr.nz>2022-12-29 22:43:46 +0100
committerSteve French <stfrench@microsoft.com>2023-01-04 16:06:53 +0100
commit39a154fc2d172a3a5865e5a9fa2a2983eb7a99ac (patch)
tree54b677b6a19e65ea48e80af840c31d45a34f4364 /fs/cifs/misc.c
parentcifs: fix race in assemble_neg_contexts() (diff)
downloadlinux-39a154fc2d172a3a5865e5a9fa2a2983eb7a99ac.tar.xz
linux-39a154fc2d172a3a5865e5a9fa2a2983eb7a99ac.zip
cifs: protect access of TCP_Server_Info::{dstaddr,hostname}
Use the appropriate locks to protect access of hostname and dstaddr fields in cifs_tree_connect() as they might get changed by other tasks. Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to '')
-rw-r--r--fs/cifs/misc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 4d3c586785a5..2a19c7987c5b 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1277,7 +1277,9 @@ int match_target_ip(struct TCP_Server_Info *server,
if (rc < 0)
return rc;
+ spin_lock(&server->srv_lock);
*result = cifs_match_ipaddr((struct sockaddr *)&server->dstaddr, (struct sockaddr *)&ss);
+ spin_unlock(&server->srv_lock);
cifs_dbg(FYI, "%s: ip addresses match: %u\n", __func__, *result);
return 0;
}