Commit 377e3a8
committed
cifs: fix potential use-after-free bugs in TCP_Server_Info::hostname
jira VULN-169227
cve CVE-2023-53751
commit-author Paulo Alcantara <pc@manguebit.com>
commit 90c49fc
upstream-diff |
fs/cifs/cifsglob.h
Added `srv_lock' to the `TCP_Server_Info' struct as it was done in
the non-backported commit d7d7a66
("cifs: avoid use of global locks for high contention data").
fs/cifs/cifs_debug.c
Ignored changes in `cifs_debug_data_proc_show()' because the code
using `hostname' was only added in the non-backported commit
40f077a ("cifs: clarify hostname
vs ip address in /proc/fs/cifs/DebugData").
fs/cifs/connect.c
- Changed the `reconn_set_next_dfs_target()' function instead of
`__reconnect_target_unlocked()' which doesn't exist in LTS
8.6. The `__reconnect_target_unlocked()' is where the `hostname'
is "updated once or many times during reconnect" (see original
commit message). The "reconnect" refers to the function
`cifs_reconnect()', which calls `__reconnect_target_unlocked()'
on a third level down the call tree. Relative to LTS 8.6 the
`cifs_reconnect()' underwent major rewrites in the commits
bbcce36 ("cifs: split out dfs
code from cifs_reconnect()") and
c88f7dc ("cifs: support nested
dfs links over reconnect"). In LTS 8.6 the updating of
`hostname' can be tracked down to the
`reconn_set_next_dfs_target()' function called by
`cifs_reconnect()'.
- Added initialization of `TCP_Server_Info::srv_lock' in
`cifs_get_tcp_session()' as it's done in d7d7a66.
- In `match_server()' changed the lockdep assertion from holding
`server->srv_lock' to holding `cifs_tcp_ses_lock', because this
is the actual invariant for the LTS 8.6 version.
- In `match_server()' sandwiched the `strcasecmp(server->hostname,
...)' call in the lock/unlock pair of `server->srv_lock',
because in LTS 8.6 the `match_server()' is not called with the
`server->srv_lock' held and yet this is the lock chosen to
protect the `server->hostname' field.
fs/cifs/sess.c
Ignored changes in `cifs_try_adding_channels()' because the code
using `hostname' was only added in the non-backported commit
9c2dc11 ("smb3: do not attempt
multichannel to server which does not support it"). As a result no
changes to the file have been made.
TCP_Server_Info::hostname may be updated once or many times during
reconnect, so protect its access outside reconnect path as well and
then prevent any potential use-after-free bugs.
Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 90c49fc)
Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>1 parent 9d04f9d commit 377e3a8
4 files changed
Lines changed: 24 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
| 612 | + | |
| 613 | + | |
613 | 614 | | |
614 | 615 | | |
615 | 616 | | |
| 617 | + | |
| 618 | + | |
616 | 619 | | |
617 | 620 | | |
618 | 621 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 98 | + | |
101 | 99 | | |
102 | 100 | | |
103 | | - | |
| 101 | + | |
| 102 | + | |
104 | 103 | | |
105 | 104 | | |
106 | | - | |
| 105 | + | |
107 | 106 | | |
108 | 107 | | |
109 | | - | |
| 108 | + | |
110 | 109 | | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
580 | 580 | | |
581 | 581 | | |
582 | 582 | | |
| 583 | + | |
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| |||
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
421 | | - | |
422 | | - | |
423 | | - | |
| 423 | + | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| |||
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
1180 | 1182 | | |
1181 | 1183 | | |
1182 | 1184 | | |
| |||
1194 | 1196 | | |
1195 | 1197 | | |
1196 | 1198 | | |
1197 | | - | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
1198 | 1202 | | |
| 1203 | + | |
| 1204 | + | |
1199 | 1205 | | |
1200 | 1206 | | |
1201 | 1207 | | |
| |||
1343 | 1349 | | |
1344 | 1350 | | |
1345 | 1351 | | |
| 1352 | + | |
1346 | 1353 | | |
1347 | 1354 | | |
1348 | 1355 | | |
| |||
1512 | 1519 | | |
1513 | 1520 | | |
1514 | 1521 | | |
| 1522 | + | |
1515 | 1523 | | |
| 1524 | + | |
1516 | 1525 | | |
1517 | 1526 | | |
1518 | 1527 | | |
| |||
0 commit comments