CVE-2026-99384: smb: client: fix OOB read of the resume name sent in TRANS2_FIND_NEXT2
In the Linux kernel, the following vulnerability has been resolved:
smb: client: fix OOB read of the resume name sent in TRANS2FINDNEXT2
cifsfilldirent() reads the fixed part of a directory entry and the name length it holds, or for SMBFINDFILEUNIX scans the name for its terminating NUL, without knowing where the response ends. cifssaveresumekey() calls it for the entry at the LastNameOffset the server chose, after every FindNext and after the FindFirst of a search rewind, and records the name it returns as the resume name of the search without bounding it; the next CIFSFindNext() copies up to PATHMAX - 1 bytes from that name into its request and sends them to the server. cifsfilldir() bounds the name against the end of the response since commit f8cf09a53a0d ("smb: client: bound dirent name against end of SMB response in cifsfilldir"), but only after cifsfilldirent() has read the entry, and nxtdirentry() checks the entries it walks only against sizeof(FILEDIRECTORYINFO), for every level but SMBFINDFILEINFOSTANDARD, and never sees the first entry of a response.
Bounding where lastentry starts, as the preceding patch does, does not bound the read. A last entry that starts within the final bytes of the response still has its fixed part read past the end of the received data, and the name length it declares, a le32 for every level but SMBFINDFILEINFOSTANDARD and SMBFINDFILEUNIX, is recorded without being checked against anything. CIFSFindNext() rejects only a length of PATHMAX or more, then copies the name, up to 4095 bytes, into its request and sends it, and as the report below shows that copy can run past the end of the cifsrequest allocation that holds the response. For SMBFINDFILEUNIX the name is in addition scanned for its terminating NUL over up to PATHMAX + 1 UTF-16 units, or PATHMAX bytes, before any check. The FindNext that carries the name is only sent by the SMB1 dialect, which is not negotiated by default; reaching it requires an explicit vers=1.0 mount.
With KASAN enabled, a response whose last entry declares a name longer than the bytes that follow it gives:
================================================================== BUG: KASAN: slab-out-of-bounds in CIFSFindNext+0x8ca/0x14c0 Read of size 4080 at addr ffff88807c823f98 by task ls/83
CPU: 0 UID: 0 PID: 83 Comm: ls Not tainted 7.3.0-rc4-00457-gf14572c203d5 #69 PREEMPT(lazy) Call Trace: <TASK> kasanreport+0xdf/0x1a0 kasancheckrange+0x10f/0x1e0 asanmemcpy+0x23/0x60 CIFSFindNext+0x8ca/0x14c0 cifsreaddir+0xf51/0x29c0 iteratedir+0x1c0/0x570 x64sysgetdents64+0x133/0x270 dosyscall64+0x109/0x5d0 entrySYSCALL64afterhwframe+0x77/0x7f </TASK>
Allocated by task 83 on cpu 1 at 13.497119s: cifsbufget+0x36/0x90 smbinit+0x4f/0x110 CIFSFindNext+0xf7/0x14c0 cifsreaddir+0xf51/0x29c0
The buggy address belongs to the object at ffff88807c820000 which belongs to the cache cifsrequest of size 16588 The buggy address is located 16280 bytes inside of allocated 16588-byte region [ffff88807c820000, ffff88807c8240cc) ==================================================================
The read is the memcpy() that copies the recorded name into the next request, so those bytes go to the server.
Pass the end of the response to cifsfilldirent() and have it reject an entry whose fixed part does not fit or whose name extends past the end, before either is used, so that both callers are covered; cifssaveresumekey() computes the end the same way cifsreaddir() does. The name bound compares the bytes left between the name and the end with the name length rather than adding the length to the name pointer, since the length is a 32-bit value taken from the entry and the sum could wrap on 32-bit systems. cifsfilldirent() is also used on the SMB2 readdir path; there smb2parsequerydirectory() has already checked every entry against the end of the response, so a vali ---truncated---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 2.6.26 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 2.6.27 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 2.6.28 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.118 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2