HIGH
smb Symlink Parser OOB
CVE-2026-31613
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:H
KernelScan AI8.1HIGH
01Description
In the Linux kernel, the following vulnerability has been resolved: smb: client: fix OOB reads parsing symlink error response When a CREATE returns STATUS_STOPPED_ON_SYMLINK, smb2_check_message() returns success without any length validation, leaving the symlink parsers as the only defense against an untrusted server. symlink_data() walks SMB 3.1.1 error contexts with the loop test "p < end", but reads p->ErrorId at offset 4 and p->ErrorDataLength at offset 0. When the server-controlled ErrorDataLength advances p to within 1-7 bytes of end, the next iteration will read past it. When the matching context is found, sym->SymLinkErrorTag is read at offset 4 from p->ErrorContextData with no check that the symlink header itself fits. smb2_parse_symlink_response() then bounds-checks the substitute name using SMB2_SYMLINK_STRUCT_SIZE as the offset of PathBuffer from iov_base. That value is computed as sizeof(smb2_err_rsp) + sizeof(smb2_symlink_err_rsp), which is correct only when ErrorContextCount == 0. With at least one error context the symlink data sits 8 bytes deeper, and each skipped non-matching context shifts it further by 8 + ALIGN(ErrorDataLength, 8). The check is too short, allowing the substitute name read to run past iov_len. The out-of-bound heap bytes are UTF-16-decoded into the symlink target and returned to userspace via readlink(2). Fix this all up by making the loops test require the full context header to fit, rejecting sym if its header runs past end, and bound the substitute name against the actual position of sym->PathBuffer rather than a fixed offset. Because sub_offs and sub_len are 16bits, the pointer math will not overflow here with the new greater-than.
02KernelScan AI Analysis
Risk summary
A malicious SMB server can cause the Linux SMB client to read beyond allocated memory buffers when parsing symlink error responses. The out-of-bounds data is UTF-16 decoded and returned to userspace via readlink() system calls, potentially leaking sensitive kernel heap contents. This affects any system mounting SMB shares from untrusted servers.
Vulnerability analysis
Root Cause: The SMB client's symlink error response parser contains multiple bounds checking vulnerabilities. In symlink_data(), the loop condition 'p < end' is insufficient because it reads p->ErrorId at offset 4 and p->ErrorDataLength at offset 0, allowing reads past the buffer when the server-controlled ErrorDataLength advances p to within 1-7 bytes of end. Additionally, smb2_parse_symlink_response() uses a fixed offset SMB2_SYMLINK_STRUCT_SIZE to bounds-check the substitute name, but this offset is only correct when ErrorContextCount == 0. With error contexts present, the symlink data sits deeper in the buffer, causing the bounds check to be too permissive.
Attack Surface: This vulnerability is exploitable by malicious SMB servers when a client attempts to access symlinks. The attack requires network connectivity to the SMB server and occurs during normal symlink resolution operations. No special privileges are required on the client side beyond the ability to access SMB shares.
Fix Mechanism: The patch strengthens bounds checking in three ways: (1) Changes the loop condition to require the full context header to fit by checking '(u8 *)p + sizeof(*p) <= end', (2) Adds validation that the symlink header itself fits within bounds before accessing sym->SymLinkErrorTag, and (3) Replaces the fixed offset bounds check with dynamic calculation using the actual position of sym->PathBuffer relative to iov_base, ensuring substitute and print name reads don't exceed iov_len.
03Fix Versions
| Branch | Fixed in | Patch commit |
|---|---|---|
| 6.1 | 6.1.175 | 043834e72337 |
| 6.12 | 6.12.91 | 20ac98f0eb60 |
| 6.18 | 6.18.24 | e0dd90d14cbb |
| 6.19 | 6.19.14 | 781902e069f4 |
| 6.6 | 6.6.141 | d65a64755a3d |
| 7.0 | 7.0.1 | a66ef2e7ed83 |
| mainline | 7.1-rc1 | 3df690bba28e |