Skip to content

Commit d598423

Browse files
committed
Merge: [CVE-2024-53095] smb: client: Fix use-after-free of network namespace.
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5888 JIRA: https://issues.redhat.com/browse/RHEL-68558 CVE: CVE-2024-53095 Signed-off-by: Paulo Alcantara <paalcant@redhat.com> Approved-by: Jay Shin <jaeshin@redhat.com> Approved-by: Benjamin Coddington <bcodding@redhat.com> Approved-by: Scott Mayhew <smayhew@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents 0f869f7 + dba4417 commit d598423

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/smb/client/connect.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
10391039
*/
10401040
}
10411041

1042+
put_net(cifs_net_ns(server));
10421043
kfree(server->leaf_fullpath);
10431044
kfree(server);
10441045

@@ -1637,8 +1638,6 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect)
16371638
/* srv_count can never go negative */
16381639
WARN_ON(server->srv_count < 0);
16391640

1640-
put_net(cifs_net_ns(server));
1641-
16421641
list_del_init(&server->tcp_ses_list);
16431642
spin_unlock(&cifs_tcp_ses_lock);
16441643

@@ -3072,13 +3071,21 @@ generic_ip_connect(struct TCP_Server_Info *server)
30723071
if (server->ssocket) {
30733072
socket = server->ssocket;
30743073
} else {
3075-
rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
3074+
struct net *net = cifs_net_ns(server);
3075+
struct sock *sk;
3076+
3077+
rc = __sock_create(net, sfamily, SOCK_STREAM,
30763078
IPPROTO_TCP, &server->ssocket, 1);
30773079
if (rc < 0) {
30783080
cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
30793081
return rc;
30803082
}
30813083

3084+
sk = server->ssocket->sk;
3085+
sk->sk_net_refcnt = 1;
3086+
get_net_track(net, &sk->ns_tracker, GFP_KERNEL);
3087+
sock_inuse_add(net, 1);
3088+
30823089
/* BB other socket options to set KEEPALIVE, NODELAY? */
30833090
cifs_dbg(FYI, "Socket created\n");
30843091
socket = server->ssocket;

0 commit comments

Comments
 (0)