kernel_samsung_a53x/fs/cifs
Paulo Alcantara 0ba0177fb7 smb: client: fix OOBs when building SMB2_IOCTL request
[ Upstream commit 1ab60323c5201bef25f2a3dc0ccc404d9aca77f1 ]

When using encryption, either enforced by the server or when using
'seal' mount option, the client will squash all compound request buffers
down for encryption into a single iov in smb2_set_next_command().

SMB2_ioctl_init() allocates a small buffer (448 bytes) to hold the
SMB2_IOCTL request in the first iov, and if the user passes an input
buffer that is greater than 328 bytes, smb2_set_next_command() will
end up writing off the end of @rqst->iov[0].iov_base as shown below:

  mount.cifs //srv/share /mnt -o ...,seal
  ln -s $(perl -e "print('a')for 1..1024") /mnt/link

  BUG: KASAN: slab-out-of-bounds in
  smb2_set_next_command.cold+0x1d6/0x24c [cifs]
  Write of size 4116 at addr ffff8881148fcab8 by task ln/859

  CPU: 1 UID: 0 PID: 859 Comm: ln Not tainted 6.12.0-rc3 #1
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
  1.16.3-2.fc40 04/01/2014
  Call Trace:
   <TASK>
   dump_stack_lvl+0x5d/0x80
   ? smb2_set_next_command.cold+0x1d6/0x24c [cifs]
   print_report+0x156/0x4d9
   ? smb2_set_next_command.cold+0x1d6/0x24c [cifs]
   ? __virt_addr_valid+0x145/0x310
   ? __phys_addr+0x46/0x90
   ? smb2_set_next_command.cold+0x1d6/0x24c [cifs]
   kasan_report+0xda/0x110
   ? smb2_set_next_command.cold+0x1d6/0x24c [cifs]
   kasan_check_range+0x10f/0x1f0
   __asan_memcpy+0x3c/0x60
   smb2_set_next_command.cold+0x1d6/0x24c [cifs]
   smb2_compound_op+0x238c/0x3840 [cifs]
   ? kasan_save_track+0x14/0x30
   ? kasan_save_free_info+0x3b/0x70
   ? vfs_symlink+0x1a1/0x2c0
   ? do_symlinkat+0x108/0x1c0
   ? __pfx_smb2_compound_op+0x10/0x10 [cifs]
   ? kmem_cache_free+0x118/0x3e0
   ? cifs_get_writable_path+0xeb/0x1a0 [cifs]
   smb2_get_reparse_inode+0x423/0x540 [cifs]
   ? __pfx_smb2_get_reparse_inode+0x10/0x10 [cifs]
   ? rcu_is_watching+0x20/0x50
   ? __kmalloc_noprof+0x37c/0x480
   ? smb2_create_reparse_symlink+0x257/0x490 [cifs]
   ? smb2_create_reparse_symlink+0x38f/0x490 [cifs]
   smb2_create_reparse_symlink+0x38f/0x490 [cifs]
   ? __pfx_smb2_create_reparse_symlink+0x10/0x10 [cifs]
   ? find_held_lock+0x8a/0xa0
   ? hlock_class+0x32/0xb0
   ? __build_path_from_dentry_optional_prefix+0x19d/0x2e0 [cifs]
   cifs_symlink+0x24f/0x960 [cifs]
   ? __pfx_make_vfsuid+0x10/0x10
   ? __pfx_cifs_symlink+0x10/0x10 [cifs]
   ? make_vfsgid+0x6b/0xc0
   ? generic_permission+0x96/0x2d0
   vfs_symlink+0x1a1/0x2c0
   do_symlinkat+0x108/0x1c0
   ? __pfx_do_symlinkat+0x10/0x10
   ? strncpy_from_user+0xaa/0x160
   __x64_sys_symlinkat+0xb9/0xf0
   do_syscall_64+0xbb/0x1d0
   entry_SYSCALL_64_after_hwframe+0x77/0x7f
  RIP: 0033:0x7f08d75c13bb

Reported-by: David Howells <dhowells@redhat.com>
Fixes: e77fe73c7e38 ("cifs: we can not use small padding iovs together with encryption")
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:21:59 +01:00
..
asn1.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cache.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_debug.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_debug.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_dfs_ref.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_fs_sb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_ioctl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_spnego.c cifs: spnego: add ';' in HOST_KEY_LEN 2024-11-18 11:43:20 +01:00
cifs_spnego.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_unicode.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_unicode.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifs_uniupr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsacl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsacl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsencrypt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsfs.c cifs: Fix non-availability of dedup breaking generic/304 2024-11-18 12:11:47 +01:00
cifsfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsglob.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifspdu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsproto.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifsroot.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cifssmb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
connect.c exit: Rename module_put_and_exit to module_put_and_kthread_exit 2024-11-19 12:27:50 +01:00
dfs_cache.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dfs_cache.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dir.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dns_resolve.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dns_resolve.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
export.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
file.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fs_context.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fs_context.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fscache.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fscache.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inode.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ioctl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
link.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
misc.c smb: client: fix OOB in smbCalcSize() 2024-11-18 12:12:02 +01:00
netmisc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nterr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nterr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ntlmssp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
readdir.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rfc1002pdu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sess.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb1ops.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb2file.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb2glob.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb2inode.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb2maperror.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb2misc.c smb3: Replace smb2pdu 1-element arrays with flex-arrays 2024-11-18 12:12:59 +01:00
smb2ops.c cifs: add a warning when the in-flight count goes negative 2024-11-18 22:25:35 +01:00
smb2pdu.c smb: client: fix OOBs when building SMB2_IOCTL request 2024-11-23 23:21:59 +01:00
smb2pdu.h smb3: Replace smb2pdu 1-element arrays with flex-arrays 2024-11-18 12:12:59 +01:00
smb2proto.h smb: client: fix potential OOBs in smb2_parse_contexts() 2024-11-18 22:25:31 +01:00
smb2status.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smb2transport.c smb: client: fix deadlock in smb2_find_smb_tcon() 2024-11-19 14:19:30 +01:00
smbdirect.c smbdirect: missing rc checks while waiting for rdma events 2024-11-18 10:58:32 +01:00
smbdirect.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smbencrypt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smberr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smbfsctl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
transport.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
winucase.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xattr.c smb3: fix caching of ctime on setxattr 2024-11-18 12:11:13 +01:00