]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/smb-client-fix-potential-uaf-in-cifs_dump_full_key.patch
Linux 6.1.85
[thirdparty/kernel/stable-queue.git] / queue-6.6 / smb-client-fix-potential-uaf-in-cifs_dump_full_key.patch
1 From 58acd1f497162e7d282077f816faa519487be045 Mon Sep 17 00:00:00 2001
2 From: Paulo Alcantara <pc@manguebit.com>
3 Date: Tue, 2 Apr 2024 16:33:54 -0300
4 Subject: smb: client: fix potential UAF in cifs_dump_full_key()
5
6 From: Paulo Alcantara <pc@manguebit.com>
7
8 commit 58acd1f497162e7d282077f816faa519487be045 upstream.
9
10 Skip sessions that are being teared down (status == SES_EXITING) to
11 avoid UAF.
12
13 Cc: stable@vger.kernel.org
14 Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
15 Signed-off-by: Steve French <stfrench@microsoft.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 ---
18 fs/smb/client/ioctl.c | 6 +++++-
19 1 file changed, 5 insertions(+), 1 deletion(-)
20
21 --- a/fs/smb/client/ioctl.c
22 +++ b/fs/smb/client/ioctl.c
23 @@ -246,7 +246,9 @@ static int cifs_dump_full_key(struct cif
24 spin_lock(&cifs_tcp_ses_lock);
25 list_for_each_entry(server_it, &cifs_tcp_ses_list, tcp_ses_list) {
26 list_for_each_entry(ses_it, &server_it->smb_ses_list, smb_ses_list) {
27 - if (ses_it->Suid == out.session_id) {
28 + spin_lock(&ses_it->ses_lock);
29 + if (ses_it->ses_status != SES_EXITING &&
30 + ses_it->Suid == out.session_id) {
31 ses = ses_it;
32 /*
33 * since we are using the session outside the crit
34 @@ -254,9 +256,11 @@ static int cifs_dump_full_key(struct cif
35 * so increment its refcount
36 */
37 cifs_smb_ses_inc_refcount(ses);
38 + spin_unlock(&ses_it->ses_lock);
39 found = true;
40 goto search_end;
41 }
42 + spin_unlock(&ses_it->ses_lock);
43 }
44 }
45 search_end: