Bounds Checker Report — 20261020_223347_cifssmb.c

Date: 2026-10-20 22:35:21 Model: gemini-2.5-flash Source: /home/src/linux/fs/smb/client/cifssmb.c Files: 1 Stage 1: 29 findings (Cat A: 7  |  Cat B: 5  |  Cat C: 1  |  Cat E: 14  |  Cat F: 1  |  Cat H: 1) Stage 1.7 SMT: 0 retired by proof (excluded from the counts above and from the sections below; see stage1_7_smt.json) Stage 2: 16 real  |  13 FP  |  0 unanalyzed Kernel: v7.3-rc5-404-g35aed8a26cce Branch: work/bc1
67 local commit(s) since origin/master
  1. 35aed8a26cce smb: client: fix OOB read due to invalid data_offset in CIFSSMBQAllEAs
  2. b9a9e19bf4a6 smb: client: fix OOB reads in cifs_to_posix_acl()
  3. c5ea4e4d4169 smb: client: fix incorrect path level counting for DFS symlinks
  4. b042c98ceedd smb: client: fix OOB read counting path levels for share-root symlink
  5. 58b6636ac0c0 smb: client: fix OOB read when symlink target equals symlinkroot
  6. ccc4ad864181 smb: client: prevent read of header as data in open_cached_dir
  7. 78f739858464 smb: client: reclaim credits for decrypted reads with no matching mid
  8. 2225ab306575 smb: client: do not pass a NULL buf to is_oplock_break()
  9. 8667061cf993 smb: client: require stable pages for SMB compression
  10. cafbf020e437 smb: client: allocate struct SMB2_sess_data on the stack
  11. f13208f26c05 smb: client: allocate struct sess_data on the stack
  12. b012ffcd45b0 smb: client: drop redundant nls_table arg from CIFSSMBRenameOpenFile()
  13. 34c6fdb03b05 smb: client: drop redundant nls_table arg from SMBLegacyOpen()
  14. b2c49578d342 smb: client: drop redundant nls_table arg from CIFSPOSIXCreate()
  15. 8552a75e219c smb: client: drop redundant nls_table arg from CIFSPOSIXDelFile()
  16. fd8ac150455d smb: client: drop redundant nls_table arg from ->tree_connect()
  17. 172cbcd178c8 smb: client: drop redundant nls_table arg from cifs_setup_session()
  18. ca67b7abefda smb: client: drop redundant nls_table arg from ->sess_setup()
  19. 9f9ab02ddfcb smb: client: drop unused nls_table arg from decode_ascii_ssetup()
  20. ea0261b23fa5 smb: client: drop redundant nls_table arg from decode_unicode_ssetup()
  21. 34e037c98a5d smb: client: drop unused nls_table arg from ascii_ssetup_strings()
  22. f945ba31422c smb: client: drop redundant nls_table arg from unicode_ssetup_strings()
  23. 40e439b61fd9 smb: client: drop unused nls_table arg from ascii_domain_string()
  24. 40c21e0e41ba smb: client: drop redundant nls_table arg from unicode_domain_string()
  25. 6b3884e9d0ac smb: client: drop unused nls_table arg from ascii_oslm_strings()
  26. 4acec99c4c1a smb: client: drop redundant nls_table arg from build_ntlmssp_auth_blob()
  27. aadcd752e34b smb: client: drop redundant nls_table arg from build_ntlmssp_smb3_negotiate_blob()
  28. a8ef7f94f901 smb: client: drop redundant nls_table arg from build_ntlmssp_negotiate_blob()
  29. 6d16358ac43d smb: client: drop redundant nls_table arg from setup_ntlmv2_rsp()
  30. 71098da2195f smb: client: drop redundant nls_table arg from calc_ntlmv2_hash()
  31. b07c7b781f89 smb: client: drop redundant nls_table arg from build_avpair_blob()
  32. 64fd7c38697b smb: client: drop redundant nls_table arg from ->set_EA()
  33. cd040ff11dae smb: client: drop redundant nls_table arg from CIFSSMBSetPathInfo()
  34. 78abbc67787d smb: client: drop redundant nls_table arg from SMBSetInformation()
  35. 740619915257 smb: client: size smb2_compound_vars.qi_iov for the padding iov
  36. c38f4e84c935 smb: client: remove unused file flags ioctl handlers
  37. 273913b7c33a smb: client: implement fileattr_set for compression flags
  38. 62d973b788e0 smb: client: remove unused num_acl_set stat from cifs_tcon
  39. 5ef569b5b789 smb: client: remove write-only signing_negotiated from TCP_Server_Info
  40. 6b56bb27466f smb: client: remove write-only sec_kerberosu2u from TCP_Server_Info
  41. 5be685f3516c smb: client: remove write-only max_rw from TCP_Server_Info
  42. 1f0cd146ba93 smb: client: remove unused overrideSecFlg from struct cifs_ses
  43. c684280717a8 smb: client: remove the internal CIFS version number
  44. 5dce507a8ba4 smb: client: clean up cifs_buf_release()
  45. bb274d815597 smb: client: remove commented-out Unix caps assignment
  46. e4a1508b8b3f smb: client: remove commented-out time conversion debug message
  47. 5c2824d98b30 smb: client: remove commented-out CIFSSMBWinSetPerms() call
  48. bdf9ccc58bc6 smb: client: remove commented-out QPathInfo debug message
  49. a59aeb074cac smb: client: remove commented-out LOCK_RSP declaration
  50. 1e0e189998c0 smb: client: remove commented-out write debug message
  51. 775bf158872f smb: client: remove commented-out oplock assignment
  52. a40b17cc9eca smb: client: remove commented-out cancel_*_requests() calls
  53. fe3fc9f77971 smb: client: remove commented-out i_flags assignment
  54. 2bcbf169f311 smb: client: remove commented-out ntlmv2_support definition
  55. a4111beeade9 smb: client: log the selected security type on session setup failure
  56. 7c4bf530aefa smb: client: avoid breaking the file lease when probing mfsymlinks
  57. 54a53dd9b6d9 smb: client: set lease_granted before revalidating inode in cifs_nt_open()
  58. 689ab4c8d159 smb: client: rename mfsymlink helpers to the smb2_ prefix
  59. 276dcdc55b5d smb: client: drop the redundant name bounds in cifs_filldir()
  60. 531aa4239b0d smb: client: reject short or out-of-range FIND response parameters
  61. 29bd6773187c smb: client: reject FIND data areas that run past the received response
  62. fa0c2f082946 smb: client: fix OOB read in the SMB_FIND_FILE_UNIX name scan
  63. f8171804a39e smb: client: fix OOB read of the resume name sent in TRANS2_FIND_NEXT2
  64. 570c783a96f0 smb: client: fix OOB last_entry pointer from unbounded LastNameOffset
  65. 59131dd72f62 smb: client: fix use-after-free infoleak via the readdir resume name
  66. 031278577380 smb: client: fix use-after-free in cifs_ses_add_channel()
  67. 80f49404968d smb: client: fast fail sends if need to reconnect

Contents

fs/smb/client/ (17 functions) — 16 real, 13 FP

Summary

FunctionFileAssessmentConfidenceRealFPUnanalyzed
fs/smb/client/ — 17 functions, 16 real, 13 FP
CIFSFindFirst()fs/smb/client/cifssmb.cBUGhigh100
CIFSFindNext()fs/smb/client/cifssmb.cFPhigh010
CIFSGetExtAttr()fs/smb/client/cifssmb.cBUGhigh100
CIFSGetSrvInodeNumber()fs/smb/client/cifssmb.cBUGhigh100
CIFSPOSIXCreate()fs/smb/client/cifssmb.cBUGhigh200
CIFSSMBPosixLock()fs/smb/client/cifssmb.cBUGhigh100
CIFSSMBQAllEAs()fs/smb/client/cifssmb.cMIXEDhigh190
CIFSSMBQFSAttributeInfo()fs/smb/client/cifssmb.cBUGhigh100
CIFSSMBQFSDeviceInfo()fs/smb/client/cifssmb.cBUGhigh100
CIFSSMBQFSInfo()fs/smb/client/cifssmb.cBUGhigh100
CIFSSMBQFSPosixInfo()fs/smb/client/cifssmb.cBUGhigh100
CIFSSMBQFSUnixInfo()fs/smb/client/cifssmb.cBUGhigh100
CIFSSMBRead()fs/smb/client/cifssmb.cFPhigh020
SMBOldQFSInfo()fs/smb/client/cifssmb.cBUGhigh100
cifs_create_reparse_inode()fs/smb/client/cifssmb.cBUGhigh200
cifs_query_reparse_point()fs/smb/client/cifssmb.cBUGhigh100
cifs_to_posix_acl()fs/smb/client/cifssmb.cFPhigh010

Function Details

CIFSFindFirst() — fs/smb/client/cifssmb.c BUG confidence=high

The core issue is an incorrect base address used for calculating derived pointers (`parms` and `psrch_inf->srch_entries_start`) from server-supplied offsets (`parm_off` and `data_off`). The SMB protocol specifies these offsets as relative to the beginning of the SMB header (`pSMBr`), but the code adds an additional, fixed offset (`offsetof(struct smb_hdr, Protocol)`) to the base pointer, effectively double-offsetting the server-supplied value. The subsequent bounds checks only validate the original, un-inflated server-supplied offset against the total buffer length, leading to an OOB read when the extra constant offset pushes the access beyond the buffer boundary.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4517
Taint snippetparm_off = le16_to_cpu(pSMBr->t2.ParameterOffset);
Tainted varparms
Pointer derefparms->EndofSearch line 4544
Sink snippetpsrch_inf->endOfSearch = !!parms->EndofSearch;
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic due to out-of-bounds read, or information disclosure by reading adjacent kernel memory.
Fix: The `ParameterOffset` field in SMB1 Transaction2 responses (and similar `DataOffset` fields) is defined as an offset from the beginning of the `SMB_Header`. The current code incorrectly calculates the base address for `parms` by adding `offsetof(struct smb_hdr, Protocol)` to `(char *)pSMBr` before adding `parm_off`. This effectively double-offsets the value. The `parms` pointer should be calculated directly as `(T2_FFIRST_RSP_PARMS *)((char *)pSMBr + parm_off);`. Similarly, `psrch_inf->srch_entries_start` should be `(char *)pSMBr + data_off;`. Example for `parms`: Change `parms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol + parm_off);` To `parms = (T2_FFIRST_RSP_PARMS *)((char *)pSMBr + parm_off);` Example for `psrch_inf->srch_entries_start`: Change `psrch_inf->srch_entries_start = (char *)&pSMBr->hdr.Protocol + data_off;` To `psrch_inf->srch_entries_start = (char *)pSMBr + data_off;`
CVE pattern: Incorrect offset calculation leading to OOB read (similar to SMB transaction parsing vulnerabilities)

CIFSFindNext() — fs/smb/client/cifssmb.c FP confidence=high

The function performs a two-part bounds check using `parm_off` (server-supplied offset) and `parm_count` (server-supplied length) against the `bytes_returned` (actual received packet length). This check ensures that the region where the `T2_FNEXT_RSP_PARMS` struct is expected is both large enough to contain the struct (`parm_count >= sizeof(*parms)`) and completely within the received buffer (`parm_off + parm_count <= bytes_returned`). This validation occurs before the `parms` pointer is dereferenced.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4660
Taint snippetparm_off = le16_to_cpu(pSMBr->t2.ParameterOffset);
Tainted varparms
Pointer derefparms->EndofSearch line 4695
Sink snippetpsrch_inf->endOfSearch = !!parms->EndofSearch;
Possibly guardedno
Dismissed: The `parm_off` is extracted from `pSMBr`, which is the server response, making it server-supplied. The `parms` pointer is derived from `response_data = (char *)&pSMBr->hdr.Protocol + parm_off;`. Before any dereferences of `parms` (lines 4695, 4696, 4701), there is a explicit bounds check at lines 4662-4663: `if (parm_count < sizeof(*parms) || parm_off + parm_count > (unsigned int)bytes_returned)`. This check validates two crucial conditions: 1. `parm_count < sizeof(*parms)`: Ensures that the declared length of the parameter data (`parm_count`) is at least as large as the `T2_FNEXT_RSP_PARMS` structure itself. If `parm_count` is smaller, it means the `parms` struct cannot fully fit, and the check triggers an error return. 2. `parm_off + parm_count > (unsigned int)bytes_returned`: Ensures that the entire region from `parm_off` up to `parm_off + parm_count` does not extend beyond the actual `bytes_returned` length of the received SMB response. If it does, the check triggers an error return. These two conditions combined guarantee that if the code proceeds past this `if` statement, there are at least `sizeof(*parms)` bytes available starting at the calculated `response_data` address, and this entire struct lies within the bounds of the received `pSMBr` buffer. Therefore, accesses to fields within `parms` are safe. Counterexample test: Let `bytes_returned = 100` and `sizeof(*parms) = 6` (hypothetical, common for 3 `__le16` fields). - If `parm_off = 98`, `parm_count = 2`: `(2 < 6)` is true. The condition `parm_count < sizeof(*parms)` passes, leading to an early return. No OOB. - If `parm_off = 96`, `parm_count = 6`: `(6 < 6)` is false. `(96 + 6 > 100)` is true (`102 > 100`). The condition `parm_off + parm_count > bytes_returned` passes, leading to an early return. No OOB. - If `parm_off = 94`, `parm_count = 6`: `(6 < 6)` is false. `(94 + 6 > 100)` is false (`100 > 100`). The check fails (no error returned), and the code proceeds. In this case, `parms` points to `pSMBr_base + 94`, and `sizeof(*parms)` (6 bytes) fits exactly up to `pSMBr_base + 100`, which is the end of the received buffer. All dereferences are in bounds. No counterexample found that leads to OOB access.

CIFSGetExtAttr() — fs/smb/client/cifssmb.c BUG confidence=high

The function `CIFSGetExtAttr` receives an SMB Transaction2 response from a server. It extracts `DataOffset` and `DataCount` fields from this response, which are server-controlled. While `DataCount` is validated to be exactly 16, there is no validation that the calculated `data_offset + DataCount` fits within the actual received `bytes_returned` buffer. This allows a malicious server to specify an `DataOffset` that points beyond the end of the received buffer, leading to an out-of-bounds read when accessing the `file_chattr_info` struct members.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 3710
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varpfinfo
Pointer derefpfinfo->mode line 3722
Sink snippet*pExtAttrBits = le64_to_cpu(pfinfo->mode);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (e.g., page fault or general protection fault) due to reading from an unmapped or invalid kernel address, or information disclosure (reading arbitrary kernel memory).
Fix: Add a bounds check to ensure that the server-supplied `DataOffset` and `DataCount` do not lead to an out-of-bounds access. Specifically, before line 3720, add a check: `if (data_offset + count > bytes_returned) { cifs_dbg(FYI, 'Data offset or count out of bounds'); rc = smb_EIO2(smb_eio_trace_getextattr_data_oob, data_offset, count); goto GetExtAttrOut; }`. Also, consider a lower bound check: `if (data_offset < offsetof(struct smb_t2_rsp, ByteCount) + sizeof(__le16))` to ensure `data_offset` points past the fixed SMB/T2 header.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

CIFSGetSrvInodeNumber() — fs/smb/client/cifssmb.c BUG confidence=high

The function `CIFSGetSrvInodeNumber` processes an SMB transaction 2 response from the server. It extracts `DataOffset` and `DataCount` from this response. The `validate_t2` helper (called on line 4824) ensures that `DataOffset + DataCount` does not exceed the total `ByteCount` reported in the SMB header. Additionally, there is a check `count < 8` (line 4836) to ensure the `DataCount` is sufficient for a `struct file_internal_info` (which is 8 bytes). However, these checks are insufficient because there is no lower-bound validation on `data_offset`. A malicious server could supply a `data_offset` value that points into the fixed SMB header or parameter area of the `TRANSACTION2_QPI_RSP` struct. In such a scenario, the `pfinfo` pointer would be formed to point to an incorrect memory region, and the subsequent read of `pfinfo->UniqueId` would misinterpret header bytes as an inode number. This is a clear information disclosure vulnerability.

Finding #1 — Category E — BUG info_disclosure

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4832
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varpfinfo
Pointer derefpfinfo->UniqueId line 4844
Sink snippet*inode_number = le64_to_cpu(pfinfo->UniqueId);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Incorrect `inode_number` being populated from an out-of-band read of internal SMB header fields. This could lead to logical errors in subsequent file system operations that rely on the inode number, or potentially leak sensitive data from the SMB header to user-space.
Fix: Introduce a lower-bound check for `data_offset`. The `data_offset` (which is relative to `&pSMBr->hdr.Protocol`) must be at least the size of the fixed `smb_hdr` plus the fixed `smb_t2_rsp` fields, plus any actual `ParameterCount` bytes. A minimal check would be `if (data_offset < (sizeof(struct smb_hdr) + sizeof(struct smb_t2_rsp) + le16_to_cpu(pSMBr->t2.ParameterCount))) { /* handle error */ }` before `pfinfo` is constructed. This ensures `pfinfo` points to the actual data payload area.
CVE pattern: SMB transaction response parsing; missing lower-bound check on offset (Rule #7)

CIFSPOSIXCreate() — fs/smb/client/cifssmb.c BUG confidence=high

The function processes an SMB transaction response. The primary issue is that the server-supplied 'DataOffset' field (pSMBr->t2.DataOffset) is used to derive a pointer into the received buffer without being sufficiently validated against the actual received buffer length ('bytes_returned'). While there are checks for the overall minimum size of the response, these checks do not incorporate the 'DataOffset' value, allowing a malicious server to provide a large offset that causes subsequent dereferences and memcpy operations to read out-of-bounds.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 1132
Taint snippetpsx_rsp = (OPEN_PSX_RSP *)
Tainted varpsx_rsp
Pointer derefpsx_rsp->OplockFlags line 1135
Sink snippet*pOplock = le16_to_cpu(psx_rsp->OplockFlags);
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic (e.g., KASAN report for slab-out-of-bounds read) due to dereferencing an out-of-bounds pointer, or reading unexpected data from kernel memory.
Fix: Before line 1132 (where 'psx_rsp' is derived), add a bounds check: `unsigned int data_offset = le16_to_cpu(pSMBr->t2.DataOffset); if (data_offset + sizeof(OPEN_PSX_RSP) > bytes_returned) { cifs_dbg(VFS, "Bad DataOffset in POSIX Create response"); rc = -EINVAL; goto psx_create_err; }` This check ensures that the combination of the server-supplied offset and the size of the expected structure (OPEN_PSX_RSP) does not exceed the total received buffer size.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

Finding #2 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 1132
Taint snippetpsx_rsp = (OPEN_PSX_RSP *)
Tainted varpsx_rsp
Sinkmemcpy() line 1153 (arg 1, role=pointer)
Sink snippetmemcpy(pRetData,
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (e.g., KASAN report for slab-out-of-bounds read) due to `memcpy` reading from an out-of-bounds kernel source buffer, or copying unexpected data to 'pRetData'.
Fix: The same fix suggested for finding #1 is sufficient, as it bounds the 'DataOffset' before 'psx_rsp' is derived. Specifically, the required check for the `memcpy` is `data_offset + sizeof(OPEN_PSX_RSP) + sizeof(*pRetData) <= bytes_returned`. The proposed fix for finding #1 covers this by ensuring `data_offset + sizeof(OPEN_PSX_RSP)` is within bounds, and if that condition holds, the subsequent check at line 1147 ensures `sizeof(*pRetData)` also fits after it. However, to be fully robust, the first check should also consider `sizeof(*pRetData)`: `if (data_offset + sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO) > bytes_returned) { ... }`
CVE pattern: CVE-2022-NNNN style DataOffset OOB

CIFSSMBPosixLock() — fs/smb/client/cifssmb.c BUG confidence=high

The function receives a server response and parses fields from it. While some size checks are present, there is no explicit validation that the server-supplied DataOffset, when combined with the size of the expected structure, remains within the bounds of the actual received network buffer. The `validate_t2` helper is called, but its source is not provided, so its postconditions cannot be verified. Without this, the existing checks are insufficient.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 2381
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varparm_data
Pointer derefparm_data->lock_type line 2390
Sink snippetif (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or KASAN: slab-out-of-bounds read
Fix: After `data_offset` is extracted (line 2381) and before `parm_data` is dereferenced (line 2390), add a check to ensure the derived pointer plus the size of the struct does not exceed the actual received buffer length. For example: `if ((char *)&pSMBr->hdr.Protocol + data_offset + sizeof(struct cifs_posix_lock) > (char *)pSMBr + rsp_iov.iov_len) { rc = -EINVAL; /* or appropriate error */ goto plk_err_exit; }` This assumes `rsp_iov.iov_len` holds the true received buffer length, which it does after `SendReceive2`.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

CIFSSMBQAllEAs() — fs/smb/client/cifssmb.c MIXED confidence=high

The function `CIFSSMBQAllEAs` handles parsing of Extended Attributes (EAs) from an SMB server response. It performs a multi-layered validation strategy: 1. Basic Transaction2 response validation (`validate_t2`, `get_bcc`). 2. `DataOffset` validation for lower and upper bounds, ensuring the initial `struct fealist` header fits. 3. Overall `ea_response_data->list_len` validation against the actual SMB packet end (`end_of_smb`). 4. Iterative validation within the loop: `list_len` is decremented by the size of each `struct fea` entry, and negative `list_len` values are caught, preventing OOB reads/writes based on declared element sizes. 5. Destination buffer (`EAData`) validation using `buf_size` for all `memcpy` operations. Most findings are false positives due to these comprehensive checks. However, one finding related to a signedness mismatch for `list_len` is a real bug, as it can bypass a critical bounds check.

Finding #1 — Category H — BUG info_disclosure

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele32_to_cpu() line 6297
Taint snippetlist_len = le32_to_cpu(ea_response_data->list_len);
Tainted varlist_len
Sinknarrowing_assignment() line 6297 (arg 0, role=sign_conversion)
Sink snippetlist_len = le32_to_cpu(ea_response_data->list_len);
Possibly guardedno
SMTproved truncation — source is no wider than the destination (proof covers every unresolved value; it answers only this property)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Incorrect parsing of Extended Attributes; server-provided EAs may be silently ignored or misinterpreted as an empty list.
Fix: Change the type of `list_len` from `int` to `unsigned int` to correctly handle `u32` values from `le32_to_cpu`. Alternatively, add an explicit check `if (list_len < 0 || list_len > MAX_EXPECTED_EA_LIST_LEN) return -EINVAL;` immediately after the `le32_to_cpu` call.
CVE pattern: Integer type confusion

Finding #2 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6276
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varea_response_data
Pointer derefea_response_data->list_len line 6297
Sink snippetlist_len = le32_to_cpu(ea_response_data->list_len);
Possibly guardedno
Dismissed: The pointer `ea_response_data` is derived from `data_offset`, which is server-supplied. However, `data_offset` is thoroughly validated at lines 6277-6293: 1. `if (data_offset < sizeof(*pSMBr))` ensures `data_offset` is not too small (lower bound). 2. `else if ((size_t)data_offset + sizeof(struct fealist) > (size_t)bytes_returned)` ensures that `data_offset` plus the size of the `fealist` header (which includes `list_len` at offset 0) fits within the received `bytes_returned` (upper bound). These checks guarantee that `ea_response_data` points to a valid location within the buffer and that `sizeof(struct fealist)` bytes are accessible. Therefore, `ea_response_data->list_len` access is safe. Counterexample test: `data_offset = sizeof(*pSMBr) - 1` is caught by line 6277. `data_offset = bytes_returned - sizeof(struct fealist) + 1` is caught by line 6284. Any in-bounds `data_offset` ensures safety.

Finding #3 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6276
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varea_response_data
Pointer derefea_response_data->list line 6319
Sink snippettemp_fea = &ea_response_data->list;
Possibly guardedyes (heuristic)
Dismissed: Similar to finding #2, the pointer `ea_response_data` is derived from `data_offset`, which is validated at lines 6277-6293. The validation ensures that `sizeof(struct fealist)` bytes are available starting at `ea_response_data`. Since `list` is a member of `struct fealist` (typically at offset 4 after `list_len`), its access via `&ea_response_data->list` is covered by the existing bounds checks. Thus, this is a false positive.

Finding #4 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele32_to_cpu() line 6297
Taint snippetlist_len = le32_to_cpu(ea_response_data->list_len);
Tainted varlist_len
Loopwhile_loop line 6321
Sink snippetwhile (list_len > 0) {
Possibly guardedyes (heuristic)
Dismissed: The `list_len` variable, derived from server data, controls the `while (list_len > 0)` loop. However, its use is sufficiently guarded: 1. Pre-loop check: `if ((char *)ea_response_data + list_len > end_of_smb)` at line 6309 ensures that the declared `list_len` does not extend beyond the actual end of the SMB buffer. `end_of_smb` is precisely calculated from `get_bcc(&pSMBr->hdr)`. 2. In-loop checks: `list_len` is decremented by fixed amounts (4, then `name_len + 1 + value_len`). After each decrement, `if (list_len < 0)` checks (lines 6328, 6337) catch any declared element sizes that would exceed the remaining `list_len`. If a declared size is too large, the function errors out. These combined checks ensure that the loop traversal stays within the bounds of the received data. Given that issue #1 (signedness of `list_len`) is fixed, this loop control would be fully safe.

Finding #5 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6276
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted vartemp_fea
Pointer dereftemp_fea->name_len line 6334
Sink snippetname_len = temp_fea->name_len;
Possibly guardedno
Dismissed: The `temp_fea` pointer is advanced inside the loop. Accesses to `temp_fea->name_len` and `temp_fea->value_len` are guarded: 1. The overall `list_len` boundary is established by the check at line 6309 (as discussed in #4). 2. Inside the loop, before accessing `temp_fea->name_len` and `temp_fea->value_len`, `list_len` is decremented by 4 (line 6325). Immediately after, `if (list_len < 0)` (line 6328) checks if at least 4 bytes were available for the `struct fea` header fields (flags, name_len, value_len). If not, it errors out before the dereferences. This ensures that `name_len` (at offset 1) and `value_len` (at offset 2) are always read from within the valid `list_len` segment. False positive.

Finding #6 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 6334
Taint snippetname_len = temp_fea->name_len;
Tainted varname_len
Sinkmemcmp() line 6345 (arg 2, role=size)
Sink snippetmemcmp(ea_name, temp_ptr, name_len) == 0) {
Possibly guardedyes (heuristic)
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `name_len` value is read from server data via `temp_fea->name_len` and used as the size argument to `memcmp(ea_name, temp_ptr, name_len)`. Bounds check for source buffer (`temp_ptr`): After reading `name_len` (and `value_len`), `list_len` is decremented by `name_len + 1 + value_len` (line 6336). Immediately after, `if (list_len < 0)` (line 6337) checks if this total length exceeds the remaining available list size. If it does, the function errors out, preventing `memcmp` from being called with an `name_len` that would read OOB from `temp_ptr`. Thus, the source buffer is protected. False positive.

Finding #7 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 6276
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted vartemp_ptr
Sinkmemcmp() line 6345 (arg 1, role=pointer)
Sink snippetmemcmp(ea_name, temp_ptr, name_len) == 0) {
Possibly guardedno
Dismissed: The `temp_ptr` is derived from `data_offset` (server-supplied) and advanced by other server-supplied lengths (`name_len`, `value_len`). However, the effective range for `temp_ptr` is bounded by `ea_response_data` (validated at function entry) and the overall `list_len` (validated at line 6309). All advancements of `temp_ptr` (by 4, by `name_len + 1 + value_len`) are accompanied by decrements to `list_len` and subsequent `if (list_len < 0)` checks before `temp_ptr` is used. These checks ensure that `temp_ptr` always points within the valid, remaining portion of the EA list and that `name_len` bytes are available from `temp_ptr` for `memcmp`. False positive.

Finding #8 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 6335
Taint snippetvalue_len = le16_to_cpu(temp_fea->value_len);
Tainted varvalue_len
Sinkmemcpy() line 6354 (arg 2, role=size)
Sink snippetmemcpy(EAData, temp_ptr, value_len);
Possibly guardedyes (heuristic)
SMTproved negative — signed value cannot be negative where it reaches the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `value_len` is server-supplied and used as the size argument for `memcpy(EAData, temp_ptr, value_len)`. 1. Source buffer (`temp_ptr`): Protection is the same as for `name_len` in finding #6 and `temp_ptr` in #7. The `list_len -= name_len + 1 + value_len;` followed by `if (list_len < 0)` (line 6337) guarantees `value_len` bytes are available from `temp_ptr`. 2. Destination buffer (`EAData`): Explicit checks at lines 6350-6353 fully validate `value_len` against the caller-supplied `buf_size`: `if ((size_t)value_len > buf_size) { rc = -ERANGE; goto QAllEAsOut; }`. This prevents OOB writes to `EAData`. False positive.

Finding #9 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 6276
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted vartemp_ptr
Sinkmemcpy() line 6354 (arg 1, role=pointer)
Sink snippetmemcpy(EAData, temp_ptr, value_len);
Possibly guardedno
Dismissed: This is identical to finding #7, applied to `memcpy` instead of `memcmp`. The pointer `temp_ptr` is validated in the same way: its base (`ea_response_data`) is checked, its overall traversal is bounded by `list_len` (which is checked against `end_of_smb`), and each step of advancement is checked against the remaining `list_len` before use. This guarantees `temp_ptr` (and `temp_ptr + value_len`) remains within bounds. False positive.

Finding #10 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 6334
Taint snippetname_len = temp_fea->name_len;
Tainted varname_len
Sinkmemcpy() line 6363 (arg 2, role=size)
Sink snippetmemcpy(EAData, temp_ptr, name_len);
Possibly guardedno
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `name_len` is server-supplied and used as the size argument for `memcpy(EAData, temp_ptr, name_len)` in the `else` branch (when `ea_name` is NULL). 1. Source buffer (`temp_ptr`): Covered by the same `list_len` checks as in finding #6. `name_len` bytes are guaranteed to be available from `temp_ptr`. 2. Destination buffer (`EAData`): The copy is performed only if `rc < (int) buf_size` (line 6360). `rc` tracks the total length being written to `EAData` (including fixed prefixes). If `rc` would exceed `buf_size`, the copy is skipped or an error `rc = -ERANGE` is set (line 6371). This ensures that `name_len` bytes will fit into `EAData` at its current offset. False positive.

CIFSSMBQFSAttributeInfo() — fs/smb/client/cifssmb.c BUG confidence=high

The function receives a TRANSACTION2 response from the server. It extracts DataOffset from this response and uses it to calculate a pointer for memcpy. While there's a check on the total ByteCount (BCC) of the response, there's no specific validation that DataOffset, when combined with the size of the target structure (FILE_SYSTEM_ATTRIBUTE_INFO), actually fits within the bounds of the received network buffer. This allows a malicious server to cause an out-of-bounds read.

Finding #1 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 5209
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Sinkmemcpy() line 5214 (arg 1, role=pointer)
Sink snippetmemcpy(&tcon->fsAttrInfo, response_data,
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic (e.g., KASAN slab-out-of-bounds read or page fault) due to reading past the end of the allocated response buffer.
Fix: Add a bounds check after `data_offset` is extracted and before `response_data` is used in `memcpy`. The check should ensure that `data_offset` plus the size of `FILE_SYSTEM_ATTRIBUTE_INFO` does not exceed the total `bytes_returned` for the received SMB packet. Additionally, a lower bound check for `data_offset` (e.g., ensuring it points past the fixed part of the TRANSACTION2 header) should be added. Example: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); // Assuming data_offset is relative to the start of the SMB header (pSMBr) // And bytes_returned is the total length of the received SMB packet. // A more precise base for data_offset might be needed depending on SMB spec. // For CIFS, DataOffset is usually relative to the start of the SMB header. if (data_offset < sizeof(struct smb_t2_rsp) || (unsigned long)data_offset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) > bytes_returned) { cifs_dbg(VFS, "Bad DataOffset %u or response size %zu in QFSAttributeInfo (total %d)", data_offset, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO), bytes_returned); rc = -EINVAL; } else { response_data = (FILE_SYSTEM_ATTRIBUTE_INFO *)(((char *)pSMBr) + data_offset); memcpy(&tcon->fsAttrInfo, response_data, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)); } ```
CVE pattern: SMB response DataOffset OOB read

CIFSSMBQFSDeviceInfo() — fs/smb/client/cifssmb.c BUG confidence=high

The CIFSSMBQFSDeviceInfo function processes an SMB Transaction2 response. The DataOffset field, read from the server response, dictates where the FILE_SYSTEM_DEVICE_INFO structure is located within the received SMB buffer. The existing validation checks are insufficient to ensure that the DataOffset points to a location within the bounds of the actually received data and that the entire FILE_SYSTEM_DEVICE_INFO structure will fit within those bounds, leading to a potential out-of-bounds read.

Finding #1 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 5284
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Sinkmemcpy() line 5289 (arg 1, role=pointer)
Sink snippetmemcpy(&tcon->fsDevInfo, response_data,
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic from OOB read, BUG: KASAN: slab-out-of-bounds read
Fix: Before line 5288, after extracting `data_offset`, add comprehensive bounds checks: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); __u16 param_offset = le16_to_cpu(pSMBr->t2.ParameterOffset); __u16 param_count = le16_to_cpu(pSMBr->t2.ParameterCount); // Calculate the end of the parameter section (relative to start of SMB header) unsigned int param_end_offset = param_offset + param_count; // Check if DataOffset points before the end of parameters or outside the received buffer if (data_offset < param_end_offset || data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > bytes_returned) { cifs_dbg(VFS, "Invalid DataOffset (%hu), ParameterOffset (%hu), ParameterCount (%hu) or response too small (%d) for QFSDeviceInfo ", data_offset, param_offset, param_count, bytes_returned); rc = -EPROTO; goto QFSDeviceRetry; } response_data = (FILE_SYSTEM_DEVICE_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); ``` The check `data_offset < param_end_offset` ensures that the data portion does not overlap with the parameters. The check `data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > bytes_returned` ensures that the entire `FILE_SYSTEM_DEVICE_INFO` structure fits within the actually received message buffer (reported by `bytes_returned`). The `response_data` pointer calculation must align with `data_offset`'s reference point (which is usually the start of the SMB header, `pSMBr`). The provided `response_data` calculation `(((char *) &pSMBr->hdr.Protocol) + data_offset)` implies that `data_offset` is relative to `&pSMBr->hdr.Protocol`, which is `pSMBr + offsetof(struct smb_hdr, Protocol)`. In this case, the `bytes_returned` check should be `offsetof(struct smb_hdr, Protocol) + data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > bytes_returned`. Given the context of standard SMB `DataOffset` usage, `data_offset` is commonly relative to the start of the SMB header `pSMBr`. If that is the case, the proposed fix using `bytes_returned` directly as the upper limit is appropriate for the overall buffer boundary. The `param_end_offset` should also be calculated relative to the `pSMBr` start.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

CIFSSMBQFSInfo() — fs/smb/client/cifssmb.c BUG confidence=high

The function receives an SMB TRANSACTION2 response. A server-supplied DataOffset field is extracted and used to calculate a pointer `response_data`. The code then dereferences this pointer to read a `FILE_SYSTEM_SIZE_INFO` structure (24 bytes) without adequately checking if the entire structure fits within the received network buffer. The existing check `get_bcc(&pSMBr->hdr) < 24` only verifies a minimum size for the transaction data block, which is insufficient to cover the derived pointer's offset and the full size of the `FILE_SYSTEM_SIZE_INFO` structure.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 5118
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Pointer derefresponse_data->BytesPerSector line 5125
Sink snippetle32_to_cpu(response_data->BytesPerSector) *
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (e.g., KASAN report, page fault, general protection fault) due to reading from an invalid memory address. Potentially information disclosure if it reads from other kernel memory.
Fix: Add a bounds check before line 5120 to ensure the `FILE_SYSTEM_SIZE_INFO` structure can be safely read from `response_data`. The `DataOffset` field in `TRANSACTION2_QFSI_RSP` (aliased as `smb_t2_rsp`) is generally an offset from the beginning of the SMB header. The current pointer arithmetic `((char *) &pSMBr->hdr.Protocol) + data_offset` effectively makes `response_data` point to `pSMBr + 4 + data_offset`. Let `bytes_returned` be the total length of the received SMB message (from `SendReceive`). The check should be: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); // Calculate the actual end of the valid buffer // response_data will point to (char *)pSMBr + 4 + data_offset // sizeof(FILE_SYSTEM_SIZE_INFO) is 24 bytes. if ((unsigned long)4 + data_offset + sizeof(FILE_SYSTEM_SIZE_INFO) > bytes_returned) { cifs_dbg(VFS, "cifs: Data offset (0x%x) or response size too large in QFSInfo (total_len=%u)\n", data_offset, bytes_returned); rc = -EINVAL; /* Or appropriate SMB error code */ goto release; /* or equivalent cleanup */ } response_data = (FILE_SYSTEM_SIZE_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); ``` Additionally, a lower bound check for `data_offset` is advisable to prevent misinterpreting header fields as `FILE_SYSTEM_SIZE_INFO` data, e.g., `data_offset >= expected_min_offset_for_data_payload`.
CVE pattern: CVE-XXXX-XXXX style SMB DataOffset OOB read

CIFSSMBQFSPosixInfo() — fs/smb/client/cifssmb.c BUG confidence=high

The function reads server-supplied `DataOffset` from a TRANSACTION2 response and uses it to calculate a pointer `response_data`. This pointer is then dereferenced to read multiple fields of `FILE_SYSTEM_POSIX_INFO`. While `validate_t2` is called, the specific check that `data_offset + sizeof(FILE_SYSTEM_POSIX_INFO)` must not exceed the actual received buffer length (after accounting for the base pointer `&pSMBr->hdr.Protocol`) is not explicitly present. The `get_bcc < 13` check is too small to cover the entire `FILE_SYSTEM_POSIX_INFO` structure (which is 44 bytes for the accessed fields).

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 5505
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Pointer derefresponse_data->BlockSize line 5511
Sink snippetle32_to_cpu(response_data->BlockSize);
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic due to read from unmapped memory or information disclosure due to reading arbitrary kernel memory into `kstatfs` struct. `BUG: KASAN: slab-out-of-bounds Read`.
Fix: Immediately after `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);`, add a check similar to: ```c if (data_offset < 0 || data_offset + sizeof(FILE_SYSTEM_POSIX_INFO) > bytes_returned - (size_t)((char *)&pSMBr->hdr.Protocol - (char *)pSMBr)) { cifs_dbg(VFS, "Bad Posix Info data offset/length %u %zu bytes_returned %d\n", data_offset, sizeof(FILE_SYSTEM_POSIX_INFO), bytes_returned); rc = -EINVAL; goto out; } ``` (Note: The expression `(size_t)((char *)&pSMBr->hdr.Protocol - (char *)pSMBr)` calculates the offset of `&pSMBr->hdr.Protocol` from the start of the `pSMBr` buffer. This needs to be precisely determined from the SMB header structure, usually `sizeof(smb_hdr) - sizeof(__le32)` or similar if `Protocol` is the first actual field after the fixed signature.) Alternatively, `validate_t2` should be updated to cover this specific data block's length and offset.
CVE pattern: CVE-XXXX-NNNN style DataOffset OOB

CIFSSMBQFSUnixInfo() — fs/smb/client/cifssmb.c BUG confidence=high

The CIFSSMBQFSUnixInfo function makes a Transaction2 Query File System Information request. It receives a response into 'pSMBr'. The DataOffset field from this response is extracted and used to calculate a pointer 'response_data'. This pointer is then used as the source for a memcpy. While a 'validate_t2' function is called, and a minimum byte count check (`get_bcc < 13`) is present, there is no explicit check to ensure that the server-supplied 'DataOffset' plus the size of the structure being copied (`sizeof(FILE_SYSTEM_UNIX_INFO)`) actually fits within the total received buffer. This allows a malicious server to send a large DataOffset, leading to an out-of-bounds read.

Finding #1 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 5356
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Sinkmemcpy() line 5361 (arg 1, role=pointer)
Sink snippetmemcpy(&tcon->fsUnixInfo, response_data,
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic due to page fault or KASAN report (slab-out-of-bounds read) during memcpy from unmapped or invalid kernel memory.
Fix: Before the memcpy on line 5361, add a bounds check to ensure the calculated data range fits within the received buffer. The DataOffset (`data_offset`) is relative to `&pSMBr->hdr.Protocol`. The total received buffer size is `bytes_returned`. The accessible data from `&pSMBr->hdr.Protocol` onwards is `bytes_returned - offsetof(TRANSACTION2_QFSI_RSP, hdr.Protocol)`. The check should be: ```c if (rc || get_bcc(&pSMBr->hdr) < 13) { rc = smb_EIO2(smb_eio_trace_qfsunixinfo_bcc_too_small, get_bcc(&pSMBr->hdr), 13); } else { __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); // Calculate available bytes from the base of DataOffset size_t available_bytes_from_protocol = bytes_returned - offsetof(TRANSACTION2_QFSI_RSP, hdr.Protocol); // Check if the offset plus the size of the target struct exceeds available bytes if (data_offset > available_bytes_from_protocol || data_offset + sizeof(FILE_SYSTEM_UNIX_INFO) > available_bytes_from_protocol) { cifs_dbg(VFS, "QFSUnixInfo: Data offset 0x%x or size 0x%zx too large for buffer (0x%zx bytes available)", data_offset, sizeof(FILE_SYSTEM_UNIX_INFO), available_bytes_from_protocol); rc = -EIO; } else { response_data = (FILE_SYSTEM_UNIX_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); memcpy(&tcon->fsUnixInfo, response_data, sizeof(FILE_SYSTEM_UNIX_INFO)); } } ``` Additionally, consider adding a check `if (data_offset < sizeof(struct smb_t2_rsp_fixed_part))` to ensure `data_offset` does not point into the transaction2 response header itself, if data is expected to follow the header.
CVE pattern: CVE-YYYY-NNNN style DataOffset OOB

CIFSSMBRead() — fs/smb/client/cifssmb.c FP confidence=high

The function performs multiple layers of validation for server-supplied values extracted from the SMB response. Specifically, the `rsp_iov.iov_len` (actual received buffer size) is used to bound both the `data_offset` and `data_length` values, preventing OOB reads from the source buffer. Additionally, `data_length` is capped by the client-requested `count`, ensuring it doesn't exceed the intended destination buffer size.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 1722
Taint snippetunsigned int data_length = le16_to_cpu(pSMBr->DataLengthHigh);
Tainted vardata_length
Sinkmemcpy() line 1751 (arg 2, role=size)
Sink snippetmemcpy(*buf, pReadData, data_length);
Possibly guardedyes (heuristic)
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `data_length` variable is derived from server-supplied fields (lines 1722, 1725). It is used as the size argument to `memcpy` (line 1751). The following checks ensure safety: 1. Line 1713: `rsp_iov.iov_len < tcon->ses->server->vals->read_rsp_size` ensures that the basic SMB response header, including `DataLengthHigh` and `DataLength`, can be read without an OOB read of `pSMBr` itself. 2. Line 1730: `(data_length > CIFSMaxBufSize) || (data_length > count)` caps `data_length` to prevent excessive values. `count` (`io_parms->length`) is the client-requested read size, which implies the destination buffer `*buf` is at least this large (if not NULL). 3. Line 1736: `(size_t)data_offset + data_length > rsp_iov.iov_len` is the crucial check. It ensures that the entire region from `data_offset` for `data_length` bytes fits within the *actual received network buffer* (`rsp_iov.iov_len`). If this check passes, the read of `data_length` bytes from `pReadData` (which is `pSMBr` + `data_offset`) will not be out-of-bounds from the `rsp_iov.iov_base` source buffer. The `memcpy` source is `pReadData`, which is `(char *) (&pSMBr->hdr.Protocol) + data_offset` (line 1745). Counterexample test: - Assume `rsp_iov.iov_len = 100`, `tcon->ses->server->vals->read_rsp_size = 31`. - If `data_offset = 31` (just past header) and `data_length = 70` (total 101 bytes). - Line 1736 evaluates `(31 < 31)` as false, and `(size_t)31 + 70 > 100` (i.e., `101 > 100`) as true. The `if` condition is met, leading to an error return (`smb_EIO2`), preventing the OOB read. - If `data_length = 0`, `memcpy` is a no-op and safe. The SMT result indicates `data_length` is unsigned, which does not negate the need for size bounds checks, but the code already provides them.

Finding #2 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 1723
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
Tainted varpReadData
Sinkmemcpy() line 1751 (arg 1, role=pointer)
Sink snippetmemcpy(*buf, pReadData, data_length);
Possibly guardedno
Dismissed: The `data_offset` variable is derived from a server-supplied field (line 1723) and used in pointer arithmetic to determine `pReadData` (line 1745). This pointer `pReadData` is then used as the source for `memcpy`. 1. Line 1713: `rsp_iov.iov_len < tcon->ses->server->vals->read_rsp_size` ensures that `pSMBr->DataOffset` can be read from the received buffer without OOB. 2. Line 1736: `data_offset < sizeof(*pSMBr)` provides a lower-bound check, ensuring that `data_offset` points *beyond* the fixed header of the SMB response. This prevents `pReadData` from pointing into the header and misinterpreting header bytes as data. 3. Line 1736: `(size_t)data_offset + data_length > rsp_iov.iov_len` provides an upper-bound check, ensuring that the starting point `pReadData` plus the `data_length` does not exceed the bounds of the actually received `rsp_iov.iov_len` buffer. This guarantees `pReadData` (and the region it spans) is within the received packet. Counterexample test: - Assume `rsp_iov.iov_len = 100`, `sizeof(*pSMBr) = 31` (e.g., standard header size). - If `data_offset = 5` (less than `sizeof(*pSMBr) = 31`) and `data_length = 95`. - Line 1736 evaluates `(5 < 31)` as true. The `if` condition is met, leading to an error return (`smb_EIO2`), preventing `pReadData` from being formed incorrectly and subsequently used in an OOB copy. - If `data_offset = 100` (equal to `rsp_iov.iov_len`) and `data_length = 1`. - Line 1736 evaluates `(100 < 31)` as false. `(size_t)100 + 1 > 100` (i.e., `101 > 100`) as true. The `if` condition is met, leading to an error return, preventing OOB access. This demonstrates that `pReadData` will always be a safe starting point relative to `rsp_iov.iov_len`.

SMBOldQFSInfo() — fs/smb/client/cifssmb.c BUG confidence=high

The function partially validates the total byte count from the server response but fails to validate a crucial server-supplied offset (`DataOffset`) against the remaining buffer size. This allows a malicious server to cause an out-of-bounds read when accessing fields of the `FILE_SYSTEM_ALLOC_INFO` struct.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 5028
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Pointer derefresponse_data->BytesPerSector line 5035
Sink snippetle16_to_cpu(response_data->BytesPerSector) *
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or KASAN slab-out-of-bounds read report due to reading past the end of the server response buffer.
Fix: After extracting `data_offset` (line 5028), add a check to ensure that `data_offset` plus the size of `FILE_SYSTEM_ALLOC_INFO` does not exceed the total available data reported by `get_bcc(&pSMBr->hdr)`. For example: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); __u16 total_data_len = get_bcc(&pSMBr->hdr); // Assuming FILE_SYSTEM_ALLOC_INFO_SIZE is the maximum expected size (e.g., 18 or 16) // For robustness, check both lower and upper bounds of data_offset if (data_offset < SOME_MIN_OFFSET_FOR_DATA || // e.g., ParameterOffset + ParameterCount data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO) > total_data_len) { rc = -EIO; // Or a more specific error cifs_dbg(VFS, "Bad DataOffset or too short response data: offset %d, struct size %zu, total_len %d\n", data_offset, sizeof(FILE_SYSTEM_ALLOC_INFO), total_data_len); break; // Or appropriate error handling } ```
CVE pattern: CVE-YYYY-NNNN style DataOffset OOB

cifs_create_reparse_inode() — fs/smb/client/cifssmb.c BUG confidence=high

The function `cifs_create_reparse_inode` processes an `xattr_iov` buffer, which is treated as containing server-supplied (or user-controlled) data. It iterates through `smb2_file_full_ea_info` structures within this buffer. The primary issue is a lack of comprehensive bounds checking on this `xattr_iov` buffer during traversal and data extraction. The `xattr_iov->iov_len` is not used to validate the integrity or bounds of the parsed structures.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 3166
Taint snippetea = (struct smb2_file_full_ea_info *)((u8 *)ea +
Tainted varea
Pointer derefea->next_entry_offset line 3167
Sink snippetle32_to_cpu(ea->next_entry_offset));
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic or KASAN report due to an out-of-bounds read when traversing extended attribute (EA) entries. The `ea->next_entry_offset` read itself, or a subsequent access to the `ea` pointer after advancement, will be OOB.
Fix: Before the `while (1)` loop, ensure that `xattr_iov->iov_len` is at least large enough to contain the initial `struct smb2_create_ea_ctx`. Inside the loop, before advancing `ea`, add a check to verify that `ea + le32_to_cpu(ea->next_entry_offset) + sizeof(struct smb2_file_full_ea_info)` does not exceed `xattr_iov->iov_base + xattr_iov->iov_len`. Also, ensure `le32_to_cpu(ea->next_entry_offset)` is not zero if it's not the last entry and that it's not too small (e.g., less than `sizeof(struct smb2_file_full_ea_info)` if it's meant to point to a valid next entry).
CVE pattern: SMB XATTR traversal OOB read

Finding #2 — Category B — cross-function via CIFSSMBSetEA() — BUG oob_read

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 3155
Taint snippetrc = CIFSSMBSetEA(xid,
Tainted varle16_to_cpu(ea->ea_value_length)
Call siteline 3155 — passes le16_to_cpu(ea->ea_value_length) to CIFSSMBSetEA()
Call snippetrc = CIFSSMBSetEA(xid,
Sink (in callee)memcpy() line 6481 (arg 2, role=size)
Sink snippetmemcpy(parm_data->list.name + name_len + 1,
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic or KASAN report due to an out-of-bounds read from the `xattr_iov` buffer when `CIFSSMBSetEA` attempts to `memcpy` the `ea_value` using an untrusted `ea_value_len`. While `CIFSSMBSetEA` validates the *destination* buffer, it has no knowledge of the *source* buffer's (`xattr_iov`) bounds.
Fix: In `cifs_create_reparse_inode`, before calling `CIFSSMBSetEA`, add a check to ensure that the `ea_value` (which is derived from `ea->ea_data`) plus its length `le16_to_cpu(ea->ea_value_length)` does not exceed the bounds of the original `xattr_iov` buffer. Specifically, `(u8 *)&ea->ea_data[ea->ea_name_length + 1] + le16_to_cpu(ea->ea_value_length)` must be less than or equal to `(u8 *)xattr_iov->iov_base + xattr_iov->iov_len`.
CVE pattern: SMB XATTR OOB read (memcpy source)

cifs_query_reparse_point() — fs/smb/client/cifssmb.c BUG confidence=high

The function performs multiple sanity checks on server-supplied lengths and offsets (upper bounds, buffer fit for struct size). However, it critically misses a lower-bound validation for the `DataOffset` field. This omission allows a malicious server to supply an offset that points into the fixed header portion of the SMB response, causing misinterpretation of header fields as application-specific data. This aligns with pattern 7 (Missing lower-bound check on struct-internal offsets).

Finding #1 — Category E — BUG info_disclosure

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 3043
Taint snippetdata_offset = le32_to_cpu(io_rsp->DataOffset);
Tainted varbuf
Pointer derefbuf->ReparseDataLength line 3083
Sink snippetdata_count < le16_to_cpu(buf->ReparseDataLength) + len) {
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Incorrect reparse tag or length returned to the caller; potential for misinterpretation of SMB header fields as reparse point data if the server supplies a small DataOffset value.
Fix: Add a lower bound check for `data_offset` before casting to `struct reparse_data_buffer *buf`. The check should ensure `data_offset` is at least beyond the fixed-size header of the `TRANSACT_IOCTL_RSP` structure. For example, `if (data_offset < offsetof(TRANSACT_IOCTL_RSP, ByteCount) + sizeof(__le16))` or a similar calculation that ensures `start` points past the fixed header and any parameter data.
CVE pattern: Missing lower-bound check on server-supplied offset

cifs_to_posix_acl() — fs/smb/client/cifssmb.c FP confidence=high

The function calculates a pointer to the start of a sequence of ACEs within a server-supplied buffer. The pointer calculation itself (array indexing) is not a memory access that can cause OOB. The subsequent dereferencing of this pointer within a loop is sufficiently guarded by a total size check that accounts for all access and default ACEs before any dereference occurs.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 3340
Taint snippetcount = le16_to_cpu(cifs_acl->access_entry_count);
Tainted varcount
Subscript[] line 3349
Sink snippetpACE = &cifs_acl->ace_array[count];
Possibly guardedno
SMTproved negative — signed value cannot be negative where it reaches the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `count` variable is derived from `cifs_acl->access_entry_count`, which is server-supplied. The sink `pACE = &cifs_acl->ace_array[count]` at line 3349 performs pointer arithmetic to get the address of the first default ACE. This operation itself does not dereference memory. The `size` variable is updated to reflect the total expected length for both access and default ACEs (line 3351), and a `size_of_data_area < size` check is performed at line 3353 BEFORE `pACE` is actually dereferenced in the `FOREACH_ACL_ENTRY` loop (line 3366). This final check ensures that the entire region covered by `pACE` and its subsequent increments within the loop is within the `size_of_data_area`. The `size_of_data_area` is the actual received buffer length. Thus, the dereferences are correctly bounded.