Skip to content

Commit 601cd8f

Browse files
committed
cifs: fix race in assemble_neg_contexts()
jira VULN-169227 cve CVE-2023-53751 commit-author Paulo Alcantara <pc@cjr.nz> commit 775e44d upstream-diff Ignored the introduction of `pserver' variable, as well as the usage of `hostname' local, as they were only needed in the upstream because of the dual source of the server hostname, introduced in the non-backported commit 9de7499 ("smb3: use netname when available on secondary channels") Serialise access of TCP_Server_Info::hostname in assemble_neg_contexts() by holding the server's mutex otherwise it might end up accessing an already-freed hostname pointer from cifs_reconnect() or cifs_resolve_server(). Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de> Signed-off-by: Steve French <stfrench@microsoft.com> (cherry picked from commit 775e44d) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent c746f8a commit 601cd8f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/cifs/smb2pdu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,10 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
549549
} else
550550
req->NegotiateContextCount = cpu_to_le16(4);
551551

552+
cifs_server_lock(server);
552553
ctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt,
553554
server->hostname);
555+
cifs_server_unlock(server);
554556
*total_len += ctxt_len;
555557
pneg_ctxt += ctxt_len;
556558

0 commit comments

Comments
 (0)