[LTS 9.4] smb: client: fix OOBs when building SMB2_IOCTL request#433
Merged
PlaidCat merged 1 commit intoctrliq:ciqlts9_4from Jul 30, 2025
Merged
Conversation
jira VULN-8637 cve CVE-2024-50151 commit-author Paulo Alcantara <pc@manguebit.com> commit 1ab6032 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 ctrliq#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: e77fe73 ("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> (cherry picked from commit 1ab6032) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[LTS 9.4]
CVE-2024-50151
VULN-8637
Problem
https://access.redhat.com/security/cve/CVE-2024-50151
Background
See "Background" section in #431.
Applicability: yes
(Situation differs slightly from #431 - the CIFS module files are already moved to
fs/smb/client/dir inciqlts9_4)The original mainline fix is contained in 1ab6032. The affected file is
fs/smb/client/smb2pdu.c. It's compiled into the kernel with theCONFIG_CIFSoption:kernel-src-tree/fs/smb/client/Makefile
Lines 6 to 15 in 28a0306
The option is enabled in
ciqlts9_4:The e77fe73 commit identified in 1ab6032 as introducing the bug is present in
ciqlts9_4's history of the module (specifically the filesfs/cifs/{smb2inode.c,smb2ops.c,smb2proto.h}). The fixing 1ab6032 commit was not backported tociqlts9_4.Solution
Mainline fix 1ab6032 was cherry-picked without any modifications.
kABI check: passed
Boot test: passed
See specific tests for the implied boot test passing.
Kselftests: passed relative
No selftests were found for the CIFS module. The general selftsts were run nevertheless, mainly as part of the effort to debug the selftests instability issue.
Coverage
Additinal tests
bpf:test_mapsanddrivers/net/bonding:bond_macvlan.shwhere omitted (compared to the usual scope) as it turned out they mismanage memory and destabilize kernel, often causing the selftests routine to crash at random places with NULL ptr dereference or similar memory-related errors.bpf(excepttest_kmod.sh,get_cgroup_id_user,test_xdp_redirect_multi.sh,test_xdp_features.sh,test_xdp_vlan_mode_native.sh,test_progs,test_xdp_veth.sh,test_xdp_meta.sh,test_maps,test_bpftool_metadata.sh,test_bpftool_build.sh,test_lwt_ip_encap.sh,test_lirc_mode2.sh,test_xdp_redirect.sh,test_tunnel.sh,test_xsk.sh,test_lwt_seg6local.sh,test_xdp_vlan_mode_generic.sh,test_skb_cgroup_id.sh,test_xdping.sh,test_bpftool.sh,test_tc_tunnel.sh,test_offload.py,test_dev_cgroup,test_flow_dissector.sh,test_progs-no_alu32,test_tcp_check_syncookie.sh,test_sock_addr.sh,test_progs-cpuv4,test_tc_edt.sh,test_sockmap,test_doc_build.sh),breakpoints(exceptstep_after_suspend_test),capabilities,clone3,cpu-hotplug,cpufreq,drivers/dma-buf,drivers/net/bonding(exceptbond_macvlan.sh),drivers/net/team,exec,filesystems/binderfs,filesystems/epoll,firmware,fpu,ftrace,futex,gpio,intel_pstate,iommu,ipc,ir,kcmp,kexec,kvm,landlock,lib,livepatch,membarrier,memfd,memory-hotplug,mincore,mount,mqueue,nci,net/forwarding(excepttc_police.sh,router_bridge_1d_lag.sh,sch_ets.sh,sch_tbf_prio.sh,router_bridge_lag.sh,sch_red.sh,sch_tbf_root.sh,q_in_vni.sh,dual_vxlan_bridge.sh,vxlan_bridge_1d_ipv6.sh,sch_tbf_ets.sh,mirror_gre_vlan_bridge_1q.sh,tc_actions.sh,ip6gre_inner_v6_multipath.sh,gre_inner_v6_multipath.sh,ipip_hier_gre_keys.sh,mirror_gre_bridge_1d_vlan.sh),net/hsr,net/mptcp(exceptsimult_flows.sh,userspace_pm.sh,mptcp_join.sh),net(exceptudpgro_fwd.sh,xfrm_policy.sh,srv6_end_dt4_l3vpn_test.sh,fib_nexthops.sh,reuseaddr_conflict,reuseport_addr_any.sh,srv6_end_dt6_l3vpn_test.sh,srv6_end_flavors_test.sh,srv6_end_dt46_l3vpn_test.sh,txtimestamp.sh,gro.sh,ip_defrag.sh,udpgso_bench.sh),netfilter(exceptnft_trans_stress.sh),nsfs,pid_namespace,pidfd,proc(exceptproc-pid-vm,proc-uptime-001),pstore,ptrace,rlimits,rseq,seccomp,sgx,sigaltstack,size,splice,static_keys,syscall_user_dispatch,tc-testing,tdx,timens,timers,tmpfs,tpm2,tty,vDSO,x86,zramReference
kselftests–ciqlts9_4–run1.log
Patch
kselftests–ciqlts9_4-CVE-2024-50151–run1.log
Comparison
The reference and patch results are the same.
Specific tests: passed
(The LTS 9.4 direct CIFS testing follows the same pattern as LTS 9.2 described in #431)
The 1ab6032 commit mentions a way to replicate the bug
An attempt was made to replicate the bug on
ciqlts9_4with KASAN enabled, but it failed - no KASAN errors were obtained and the symlink creation worked fine. Perhaps it had to do with the SMB share being hosted on the very same machine where it was mounted, but setting up a "proper" samba share were dropped after a couple of unsuccesfull attempts at getting rid ofNT_STATUS_CONNECTION_REFUSEDerror. The same test was repeated on the patched kernel with the same result. At the very least it shows that the CIFS module remains functional.The steps setting up encrypted samba share were as follows:
reference-replication.log
patch-replication.log