linux-stable/fs/cifs
Paulo Alcantara 89b6ae907c smb: client: fix OOB in smbCalcSize()
[ Upstream commit b35858b378 ]

Validate @smb->WordCount to avoid reading off the end of @smb and thus
causing the following KASAN splat:

  BUG: KASAN: slab-out-of-bounds in smbCalcSize+0x32/0x40 [cifs]
  Read of size 2 at addr ffff88801c024ec5 by task cifsd/1328

  CPU: 1 PID: 1328 Comm: cifsd Not tainted 6.7.0-rc5 #9
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
  rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
  Call Trace:
   <TASK>
   dump_stack_lvl+0x4a/0x80
   print_report+0xcf/0x650
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? __phys_addr+0x46/0x90
   kasan_report+0xd8/0x110
   ? smbCalcSize+0x32/0x40 [cifs]
   ? smbCalcSize+0x32/0x40 [cifs]
   kasan_check_range+0x105/0x1b0
   smbCalcSize+0x32/0x40 [cifs]
   checkSMB+0x162/0x370 [cifs]
   ? __pfx_checkSMB+0x10/0x10 [cifs]
   cifs_handle_standard+0xbc/0x2f0 [cifs]
   ? srso_alias_return_thunk+0x5/0xfbef5
   cifs_demultiplex_thread+0xed1/0x1360 [cifs]
   ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? lockdep_hardirqs_on_prepare+0x136/0x210
   ? __pfx_lock_release+0x10/0x10
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? mark_held_locks+0x1a/0x90
   ? lockdep_hardirqs_on_prepare+0x136/0x210
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? srso_alias_return_thunk+0x5/0xfbef5
   ? __kthread_parkme+0xce/0xf0
   ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
   kthread+0x18d/0x1d0
   ? kthread+0xdb/0x1d0
   ? __pfx_kthread+0x10/0x10
   ret_from_fork+0x34/0x60
   ? __pfx_kthread+0x10/0x10
   ret_from_fork_asm+0x1b/0x30
   </TASK>

This fixes CVE-2023-6606.

Reported-by: j51569436@gmail.com
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218218
Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-08 11:27:37 +01:00
..
Kconfig cifs: In Kconfig CONFIG_CIFS_POSIX needs depends on legacy (insecure cifs) 2018-12-21 14:15:23 +01:00
Makefile
asn1.c cifs: remove bogus debug code 2020-10-29 09:54:59 +01:00
cache.c
cifs_debug.c cifs: Don't display RDMA transport on reconnect 2019-12-21 10:57:33 +01:00
cifs_debug.h
cifs_dfs_ref.c cifs: use correct format characters 2019-04-05 22:32:59 +02:00
cifs_fs_sb.h cifs: Properly handle auto disabling of serverino option 2019-09-16 08:22:17 +02:00
cifs_ioctl.h
cifs_spnego.c cifs: spnego: add ';' in HOST_KEY_LEN 2023-11-28 16:46:33 +00:00
cifs_spnego.h
cifs_unicode.c CIFS: Fix a potencially linear read overflow 2021-09-22 11:47:54 +02:00
cifs_unicode.h
cifs_uniupr.h
cifsacl.c cifs: Fix mode output in debugging statements 2020-03-05 16:42:15 +01:00
cifsacl.h
cifsencrypt.c
cifsfs.c smb3: fix touch -h of symlink 2023-12-08 08:43:25 +01:00
cifsfs.h cifs: fix DFS traversal oops without CONFIG_CIFS_DFS_UPCALL 2023-04-05 11:15:41 +02:00
cifsglob.h CIFS: Properly process SMB3 lease breaks 2020-10-01 13:14:29 +02:00
cifspdu.h
cifsproto.h cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:27:34 +01:00
cifssmb.c cifs: prevent infinite recursion in CIFSGetDFSRefer() 2023-04-05 11:15:41 +02:00
connect.c smbd: Make upper layer decide when to destroy the transport 2023-02-06 07:49:42 +01:00
dir.c cifs: report error instead of invalid when revalidating a dentry fails 2021-02-10 09:21:07 +01:00
dns_resolve.c
dns_resolve.h
export.c
file.c cifs: Release folio lock on fscache read hit. 2023-08-30 16:31:50 +02:00
fscache.c
fscache.h
inode.c cifs: handle -EINTR in cifs_setattr 2020-11-05 11:08:44 +01:00
ioctl.c cifs: Fix wrong return value checking when GETFLAGS 2022-11-25 17:40:25 +01:00
link.c cifs: Fix uninitialized memory read for smb311 posix symlink create 2023-01-18 11:30:52 +01:00
misc.c smb: client: fix OOB in smbCalcSize() 2024-01-08 11:27:37 +01:00
netmisc.c fs: cifs: mute -Wunused-const-variable message 2019-11-06 13:05:51 +01:00
nterr.c
nterr.h
ntlmssp.h
readdir.c cifs: check ntwrk_buf_start for NULL before dereferencing it 2019-02-12 19:47:17 +01:00
rfc1002pdu.h
sess.c cifs: fix wrong release in sess_alloc_buffer() failed path 2021-09-22 11:48:08 +02:00
smb1ops.c CIFS: Properly process SMB3 lease breaks 2020-10-01 13:14:29 +02:00
smb2file.c cifs: Adjust indentation in smb2_open_file 2020-01-17 19:47:01 +01:00
smb2glob.h
smb2inode.c
smb2maperror.c SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write 2019-06-25 11:36:01 +08:00
smb2misc.c smb: client: fix NULL deref in asn1_ber_decoder() 2024-01-08 11:27:35 +01:00
smb2ops.c cifs: add a warning when the in-flight count goes negative 2023-09-23 10:47:58 +02:00
smb2pdu.c cifs: do not include page data when checking signature 2023-01-24 07:11:50 +01:00
smb2pdu.h ksmbd: fix wrong name of SMB2_CREATE_ALLOCATION_SIZE 2024-01-08 11:27:33 +01:00
smb2proto.h CIFS: Close open handle after interrupted close 2019-12-21 10:57:35 +01:00
smb2status.h
smb2transport.c CIFS: Do not skip SMB2 message IDs on send failures 2019-03-23 20:09:56 +01:00
smbdirect.c smbdirect: missing rc checks while waiting for rdma events 2023-11-08 11:22:18 +01:00
smbdirect.h smbd: Make upper layer decide when to destroy the transport 2023-02-06 07:49:42 +01:00
smbencrypt.c
smberr.h
smbfsctl.h
trace.c
trace.h
transport.c cifs: don't send down the destination address to sendmsg for a SOCK_STREAM 2022-09-28 11:02:52 +02:00
winucase.c
xattr.c CIFS: fix max ea value size 2019-10-05 13:10:12 +02:00