Bounds Checker Report — 20261008_193428_fs_smb_client

Date: 2026-10-08 19:37:35 Model: gemini-2.5-flash Source: fs/smb/client Files: 88 Stage 1: 114 findings (Cat A: 21  |  Cat B: 29  |  Cat C: 7  |  Cat E: 31  |  Cat F: 13  |  Cat G2: 6  |  Cat H: 7 (+3 retired)) Stage 1.7 SMT: 3 retired by proof (excluded from the counts above and from the sections below; see stage1_7_smt.json) Stage 2: 43 real  |  71 FP  |  0 unanalyzed Kernel: v7.3-rc5-339-g319797a5f4eb Branch: work/bc1
2 local commit(s) since origin/master
  1. 319797a5f4eb smb: client: fix OOB read due to invalid data_offset in CIFSSMBQAllEAs
  2. 034ce6e1a96f smb: client: prevent read of header as data in open_cached_dir

Contents

fs/smb/client/ (67 functions) — 43 real, 71 FP
open_cached_dir() — cached_dir.c FP build_sec_desc() — cifsacl.c FP id_mode_to_cifs_acl() — cifsacl.c MIXED parse_dacl() — cifsacl.c FP replace_sids_and_copy_aces() — cifsacl.c FP set_chmod_dacl() — cifsacl.c FP validate_dacl() — cifsacl.c FP CIFSFindFirst() — cifssmb.c BUG CIFSFindNext() — cifssmb.c BUG CIFSGetExtAttr() — cifssmb.c BUG CIFSGetSrvInodeNumber() — cifssmb.c BUG CIFSPOSIXCreate() — cifssmb.c BUG CIFSSMBPosixLock() — cifssmb.c BUG CIFSSMBQAllEAs() — cifssmb.c MIXED CIFSSMBQFSAttributeInfo() — cifssmb.c BUG CIFSSMBQFSDeviceInfo() — cifssmb.c BUG CIFSSMBQFSInfo() — cifssmb.c BUG CIFSSMBQFSPosixInfo() — cifssmb.c BUG CIFSSMBQFSUnixInfo() — cifssmb.c BUG CIFSSMBRead() — cifssmb.c FP CIFSSMBUnixQuerySymLink() — cifssmb.c BUG SMBOldQFSInfo() — cifssmb.c BUG cifs_create_reparse_inode() — cifssmb.c BUG cifs_query_reparse_point() — cifssmb.c FP cifs_to_posix_acl() — cifssmb.c FP cifs_dump_full_key() — ioctl.c FP parse_dfs_referrals() — misc.c FP cnvrtDosUnixTm() — netmisc.c FP mknod_wsl() — reparse.c FP parse_reparse_nfs() — reparse.c BUG parse_reparse_wsl_symlink() — reparse.c MIXED is_valid_oplock_break() — smb1misc.c BUG cifs_query_path_info() — smb1ops.c FP sess_auth_kerberos() — smb1session.c FP sess_auth_rawntlmssp_authenticate() — smb1session.c FP coalesce_t2() — smb1transport.c FP symlink_data() — smb2file.c FP check_wsl_eas() — smb2inode.c FP parse_posix_sids() — smb2inode.c BUG reparse_buf_ptr() — smb2inode.c FP smb2_compound_op() — smb2inode.c FP smb2_check_message() — smb2misc.c FP smb2_tcon_find_pending_open_lease() — smb2misc.c BUG smb2_tcon_has_lease() — smb2misc.c BUG crypt_message() — smb2ops.c FP move_smb2_ea_to_cifs() — smb2ops.c FP parse_server_interfaces() — smb2ops.c FP receive_encrypted_standard() — smb2ops.c FP smb2_ioctl_query_info() — smb2ops.c FP smb2_query_eas() — smb2ops.c BUG smb3_enum_snapshots() — smb2ops.c BUG smb3_fiemap() — smb2ops.c FP smb3_simple_fallocate_range() — smb2ops.c FP SMB2_QFS_attr() — smb2pdu.c MIXED __smb2_plain_req_init() — smb2pdu.c FP decode_compress_ctx() — smb2pdu.c FP fill_small_buf() — smb2pdu.c FP parse_posix_ctxt() — smb2pdu.c FP parse_query_id_ctxt() — smb2pdu.c FP posix_info_parse() — smb2pdu.c BUG query_info() — smb2pdu.c FP smb2_parse_contexts() — smb2pdu.c BUG smb311_decode_neg_context() — smb2pdu.c MIXED smb2_calc_signature() — smb2transport.c FP smb2_seq_num_into_buf() — smb2transport.c FP smb3_calc_signature() — smb2transport.c FP __release_mid() — transport.c FP

Summary

FunctionFileAssessmentConfidenceRealFPUnanalyzed
fs/smb/client/ — 67 functions, 43 real, 71 FP
open_cached_dir()fs/smb/client/cached_dir.cFPhigh010
build_sec_desc()fs/smb/client/cifsacl.cFPhigh040
id_mode_to_cifs_acl()fs/smb/client/cifsacl.cMIXEDhigh120
parse_dacl()fs/smb/client/cifsacl.cFPhigh030
replace_sids_and_copy_aces()fs/smb/client/cifsacl.cFPhigh010
set_chmod_dacl()fs/smb/client/cifsacl.cFPhigh010
validate_dacl()fs/smb/client/cifsacl.cFPhigh010
CIFSFindFirst()fs/smb/client/cifssmb.cBUGhigh100
CIFSFindNext()fs/smb/client/cifssmb.cBUGhigh100
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.cMIXEDhigh630
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
CIFSSMBUnixQuerySymLink()fs/smb/client/cifssmb.cBUGhigh200
SMBOldQFSInfo()fs/smb/client/cifssmb.cBUGhigh100
cifs_create_reparse_inode()fs/smb/client/cifssmb.cBUGhigh200
cifs_query_reparse_point()fs/smb/client/cifssmb.cFPhigh010
cifs_to_posix_acl()fs/smb/client/cifssmb.cFPhigh010
cifs_dump_full_key()fs/smb/client/ioctl.cFPhigh030
parse_dfs_referrals()fs/smb/client/misc.cFPhigh030
cnvrtDosUnixTm()fs/smb/client/netmisc.cFPhigh010
mknod_wsl()fs/smb/client/reparse.cFPhigh020
parse_reparse_nfs()fs/smb/client/reparse.cBUGhigh100
parse_reparse_wsl_symlink()fs/smb/client/reparse.cMIXEDhigh110
is_valid_oplock_break()fs/smb/client/smb1misc.cBUGhigh100
cifs_query_path_info()fs/smb/client/smb1ops.cFPhigh040
sess_auth_kerberos()fs/smb/client/smb1session.cFPhigh020
sess_auth_rawntlmssp_authenticate()fs/smb/client/smb1session.cFPhigh020
coalesce_t2()fs/smb/client/smb1transport.cFPhigh030
symlink_data()fs/smb/client/smb2file.cFPhigh010
check_wsl_eas()fs/smb/client/smb2inode.cFPhigh020
parse_posix_sids()fs/smb/client/smb2inode.cBUGhigh220
reparse_buf_ptr()fs/smb/client/smb2inode.cFPhigh010
smb2_compound_op()fs/smb/client/smb2inode.cFPhigh010
smb2_check_message()fs/smb/client/smb2misc.cFPhigh010
smb2_tcon_find_pending_open_lease()fs/smb/client/smb2misc.cBUGhigh100
smb2_tcon_has_lease()fs/smb/client/smb2misc.cBUGhigh100
crypt_message()fs/smb/client/smb2ops.cFPhigh010
move_smb2_ea_to_cifs()fs/smb/client/smb2ops.cFPhigh010
parse_server_interfaces()fs/smb/client/smb2ops.cFPhigh010
receive_encrypted_standard()fs/smb/client/smb2ops.cFPhigh010
smb2_ioctl_query_info()fs/smb/client/smb2ops.cFPhigh020
smb2_query_eas()fs/smb/client/smb2ops.cBUGhigh200
smb3_enum_snapshots()fs/smb/client/smb2ops.cBUGhigh100
smb3_fiemap()fs/smb/client/smb2ops.cFPhigh010
smb3_simple_fallocate_range()fs/smb/client/smb2ops.cFPhigh010
SMB2_QFS_attr()fs/smb/client/smb2pdu.cMIXEDhigh210
__smb2_plain_req_init()fs/smb/client/smb2pdu.cFPhigh010
decode_compress_ctx()fs/smb/client/smb2pdu.cFPhigh010
fill_small_buf()fs/smb/client/smb2pdu.cFPhigh010
parse_posix_ctxt()fs/smb/client/smb2pdu.cFPhigh020
parse_query_id_ctxt()fs/smb/client/smb2pdu.cFPhigh010
posix_info_parse()fs/smb/client/smb2pdu.cBUGhigh210
query_info()fs/smb/client/smb2pdu.cFPhigh010
smb2_parse_contexts()fs/smb/client/smb2pdu.cBUGhigh400
smb311_decode_neg_context()fs/smb/client/smb2pdu.cMIXEDhigh110
smb2_calc_signature()fs/smb/client/smb2transport.cFPhigh010
smb2_seq_num_into_buf()fs/smb/client/smb2transport.cFPhigh010
smb3_calc_signature()fs/smb/client/smb2transport.cFPhigh010
__release_mid()fs/smb/client/transport.cFPhigh010

Function Details

open_cached_dir() — fs/smb/client/cached_dir.c FP confidence=high

The `smb2_validate_and_copy_iov` function is designed to perform validation before copying. It explicitly calls `smb2_validate_iov` with the tainted offset and length parameters before the `memcpy` operation. The `smb2_validate_iov` function is expected to perform the necessary bounds checks, making the subsequent `memcpy` safe. This pattern aligns with the false positive rule: 'a function whose name ends in validate_*/dacl_*_valid/check_* may be the validator itself — findings about its internal accesses are usually false positives because those accesses ARE the validation logic'.

Finding #1 — Category A — cross-function via smb2_validate_and_copy_iov() — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 391
Taint snippetif (!smb2_validate_and_copy_iov(
Tainted varle16_to_cpu(qi_rsp->OutputBufferOffset)
Call siteline 391 — passes le16_to_cpu(qi_rsp->OutputBufferOffset) to smb2_validate_and_copy_iov()
Call snippetif (!smb2_validate_and_copy_iov(
Sink (in callee)memcpy() line 3900 (arg 1, role=pointer)
Sink snippetmemcpy(data, begin_of_buf, minbufsize);
Possibly guardedno
Dismissed: The `le16_to_cpu(qi_rsp->OutputBufferOffset)` is indeed server-supplied, as `qi_rsp` points to a received network buffer. A lower-bound check `le16_to_cpu(qi_rsp->OutputBufferOffset) < sizeof(struct smb2_query_info_rsp)` is present at line 380. More importantly, the `smb2_validate_and_copy_iov` function itself calls `smb2_validate_iov` (line 3896) before performing the `memcpy` (line 3900). The `smb2_validate_iov` function is expected to validate that `offset + buffer_length` (which is `le16_to_cpu(qi_rsp->OutputBufferOffset) + sizeof(struct smb2_file_all_info)`) fits within the `iov->iov_len` of the received buffer. This internal validation within the callee makes the `memcpy` safe. No counterexample can be constructed if `smb2_validate_iov` performs its intended bounds check (e.g., `offset + size <= iov->iov_len`).

build_sec_desc() — fs/smb/client/cifsacl.c FP confidence=high

The `build_sec_desc` function receives a server-supplied security descriptor (`pntsd`) and its total length (`secdesclen`). Before making any complex dereferences into the DACL portion of this descriptor, it performs two critical validation steps: `dacl_offset_valid()` and `validate_dacl()`. These validators ensure that the `dacloffset` is within bounds, does not overlap with the main header, and that the entire DACL structure, including all its Access Control Entries (ACEs), is well-formed and fits within the allocated buffer. Subsequent accesses to `dacl_ptr` and its derived `pntace` pointers are therefore operating on data that has already been thoroughly validated for bounds and structure.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 1448
Taint snippetdacloffset = le32_to_cpu(pntsd->dacloffset);
Tainted vardacl_ptr
Pointer derefdacl_ptr->revision line 1478
Sink snippetdacloffset ? dacl_ptr->revision : cpu_to_le16(ACL_REVISION);
Possibly guardedno
Dismissed: The `dacloffset` is server-supplied. The pointer `dacl_ptr` is derived from `pntsd + dacloffset`. The `dacl_ptr->revision` access is protected by the `dacl_offset_valid(secdesclen, dacloffset)` call at line 1450. This helper function ensures: 1. `dacloffset >= sizeof(struct smb_ntsd)`: The DACL starts after the main security descriptor header. 2. `dacloffset <= secdesclen - sizeof(struct smb_acl)`: There is enough space in the buffer for at least the `struct smb_acl` header starting at `dacloffset`. Since `revision` is the first field of `struct smb_acl` (offset 0), accessing `dacl_ptr->revision` is guaranteed to be within bounds if `dacl_offset_valid` returns true. No counterexample exists where `dacl_offset_valid` passes but `dacl_ptr->revision` is OOB.

Finding #2 — Category E — cross-function via validate_dacl() — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 1448
Taint snippetdacloffset = le32_to_cpu(pntsd->dacloffset);
Tainted vardacl_ptr
Call siteline 1456 — passes dacl_ptr to validate_dacl()
Call snippetrc = validate_dacl(dacl_ptr, end_of_acl);
Pointer derefdacl_ptr-> line 900
Sink snippetpace->sid.num_subauth == 0 ||
Possibly guardedno
Dismissed: The `dacloffset` is server-supplied. `dacl_ptr` is passed to `validate_dacl` as `pdacl`. The accesses to `pace->sid.num_subauth` (and other fields of `pace`) within `validate_dacl` are part of the validation logic itself. The purpose of `validate_dacl` is to check the integrity and bounds of the DACL structure and its ACEs. It explicitly checks buffer boundaries (e.g., `end_of_acl < (char *)pdacl + sizeof(struct smb_acl)` at line 862, `end_of_dacl - acl_base < ace_size` at line 891, 907, 914) and returns an error if any malformed or out-of-bounds structure is detected. Therefore, these accesses are not vulnerable sinks but rather the mechanism by which the data is validated. This is a false positive based on pattern 2 (validation call chains).

Finding #3 — Category E — cross-function via set_chmod_dacl() — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 1448
Taint snippetdacloffset = le32_to_cpu(pntsd->dacloffset);
Tainted vardacl_ptr
Call siteline 1483 — passes dacl_ptr to set_chmod_dacl()
Call snippetrc = set_chmod_dacl(dacl_ptr, ndacl_ptr, owner_sid_ptr, group_sid_ptr,
Pointer derefdacl_ptr-> line 1287
Sink snippetif (!new_aces_set && (pntace->flags & INHERITED_ACE)) {
Possibly guardedno
Dismissed: The `dacloffset` is server-supplied. `dacl_ptr` is passed as `pdacl` to `set_chmod_dacl`. Before this call, `dacl_ptr` has been validated by both `dacl_offset_valid()` and `validate_dacl()`. The `validate_dacl()` function ensures that the entire DACL, including the number of ACEs (`pdacl->num_aces`) and the size/location of each ACE (`pntace->flags`, `pntace->sid`, `pntace->size`), is within the bounds of `secdesclen`. Any dereferences of `pdacl` or `pntace` within `set_chmod_dacl` are therefore operating on a pre-validated structure. If `validate_dacl` passes, it guarantees that all these accesses are in-bounds. This is a false positive based on pattern 5 (container-level validation).

Finding #4 — Category E — cross-function via replace_sids_and_copy_aces() — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 1448
Taint snippetdacloffset = le32_to_cpu(pntsd->dacloffset);
Tainted vardacl_ptr
Call siteline 1562 — passes dacl_ptr to replace_sids_and_copy_aces()
Call snippetrc = replace_sids_and_copy_aces(dacl_ptr, ndacl_ptr,
Pointer derefdacl_ptr-> line 1231
Sink snippetif (pnownersid && compare_sids(&pntace->sid, pownersid) == 0) {
Possibly guardedno
Dismissed: The `dacloffset` is server-supplied. `dacl_ptr` is passed as `pdacl` to `replace_sids_and_copy_aces`. Similar to finding #3, `dacl_ptr` has been fully validated by `dacl_offset_valid()` and `validate_dacl()` before this function is called. The `validate_dacl()` function ensures that the entire DACL structure, including the number of ACEs (`pdacl->num_aces`) and the size/location of each ACE (`pntace->sid`, `pntace->size`), is within the bounds of `secdesclen`. Therefore, accesses to `pntace->sid` and `pntace->size` within `replace_sids_and_copy_aces` are safe as they operate on a pre-validated structure. This is a false positive based on pattern 5 (container-level validation).

id_mode_to_cifs_acl() — fs/smb/client/cifsacl.c MIXED confidence=high

The function `id_mode_to_cifs_acl` retrieves a security descriptor from the server via `ops->get_acl`. It then performs calculations to determine a new security descriptor size (`nsecdesclen`), allocates a new buffer (`pnntsd`) with `kzalloc`, and populates it. The original `pntsd` and its fields (`dacloffset`, `num_aces`) are server-supplied and thus tainted. The function includes a `dacl_offset_valid` check and calls a `validate_dacl` helper. While the `validate_dacl` correctly performs bounds checks on the input structure, the calculation for the allocation size (`nsecdesclen`) for the *output* structure (specifically, the part based on `num_aces`) appears to underestimate the worst-case size for variable-length SIDs, leading to a potential undersized allocation and subsequent OOB write.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 1838
Taint snippetdacloffset = le32_to_cpu(pntsd->dacloffset);
Tainted vardacl_ptr
Pointer derefdacl_ptr->num_aces line 1859
Sink snippetle16_to_cpu(dacl_ptr->num_aces) * sizeof(struct smb_ace);
Possibly guardedno
Dismissed: `pntsd` is a server-supplied buffer obtained from `ops->get_acl()`. `dacloffset` is read from `pntsd->dacloffset` via `le32_to_cpu()` at line 1838, making it server-supplied. The derived pointer `dacl_ptr` is then validated by `dacl_offset_valid(secdesclen, dacloffset)` at line 1840 before the dereference at line 1859. The `dacl_offset_valid` function checks both lower and upper bounds: `dacloffset < sizeof(struct smb_ntsd)` ensures the offset is not within the header, and `dacloffset <= acl_len - sizeof(struct smb_acl)` ensures that `dacl_ptr` plus the minimum size of an `smb_acl` header (`sizeof(struct smb_acl)`) fits within the `secdesclen` buffer. These checks guarantee that `dacl_ptr` can be safely dereferenced to read at least `sizeof(struct smb_acl)`, which fully covers the access to `dacl_ptr->num_aces`. Counterexample test: Assume `secdesclen = 10`, `sizeof(struct smb_ntsd) = 4`, `sizeof(struct smb_acl) = 4`. If `dacloffset = 6`, `dacl_offset_valid(10, 6)` passes (`6 >= 4` and `6 <= 10 - 4`). `dacl_ptr` would be `pntsd + 6`. Accessing `dacl_ptr->num_aces` (which is within the first `sizeof(struct smb_acl)` bytes of `dacl_ptr`) would access `pntsd[6]` to `pntsd[9]`, which is within the bounds of `secdesclen=10`. Any `dacloffset` value that would cause an out-of-bounds read of `dacl_ptr->num_aces` would be caught by `dacl_offset_valid`.

Finding #2 — Category B — BUG oob_write

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 1858
Taint snippetnsecdesclen += sizeof(struct smb_acl) +
Tainted varnsecdesclen
Sinkkzalloc() line 1870 (arg 0, role=size)
Sink snippetpnntsd = kzalloc(nsecdesclen, GFP_KERNEL);
Possibly guardedno
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic from heap corruption (likely triggered by subsequent write into `pnntsd`)
Fix: The initial calculation of `nsecdesclen` at line 1859 (and similar lines for the 'chmod' path, e.g., 1830-1834) uses `sizeof(struct smb_ace)` as the base size for each ACE. However, `struct smb_ace` contains a variable-length `struct smb_sid`, meaning the actual size of an ACE (given by its internal `size` field) can be significantly larger than `sizeof(struct smb_ace)` (up to `SID_MAX_SUB_AUTHORITIES` sub-authorities). This makes the `nsecdesclen` calculation an *underestimate* of the required allocation size for the `pnntsd` buffer. The `kzalloc` at line 1870 is performed with this potentially underestimated size. Subsequently, the `build_sec_desc` function (which calls `replace_sids_and_copy_aces`) calculates the *actual* necessary size (`nsize`) for the new ACL but does not check it against the originally allocated `pnntsd` buffer size. If the actual required `nsize` exceeds the initially allocated `nsecdesclen`, `replace_sids_and_copy_aces` will write past the end of the `pnntsd` buffer, resulting in a heap out-of-bounds write. The fix should involve calculating a more accurate worst-case size for `nsecdesclen` that explicitly accounts for `SID_MAX_SUB_AUTHORITIES` when estimating the ACE sizes, or `build_sec_desc` should verify that `nsize` does not exceed the provided buffer size and reallocate if necessary. The SMT result 'value is unsigned at the sink' simply indicates that `nsecdesclen` is non-negative and does not address the undersized allocation problem. Counterexample test: Assume `sizeof(struct smb_ace)` is 20 bytes (e.g., base ACE + 1 sub-authority SID) and a maximum ACE size (with `SID_MAX_SUB_AUTHORITIES=15`) is 76 bytes. If the server provides an ACL with `dacl_ptr->num_aces = 10`, the estimated `nsecdesclen` (ignoring fixed headers) would add `10 * 20 = 200` bytes. If `build_sec_desc` then processes these 10 ACEs and each requires 76 bytes (due to SID translation), it would attempt to write `10 * 76 = 760` bytes into a buffer allocated for only 200 bytes, leading to an OOB write of 560 bytes.

Finding #3 — Category E — cross-function via validate_dacl() — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 1838
Taint snippetdacloffset = le32_to_cpu(pntsd->dacloffset);
Tainted vardacl_ptr
Call siteline 1847 — passes dacl_ptr to validate_dacl()
Call snippetrc = validate_dacl(dacl_ptr, (char *)pntsd + secdesclen);
Pointer derefdacl_ptr-> line 900
Sink snippetpace->sid.num_subauth == 0 ||
Possibly guardedno
Dismissed: This is a false positive. `dacl_ptr` is derived from server-supplied `pntsd` and `dacloffset`. Prior to calling `validate_dacl()`, `dacl_offset_valid()` is called in `id_mode_to_cifs_acl` (line 1840). This pre-check ensures that `dacl_ptr` (referred to as `pdacl` within `validate_dacl`) points within the bounds of `pntsd` and that at least `sizeof(struct smb_acl)` can be safely read. `validate_dacl` is explicitly a validation function, and its internal accesses, such as `pace->sid.num_subauth` at line 900, are part of the validation logic itself, not vulnerable sinks. The function contains multiple explicit bounds checks to ensure safe traversal of the ACL structure. Specifically, before accessing `pace->sid.num_subauth`, the check `if (end_of_dacl - acl_base < ace_hdr_size)` at line 899 verifies that `ace_hdr_size` (which covers the fixed portion of `smb_ace` including `sid.num_subauth`) fits within the remaining buffer. Any value of `dacloffset` or `dacl_ptr` that would lead to an OOB read at this point would be caught by one of the explicit checks within `validate_dacl`, causing it to return an error.

parse_dacl() — fs/smb/client/cifsacl.c FP confidence=high

The function `parse_dacl` is protected by an earlier call to `validate_dacl(pdacl, end_of_acl)`. The `validate_dacl()` function, as per its postcondition, performs a comprehensive validation of the entire DACL structure, including all ACE entries, their sizes, `num_subauth` fields, and `sub_auth` arrays. It ensures that all these fields are consistent and fit within the declared `end_of_acl` boundary. Therefore, subsequent traversals and accesses within `parse_dacl` (and its callees) using these previously validated lengths and offsets are safe.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 957
Taint snippetnum_aces = le16_to_cpu(pdacl->num_aces);
Tainted varnum_aces
Loopfor_loop line 965
Sink snippetfor (i = 0; i < num_aces; ++i) {
Possibly guardedyes (heuristic)
Dismissed: The `num_aces` variable, while server-supplied, is read from `pdacl->num_aces`. The `validate_dacl()` function (called at line 942) guarantees that this `num_aces` value is consistent with the actual buffer length and the sizes of all contained ACEs. Its postcondition explicitly states that 'every ACE entry (including its header, num_subauth field, and full sub-authority array) lies within the declared DACL bounds without exceeding end_of_acl'. This implies that `validate_dacl()` performed a full traversal using `num_aces` and individual ACE `size` fields, ensuring that all elements fit. Thus, the subsequent loop in `parse_dacl` using `num_aces` is protected by this prior, comprehensive validation. Counterexample: If `validate_dacl` returns 0, it means all ACEs, including their sizes and the count `num_aces`, are verified to fit within the buffer. No `num_aces` value can cause an OOB access if `validate_dacl` passes.

Finding #2 — Category F — cross-function via dump_ace() (read-only callee) — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 957
Taint snippetnum_aces = le16_to_cpu(pdacl->num_aces);
Tainted varppace
Call siteline 969 — passes ppace to dump_ace()
Call snippetdump_ace(ppace[i],
Loopfor_loop line 839
Sink snippetfor (i = 0; i < num_subauth; ++i) {
Possibly guardedno
Dismissed: The `num_aces` variable is server-supplied, and `ppace[i]` points into the server-supplied `pdacl` buffer. The `num_subauth` field, used as a loop bound in `dump_ace()`, is also server-supplied from `ppace[i]->sid.num_subauth`. The `validate_dacl()` function (called at line 942) guarantees that 'every ACE entry (including its header, num_subauth field, and full sub-authority array) lies within the declared DACL bounds without exceeding end_of_acl'. This means that the `num_subauth` field within each ACE has already been validated to ensure that the `sub_auth` array it describes fits within the ACE's boundaries and thus within the overall `end_of_acl`. `dump_ace()` also performs internal checks (`if (le16_to_cpu(pace->size) < 16)` and `if (end_of_acl < (char *)pace + le16_to_cpu(pace->size))`) which, while not directly guarding `num_subauth` loop, contribute to ensuring the ACE's overall integrity. The 'BB add length check' comment in `dump_ace` may refer to a redundant check if `validate_dacl` already covers it. Counterexample: If `validate_dacl` passes, then `num_subauth` for any given ACE is guaranteed to be a value such that accessing `pace->sid.sub_auth[i]` within the `dump_ace` loop will not go out of bounds of the ACE, and thus not the overall ACL buffer. No counterexample found.

Finding #3 — Category F — cross-function via compare_sids() (read-only callee) — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 957
Taint snippetnum_aces = le16_to_cpu(pdacl->num_aces);
Tainted varppace
Call siteline 974 — passes ppace to compare_sids()
Call snippet(compare_sids(&(ppace[i]->sid),
Loopfor_loop line 209
Sink snippetfor (i = 0; i < num_subauth; ++i) {
Possibly guardedyes (heuristic)
Dismissed: Similar to finding #2, `num_aces` is server-supplied, and `ppace[i]` points to server-supplied data. The `num_subauth` field, used as a loop bound in `compare_sids()`, is extracted from `ctsid->num_subauth` (which corresponds to `ppace[i]->sid.num_subauth`). The `validate_dacl()` function, called prior to this, guarantees that 'every ACE entry (including its header, num_subauth field, and full sub-authority array) lies within the declared DACL bounds without exceeding end_of_acl'. This validation ensures that `ctsid->num_subauth` is a safe value and that accesses to `ctsid->sub_auth[i]` within the loop in `compare_sids` will remain in bounds. `compare_sids` also has a null check for its arguments. Counterexample: If `validate_dacl` passes, then `num_subauth` for any SID passed to `compare_sids` is guaranteed to be a value such that accessing `ctsid->sub_auth[i]` will not go out of bounds of the SID structure, and thus not the overall ACL buffer. No counterexample found.

replace_sids_and_copy_aces() — fs/smb/client/cifsacl.c FP confidence=high

The function `replace_sids_and_copy_aces` is called from `build_sec_desc`. In `build_sec_desc`, a crucial validation step `rc = validate_dacl(dacl_ptr, end_of_acl);` is performed on the `dacl_ptr` (which is passed as `pdacl` to the target function) and the overall security descriptor buffer boundary `end_of_acl`. Functions named `validate_dacl` in kernel code are typically implemented to perform a full traversal of the ACL structure, ensuring that `num_aces` is reasonable, and that all ACEs, including their `size` fields, fit within the provided buffer. Assuming `validate_dacl` adheres to this common pattern, it would establish the necessary bounds for `pdacl->num_aces` and subsequent ACE accesses. Therefore, the loop iteration count and pointer advancements are implicitly protected by this prior validation.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 1221
Taint snippetsrc_num_aces = le16_to_cpu(pdacl->num_aces);
Tainted varsrc_num_aces
Loopfor_loop line 1227
Sink snippetfor (i = 0; i < src_num_aces; ++i) {
Possibly guardedno
Dismissed: The `src_num_aces` variable is derived from `pdacl->num_aces`, which comes from a server-supplied buffer. However, the caller `build_sec_desc` performs a validation step via `validate_dacl(dacl_ptr, end_of_acl)`. `dacl_ptr` is the same pointer as `pdacl`. A function named `validate_dacl` (especially when given the buffer end `end_of_acl`) is expected to iterate through all ACEs in the DACL, verifying that `pdacl->num_aces` is a reasonable count and that the sum of all ACE `size` fields (accessed as `le16_to_cpu(pntace->size)` in the flagged loop) does not exceed the buffer boundary (`end_of_acl`). If `validate_dacl` establishes this postcondition, then the loop condition `i < src_num_aces` and the pointer arithmetic (`acl_base + size`) are implicitly bounded, preventing OOB reads. Counterexample test: If `secdesclen = 20`, `dacloffset = 0`, and `pdacl->num_aces = 0xFFFF`, a correctly implemented `validate_dacl` would check if `0xFFFF` ACEs (even with minimal `sizeof(struct smb_ace)`) could fit into a 20-byte buffer. It would immediately return an error, preventing `replace_sids_and_copy_aces` from being called with an unbounded `src_num_aces` that could lead to OOB reads from `pntace->sid` or `pntace->size`. Thus, no counterexample is reachable if `validate_dacl` performs its expected role.

set_chmod_dacl() — fs/smb/client/cifsacl.c FP confidence=high

The `set_chmod_dacl` function is a static helper called from `build_sec_desc`. The `pdacl` argument to `set_chmod_dacl` (which is `dacl_ptr` in the caller) is thoroughly validated by a call to `validate_dacl(dacl_ptr, end_of_acl)` in `build_sec_desc` before `set_chmod_dacl` is invoked. The `validate_dacl` function (as typically implemented in cifsacl.c, and based on its name and arguments) performs a full traversal of the SMB ACL structure, checking `pdacl->num_aces` against the total size and ensuring that each ACE's size field (`pntace->size`) is consistent and does not extend beyond the provided buffer (`end_of_acl`). This prior, full-traversal validation establishes a strong precondition for `set_chmod_dacl`, making subsequent accesses using the same traversal logic safe.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 1281
Taint snippetsrc_num_aces = le16_to_cpu(pdacl->num_aces);
Tainted varsrc_num_aces
Loopfor_loop line 1284
Sink snippetfor (i = 0; i < src_num_aces; ++i) {
Possibly guardedno
Dismissed: The taint source `pdacl->num_aces` is indeed server-supplied, as `pdacl` is derived from `pntsd` which is a server-supplied security descriptor. However, the `build_sec_desc` function (the caller) invokes `validate_dacl(dacl_ptr, end_of_acl)` on the `dacl_ptr` (which is `pdacl` in `set_chmod_dacl`) before calling `set_chmod_dacl`. The `validate_dacl` function performs a full traversal of the DACL structure, iterating `pdacl->num_aces` times and checking that the accumulated `size` (from `sizeof(struct smb_acl)` plus sum of `pntace->size` for each ACE) does not exceed `end_of_acl`. This means any `src_num_aces` value that would lead to an OOB read in `set_chmod_dacl` by making `size` exceed the actual buffer boundary would have been caught by `validate_dacl` earlier, causing `build_sec_desc` to return an error. Thus, the loop's iteration count is implicitly bounded by the earlier validation. Counterexample test: If `secdesclen`=100 and `pdacl->num_aces`=10, but the cumulative size of `struct smb_acl` and the first few ACEs exceeds 100, `validate_dacl` would detect this OOB condition and return an error. The `set_chmod_dacl` function would not be called, or would operate on an already-validated buffer segment.

validate_dacl() — fs/smb/client/cifsacl.c FP confidence=high

The `validate_dacl` function performs a full-traversal validation of the Access Control List (ACL). While `num_aces` (number of Access Control Entries) is server-supplied and controls the loop iteration count, the loop body includes robust per-iteration bounds checks. The pointer `acl_base` is advanced by `ace_size`, which is itself validated against the remaining buffer size (`end_of_dacl - acl_base`) in each iteration. This ensures that no out-of-bounds access occurs even if `num_aces` is maliciously large or `ace_size` claims an invalid length. The pre-loop check at line 881 provides an additional coarse-grained sanity check on `num_aces` based on `min_ace_size`, but the per-iteration checks are the primary safeguard.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 874
Taint snippetnum_aces = le16_to_cpu(pdacl->num_aces);
Tainted varnum_aces
Loopfor_loop line 890
Sink snippetfor (i = 0; i < num_aces; ++i) {
Possibly guardedyes (heuristic)
Dismissed: The `num_aces` variable is derived from `pdacl->num_aces`, which is server-supplied. It controls the number of iterations in the `for` loop at line 890. However, the loop body performs per-iteration bounds checks: 1. `dacl_size` (claimed total DACL size) is validated against the overall buffer (`end_of_acl`) at lines 868-871. `end_of_dacl` is then derived from this validated `dacl_size`. 2. Before the loop, a sanity check at lines 881-884 ensures `num_aces` isn't excessively large for the available `dacl_size` when considering `min_ace_size`. 3. Inside the loop, at each iteration, `acl_base` is advanced by the `ace_size` of the *previous* ACE. The `ace_size` for the *current* ACE (from `pace->size` or calculated based on `num_subauth`) is validated to fit within the remaining `dacl_size` via `end_of_dacl - acl_base < ace_size` (lines 899, 907, 914) before any dereference at `pace`. This full-traversal validation pattern, where each element's size is checked against the remaining buffer before the pointer is advanced, makes the iteration count safe. No specific counterexample with `num_aces` causing OOB is possible because of these internal checks that terminate the loop early on invalid ACE sizes or insufficient remaining buffer space. This is a false positive as per pattern 5b (full-traversal validation).

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

The CIFSFindFirst function sends a SMB_COM_TRANSACTION2_FIND_FIRST request and parses the server's TRANS2_FIND_FIRST response. The overall response buffer is validated by SendReceive and then by validate_t2. However, the internal structure T2_FFIRST_RSP_PARMS, which is read using the server-supplied ParameterOffset, is not adequately checked against the server-supplied ParameterCount. While validate_t2 likely ensures ParameterOffset + ParameterCount does not exceed the total received buffer length, it usually does not guarantee that ParameterCount itself is large enough to encompass the entire fixed-size T2_FFIRST_RSP_PARMS struct (which is 10 bytes). This can lead to out-of-bounds reads when accessing fields of T2_FFIRST_RSP_PARMS if ParameterCount is smaller than 10 bytes.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4539
Taint snippetparms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol +
Tainted varparms
Pointer derefparms->EndofSearch line 4541
Sink snippetpsrch_inf->endOfSearch = !!parms->EndofSearch;
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (e.g., KASAN slab-out-of-bounds read) if the OOB access attempts to read unmapped memory. Otherwise, potential information disclosure (reading arbitrary kernel memory) or data corruption in *pnetfid if it's subsequently used based on the corrupted value.
Fix: Add a check after validate_t2 and before dereferencing 'parms' to ensure the server-supplied parameter length is sufficient for the expected structure. For example, insert the following check: ```c if (le16_to_cpu(pSMBr->t2.ParameterCount) < sizeof(T2_FFIRST_RSP_PARMS)) { cifs_dbg(VFS, "SMB parameter block too short (%u < %zu)", le16_to_cpu(pSMBr->t2.ParameterCount), sizeof(T2_FFIRST_RSP_PARMS)); rc = -EINVAL; cifs_buf_release(pSMB); return rc; } ``` Ideally, validate_t2 should be enhanced to take the expected minimum size of the parameter block for specific TRANSACTION2 subcommands.
CVE pattern: SMB transaction response parsing OOB read due to insufficient parameter length compared to expected struct size

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

The function processes a server response using offsets and counts extracted from the response header. While a general transaction validation (`validate_t2`) is called, it is not guaranteed to enforce that the specific parameter block parsed by `T2_FNEXT_RSP_PARMS` actually fits within the declared ParameterCount from the SMB header, leading to potential out-of-bounds reads if the server sends a maliciously crafted short parameter count.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4648
Taint snippetresponse_data = (char *)&pSMBr->hdr.Protocol +
Tainted varparms
Pointer derefparms->EndofSearch line 4662
Sink snippetpsrch_inf->endOfSearch = !!parms->EndofSearch;
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or KASAN: slab-out-of-bounds Read if the server-supplied ParameterCount is less than sizeof(T2_FNEXT_RSP_PARMS), leading to attempts to read past the allocated parameter buffer.
Fix: After `validate_t2` returns successfully, or within `validate_t2`, add a check to ensure `le16_to_cpu(pSMBr->t2.ParameterCount)` is greater than or equal to `sizeof(T2_FNEXT_RSP_PARMS)` before casting to `T2_FNEXT_RSP_PARMS` and accessing its members. For example: ```c if (le16_to_cpu(pSMBr->t2.ParameterCount) < sizeof(T2_FNEXT_RSP_PARMS)) { cifs_dbg(VFS, "T2_FNEXT_RSP_PARMS too small for response\n"); cifs_buf_release(pSMB); return -EINVAL; } parms = (T2_FNEXT_RSP_PARMS *)response_data; ```
CVE pattern: CVE-XXXX-XXXX style ParameterOffset OOB read

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

The function parses an SMB TRANS2_QUERY_FILE_INFORMATION response. It extracts DataOffset and DataCount from the server-supplied response. While DataCount is validated to be 16 (matching the expected struct size for `file_chattr_info`), DataOffset is not sufficiently validated against the total received buffer size. This allows a malicious server to provide a DataOffset that causes an out-of-bounds read when accessing fields of the `file_chattr_info` struct.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 3726
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varpfinfo
Pointer derefpfinfo->mode line 3738
Sink snippet*pExtAttrBits = le64_to_cpu(pfinfo->mode);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (e.g., page fault on invalid address), KASAN report (slab-out-of-bounds read), or potential information disclosure if the OOB read accesses sensitive kernel memory.
Fix: Add a bounds check to ensure the calculated end of the data payload does not exceed the received buffer. Specifically, before line 3737, add a check like: ```c unsigned int payload_start_offset = (char *)&pSMBr->hdr.Protocol - (char *)pSMBr; if (payload_start_offset + data_offset + count > bytes_returned || data_offset < MIN_VALID_DATA_OFFSET) { cifs_dbg(FYI, "Data offset or count out of bounds in GetExtAttr: off=%u, cnt=%u, total=%d\n", data_offset, count, bytes_returned); rc = smb_EIO2(smb_eio_trace_getextattr_data_oob, data_offset, count); goto GetExtAttrOut; } ``` Where `MIN_VALID_DATA_OFFSET` would typically be `offsetof(struct smb_t2_qfi_rsp, ...)` to ensure the data block does not overlap with the fixed header fields.
CVE pattern: SMB response parsing OOB read (similar to CVE-XXXX-YYYY due to unvalidated offset/length)

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

The function receives a server response containing file information. It extracts a data offset and a data count from the response. While it checks if the data count is at least the size of the expected structure, it fails to validate that the combination of the server-supplied data offset and data count fits within the actual received buffer length. This allows a malicious server to provide an out-of-bounds offset, leading to an OOB read.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4793
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varpfinfo
Pointer derefpfinfo->UniqueId line 4805
Sink snippet*inode_number = le64_to_cpu(pfinfo->UniqueId);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic due to out-of-bounds read, KASAN report, information disclosure through reading arbitrary kernel memory
Fix: Add a bounds check to ensure that the calculated pointer `pfinfo` and the size of the data it points to (`count`) remain within the received buffer. The calculation `(char *) &pSMBr->hdr.Protocol + data_offset + count` must be less than or equal to `(char *)pSMBr + bytes_returned`. A check like `if (offsetof(struct smb_hdr, Protocol) + data_offset + count > bytes_returned)` should be added after extracting `data_offset` and `count` and before `pfinfo` is dereferenced.
CVE pattern: SMB DataOffset OOB

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

The CIFSPOSIXCreate function parses a server-supplied TRANSACTION2_SPI_RSP message. It extracts a DataOffset field from the response header and uses it to locate a sub-structure (OPEN_PSX_RSP) and then potentially further data (FILE_UNIX_BASIC_INFO). The existing bounds checks only validate the total ByteCount of the SMB payload against the expected size of the target structure(s). They completely fail to account for the server-supplied DataOffset. This means a malicious server can provide a large DataOffset and a small ByteCount (still exceeding the target structure size), causing derived pointers to point past the end of the received buffer, leading to OOB reads.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 1138
Taint snippetpsx_rsp = (OPEN_PSX_RSP *)
Tainted varpsx_rsp
Pointer derefpsx_rsp->OplockFlags line 1141
Sink snippet*pOplock = le16_to_cpu(psx_rsp->OplockFlags);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap corruption, data corruption, or information disclosure via OOB read.
Fix: Before line 1139, after `psx_rsp` is calculated, add a check to ensure `DataOffset` is within the bounds of the received buffer and the `OPEN_PSX_RSP` structure fits. The check should be: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); /* Additional validation could check against min offset if data_offset cannot be less than a certain value */ if (data_offset + sizeof(OPEN_PSX_RSP) > bytes_returned) { cifs_dbg(VFS, "SMB POSIX create response: DataOffset %u + OPEN_PSX_RSP size %zu exceeds buffer size %d\n", data_offset, sizeof(OPEN_PSX_RSP), bytes_returned); rc = -EINVAL; goto psx_create_err; } ``` This check must replace or augment the check at line 1131, as the current `get_bcc` comparison is insufficient.
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 1138
Taint snippetpsx_rsp = (OPEN_PSX_RSP *)
Tainted varpsx_rsp
Sinkmemcpy() line 1159 (arg 1, role=pointer)
Sink snippetmemcpy(pRetData,
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap corruption, data corruption, or information disclosure via OOB read.
Fix: The fix suggested for finding #1, ensuring `DataOffset + sizeof(OPEN_PSX_RSP) <= bytes_returned`, makes the `psx_rsp` pointer itself safe. For the `memcpy` sink, an additional check is needed before line 1159 (or augment the check at 1153) to ensure the `FILE_UNIX_BASIC_INFO` structure also fits: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); /* Assuming previous check for OPEN_PSX_RSP passed */ if (data_offset + sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO) > bytes_returned) { cifs_dbg(VFS, "SMB POSIX create response: DataOffset %u + OPEN_PSX_RSP size %zu + FILE_UNIX_BASIC_INFO size %zu exceeds buffer size %d\n", data_offset, sizeof(OPEN_PSX_RSP), sizeof(FILE_UNIX_BASIC_INFO), bytes_returned); rc = -EINVAL; goto psx_create_err; } ``` This check must replace or augment the check at line 1153, as the current `get_bcc` comparison is insufficient.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The function processes a server response (`pSMBr`) which contains `DataOffset` and `DataCount` fields. These fields are used to derive a pointer `parm_data` into the response buffer. While some checks exist (`get_bcc` and `data_count` validation), they do not sufficiently validate the combination of `data_offset` and the size of the target structure (`struct cifs_posix_lock`) against the actual received buffer length (`bytes_returned`). This omission allows a malicious server to craft a response where `data_offset` points beyond the received buffer, leading to an out-of-bounds read when `parm_data` is dereferenced.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 2392
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varparm_data
Pointer derefparm_data->lock_type line 2401
Sink snippetif (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or crash due to out-of-bounds read when processing a crafted SMB POSIX Lock response. Potential information disclosure if the OOB read fetches sensitive kernel memory.
Fix: Add an explicit bounds check after extracting `data_offset` and before deriving `parm_data`. The check should ensure that the calculated end of the `cifs_posix_lock` structure does not exceed the actual received buffer length. Specifically, `offsetof(struct smb_hdr, Protocol) + data_offset + sizeof(struct cifs_posix_lock)` must be less than or equal to `bytes_returned`. Example fix around line 2398: ```c // ... existing checks ... if (data_count < sizeof(struct cifs_posix_lock)) { rc = smb_EIO2(smb_eio_trace_lock_data_too_small, data_count, sizeof(struct cifs_posix_lock)); goto plk_err_exit; } // New bounds check for data_offset and structure size if ((unsigned long)offsetof(struct smb_hdr, Protocol) + data_offset + sizeof(struct cifs_posix_lock) > bytes_returned) { rc = smb_EIO2(smb_eio_trace_lock_offset_too_large, data_offset, bytes_returned); goto plk_err_exit; } parm_data = (struct cifs_posix_lock *) ((char *)&pSMBr->hdr.Protocol + data_offset); // ... rest of the code ... ```
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The function processes a server-supplied list of Extended Attributes (EAs). Initial validation of the overall `data_offset` and the total `list_len` against the received SMB buffer size is present. However, the internal loop that iterates through individual `fea` (File Extended Attribute) entries has critical flaws: 1. **Insufficient per-entry bounds checks**: The code fails to ensure that the fixed-size header of each `fea` entry (8 bytes, containing `next_entry_offset`, `flags`, `name_len`, `value_len`) is entirely within bounds before attempting to read `name_len` and `value_len`. The check `list_len < 0` after `list_len -= 4` only guarantees 4 bytes, not the required 8. 2. **Pointer misalignment**: The `temp_ptr` variable, which is intended to traverse the variable-length parts of the `fea` entry (name and value), is consistently misaligned by 4 bytes. It is advanced by `4` for `next_entry_offset`, but then used as the base for `memcmp` or `memcpy` of the name, which actually starts 4 bytes later in the `fea` structure. A similar misalignment exists when copying the value. This leads to reading incorrect data, and potentially OOB reads if the `name_len` or `value_len` fields are large (especially if they were themselves read OOB due to issue #1).

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6240
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varea_response_data
Pointer derefea_response_data->list_len line 6261
Sink snippetlist_len = le32_to_cpu(ea_response_data->list_len);
Possibly guardedno
Dismissed: The taint source `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` is server-supplied, as `pSMBr` is the response buffer. The pointer `ea_response_data` is derived from `data_offset`. Before `ea_response_data->list_len` is dereferenced, the code performs two crucial checks: 1. `if (data_offset < sizeof(*pSMBr))` (line 6241): Ensures `data_offset` is not within the fixed `pSMBr` header. 2. `else if ((size_t)data_offset + sizeof(struct fealist) > (size_t)bytes_returned)` (line 6248): Ensures that at least a `struct fealist` (the header for the EA list) fits within the total `bytes_returned` from `data_offset`. If `sizeof(struct fealist)` bytes are available, then `ea_response_data->list_len` (a field within `struct fealist`) can be safely read. These checks are sufficient. Counterexample test: If `data_offset` is `bytes_returned - sizeof(struct fealist) + 1`, it would be caught by line 6248. If `data_offset` is `sizeof(*pSMBr) - 1`, it would be caught by line 6241. No counterexample found for OOB read of `ea_response_data->list_len`.

Finding #2 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6240
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varea_response_data
Pointer derefea_response_data->list line 6283
Sink snippettemp_fea = &ea_response_data->list;
Possibly guardedyes (heuristic)
Dismissed: Similar to finding #1, the pointer `ea_response_data` is derived from a server-supplied `data_offset` and validated by checks at lines 6241 and 6248. `ea_response_data->list` is a field within `struct fealist`. If `sizeof(struct fealist)` bytes are guaranteed to be available from `data_offset`, then accessing its `list` member to initialize `temp_fea` is safe. No counterexample found.

Finding #3 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele32_to_cpu() line 6261
Taint snippetlist_len = le32_to_cpu(ea_response_data->list_len);
Tainted varlist_len
Loopwhile_loop line 6285
Sink snippetwhile (list_len > 0) {
Possibly guardedyes (heuristic)
Dismissed: The initial `list_len` is derived from `ea_response_data->list_len` (server-supplied). This total `list_len` is validated against the end of the SMB buffer at line 6273: `if ((char *)ea_response_data + list_len > end_of_smb)`. This ensures that the *entire* EA list, as declared by the server, fits within the received SMB data. Subsequent checks within the loop, `if (list_len < 0)` at lines 6292 and 6301, ensure that each sub-component (the `next_entry_offset` and then the combined `name_len + 1 + value_len`) does not cause the total `list_len` to underflow. While there are issues with the *internal* parsing of `fea` entries (see findings #4 onwards), the overall iteration count based on `list_len` is bounded by this initial check and subsequent decrements. No counterexample found for unbounded iteration *itself*.

Finding #4 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6240
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted vartemp_fea
Pointer dereftemp_fea->name_len line 6298
Sink snippetname_len = temp_fea->name_len;
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or arbitrary data disclosure
Fix: Before reading `temp_fea->name_len` and `temp_fea->value_len`, add a check to ensure at least `sizeof(struct fea_fixed_header)` bytes (e.g., 8 bytes) are available from `temp_fea` within the remaining `list_len`. The `temp_ptr` and `temp_fea` usage and advancement logic also needs to be corrected throughout the loop (see overall notes and fix for `temp_ptr` in finding #5).
CVE pattern: SMB response parsing OOB read

Finding #5 — Category B — BUG oob_read

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 6298
Taint snippetname_len = temp_fea->name_len;
Tainted varname_len
Sinkmemcmp() line 6309 (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)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or arbitrary data disclosure (reading uninitialized kernel memory or other network buffer content)
Fix: Correct the `temp_ptr` advancement logic. Before `memcmp(ea_name, temp_ptr, name_len)`, `temp_ptr` must be set to point to the actual start of the `name` data, which is `(char *)temp_fea + 8`. Also, `name_len` must be validated against `list_len` (or against `end_of_smb - temp_ptr`) *before* the `memcmp`. The current `list_len < 0` check is insufficient as it applies to the total remaining list length, not the bytes available at `temp_ptr` for `name_len`.
CVE pattern: SMB response parsing OOB read

Finding #6 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 6240
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted vartemp_ptr
Sinkmemcmp() line 6309 (arg 1, role=pointer)
Sink snippetmemcmp(ea_name, temp_ptr, name_len) == 0) {
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic or arbitrary data disclosure
Fix: As per finding #5, correct the `temp_ptr` value before calling `memcmp`.
CVE pattern: SMB response parsing OOB read

Finding #7 — Category B — BUG oob_read

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 6299
Taint snippetvalue_len = le16_to_cpu(temp_fea->value_len);
Tainted varvalue_len
Sinkmemcpy() line 6318 (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)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or arbitrary data disclosure
Fix: Correct the `temp_ptr` advancement logic. Before `memcpy(EAData, temp_ptr, value_len)`, `temp_ptr` must be set to point to the actual start of the `value` data, which is `(char *)temp_fea + 8 + name_len + 1`. `value_len` must also be validated against `list_len` (or against `end_of_smb - temp_ptr`) *before* the `memcpy` for the source buffer, in addition to the existing destination `buf_size` check.
CVE pattern: SMB response parsing OOB read

Finding #8 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 6240
Taint snippetdata_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted vartemp_ptr
Sinkmemcpy() line 6318 (arg 1, role=pointer)
Sink snippetmemcpy(EAData, temp_ptr, value_len);
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic or arbitrary data disclosure
Fix: As per finding #7, correct the `temp_ptr` value before calling `memcpy`.
CVE pattern: SMB response parsing OOB read

Finding #9 — Category B — BUG oob_read

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 6298
Taint snippetname_len = temp_fea->name_len;
Tainted varname_len
Sinkmemcpy() line 6327 (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)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic or arbitrary data disclosure
Fix: Correct the `temp_ptr` advancement logic. Before `memcpy(EAData, temp_ptr, name_len)` in the `else` branch, `temp_ptr` must be set to point to the actual start of the `name` data, which is `(char *)temp_fea + 8`. `name_len` must also be validated against `list_len` (or `end_of_smb - temp_ptr`) *before* the `memcpy` for the source buffer, in addition to existing destination `buf_size` checks.
CVE pattern: SMB response parsing OOB read

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

The function processes a server response for querying file system attributes. A key field `DataOffset` is extracted from the server-supplied message and used to calculate a pointer for a memcpy operation. The existing checks on `get_bcc` are insufficient to guarantee that `DataOffset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)` does not exceed the actual length of the received response buffer. This is a classic SMB/CIFS `DataOffset` OOB vulnerability pattern.

Finding #1 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 5170
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Sinkmemcpy() line 5175 (arg 1, role=pointer)
Sink snippetmemcpy(&tcon->fsAttrInfo, response_data,
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap corruption, BUG: KASAN: slab-out-of-bounds read, information disclosure.
Fix: Add a bounds check to ensure `data_offset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)` does not exceed `bytes_returned` (the actual size of the received SMB response PDU). The check should be placed before the `memcpy` operation. ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); if (data_offset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) > bytes_returned) { cifs_dbg(VFS, "QFSAttributeInfo: DataOffset %u plus size %zu exceeds buffer length %d\n", data_offset, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO), bytes_returned); rc = -EINVAL; // Or smb_EIO2 } else { response_data = (FILE_SYSTEM_ATTRIBUTE_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); memcpy(&tcon->fsAttrInfo, response_data, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)); } ```
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The function reads a server-supplied DataOffset field from a TRANSACTION2 response and uses it to calculate a pointer for a `memcpy` operation. While `SendReceive` ensures the overall `bytes_returned` does not exceed the buffer capacity, and there's a check on the server-advertised `ByteCount` (`get_bcc`), neither of these sufficiently guards against a malicious or malformed `DataOffset` causing an Out-of-Bounds Read. The `memcpy` can read past the end of the actual received buffer.

Finding #1 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 5245
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Sinkmemcpy() line 5250 (arg 1, role=pointer)
Sink snippetmemcpy(&tcon->fsDevInfo, response_data,
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic from heap corruption (e.g., KASAN: slab-out-of-bounds read)
Fix: An explicit bounds check is required before `memcpy` to ensure `data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO)` does not exceed the actual received data length. The base for `data_offset` is `&pSMBr->hdr.Protocol`. The total number of received bytes is `bytes_returned`. The offset of `pSMBr->hdr.Protocol` from the start of the `pSMBr` buffer is `offsetof(struct smb_hdr, Protocol)`. Thus, the sum of this offset, `data_offset`, and `sizeof(FILE_SYSTEM_DEVICE_INFO)` must not exceed `bytes_returned`. Proposed fix: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); /* Ensure DataOffset + struct size does not exceed the actual received buffer length */ if (offsetof(struct smb_hdr, Protocol) + data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > bytes_returned) { cifs_dbg(VFS, "SMB: DataOffset (0x%x) + len (0x%zx) exceeds bytes_returned (0x%x)\n", data_offset, sizeof(FILE_SYSTEM_DEVICE_INFO), bytes_returned); rc = -EINVAL; /* or -EREMOTEIO, appropriate error handling */ } else { response_data = (FILE_SYSTEM_DEVICE_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); memcpy(&tcon->fsDevInfo, response_data, sizeof(FILE_SYSTEM_DEVICE_INFO)); } ``` Counterexample: Assume `sizeof(FILE_SYSTEM_DEVICE_INFO)` = 16 bytes and `offsetof(struct smb_hdr, Protocol)` = 32 bytes. If the server sends `bytes_returned = 40` (actual received length) and sets `pSMBr->t2.DataOffset` to a value that, after `le16_to_cpu`, results in `data_offset = 10`, the check `get_bcc() < sizeof(FILE_SYSTEM_DEVICE_INFO)` may pass (e.g., if `get_bcc()` is 100). However, the `memcpy` would attempt to read from `pSMBr + 32 + 10 = pSMBr + 42` for 16 bytes. Since `bytes_returned` is only 40, this is an OOB read accessing `pSMBr[42...57]`, exceeding the allocated buffer `pSMBr[0...39]`. This specifically violates the condition `32 + 10 + 16 <= 40` (i.e., `58 <= 40`), confirming an OOB read.
CVE pattern: SMB_COM_TRANSACTION2_DataOffset OOB Read

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

The CIFSSMBQFSInfo function receives a server response and parses it. The DataOffset field, read from the server response, is used to derive a pointer into the received buffer. The existing validation (`get_bcc`) checks for a minimum total data length, but does not ensure that the DataOffset itself, when combined with the size of the expected structure (`FILE_SYSTEM_SIZE_INFO`), remains within the bounds of the actually received network buffer. This can lead to an out-of-bounds read if the server-supplied DataOffset is maliciously crafted or simply too large.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 5079
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Pointer derefresponse_data->BytesPerSector line 5086
Sink snippetle32_to_cpu(response_data->BytesPerSector) *
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from out-of-bounds read, or information disclosure/corruption if the read occurs within mapped but unintended kernel memory.
Fix: Add explicit bounds checks for `data_offset` to ensure it points within the received buffer and allows for the full `FILE_SYSTEM_SIZE_INFO` structure to be read. Specifically, before line 5081, add a check similar to: ```c __u16 proto_offset = offsetof(struct smb_hdr, Protocol); if (proto_offset + data_offset + sizeof(FILE_SYSTEM_SIZE_INFO) > bytes_returned) { cifs_dbg(VFS, "QFSInfo: data offset %d or size %zu too large for bytes_returned %d\n", data_offset, sizeof(FILE_SYSTEM_SIZE_INFO), bytes_returned); rc = -EINVAL; goto out; } // Optionally, add a lower bound check for data_offset // For instance, data_offset should at least be past the fixed part of the T2 response header if (proto_offset + data_offset < SOME_MIN_VALID_DATA_OFFSET_FROM_PROTO) { cifs_dbg(VFS, "QFSInfo: data offset %d too small\n", data_offset); rc = -EINVAL; goto out; } ```
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The function `CIFSSMBQFSPosixInfo` parses a server-supplied TRANSACTION2 response containing `FILE_SYSTEM_POSIX_INFO` data. The location of this data is indicated by `pSMBr->t2.DataOffset`, which is directly used to derive `response_data`. While `validate_t2` is called, its source code is not provided, and standard TRANSACTION2 validation typically verifies consistency of offsets and counts within the Transaction2 header, but not necessarily that a specific data structure of size `sizeof(FILE_SYSTEM_POSIX_INFO)` fits within the bounds implied by `DataOffset` and `DataCount`, or the overall message length. The absence of an explicit check in `CIFSSMBQFSPosixInfo` to ensure `data_offset + sizeof(FILE_SYSTEM_POSIX_INFO)` is within the received `bytes_returned` from `SendReceive` constitutes a clear vulnerability.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 5466
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Pointer derefresponse_data->BlockSize line 5472
Sink snippetle32_to_cpu(response_data->BlockSize);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic from heap corruption, BUG: KASAN: slab-out-of-bounds Read
Fix: Add a bounds check after `data_offset` is extracted and before `response_data` is used. Specifically, ensure that `data_offset + sizeof(FILE_SYSTEM_POSIX_INFO)` does not exceed the total `bytes_returned` adjusted for the SMB header's `Protocol` field offset. A more robust fix would extend `validate_t2` or introduce a new helper to perform this specific validation: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); unsigned int min_struct_size = sizeof(FILE_SYSTEM_POSIX_INFO); unsigned int base_offset = offsetof(struct smb_hdr, Protocol); unsigned int max_len_from_base = bytes_returned - base_offset; if (data_offset + min_struct_size > max_len_from_base) { cifs_dbg(VFS, "malformed QFSPosixInfo response: data_offset %u or data size %u too large for buffer (max %u)\n", data_offset, min_struct_size, max_len_from_base); rc = -EINVAL; goto out; // Assuming 'out' label exists for cleanup and return. } response_data = (FILE_SYSTEM_POSIX_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset); ```
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The function `CIFSSMBQFSUnixInfo` processes a server response for UNIX file system information. The `DataOffset` field within this response is used to calculate the starting address of the `FILE_SYSTEM_UNIX_INFO` structure. While the overall buffer `pSMBr` is guaranteed to be within `CIFSMaxBufSize` by `SendReceive`, there's no specific validation that the server-provided `DataOffset`, when combined with the size of `FILE_SYSTEM_UNIX_INFO`, stays within the *actual received length* (`bytes_returned`). This allows a malicious server to craft a response with a large `DataOffset` that causes an out-of-bounds read during the `memcpy` operation.

Finding #1 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 5317
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Sinkmemcpy() line 5322 (arg 1, role=pointer)
Sink snippetmemcpy(&tcon->fsUnixInfo, response_data,
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel panic/KASAN warning due to out-of-bounds read.
Fix: Add a bounds check to ensure the server-supplied `data_offset` points within the received data. Specifically, before the `memcpy`, verify that `(char *)&pSMBr->hdr.Protocol + data_offset + sizeof(FILE_SYSTEM_UNIX_INFO)` does not exceed `(char *)pSMBr + bytes_returned`. If it does, return an error.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The function `CIFSSMBRead` receives a server response into `rsp_iov.iov_base`, which is cast to `READ_RSP *pSMBr`. The fields `DataLengthHigh`, `DataLength`, and `DataOffset` are extracted from this server-supplied structure. The code includes a comprehensive validation block (lines 1738-1753) that checks several conditions before the `memcpy` operation. These checks cover both the lower and upper bounds of `data_offset` and the overall data block's fit within the received buffer `rsp_iov.iov_len`, as well as sanity checks against `CIFSMaxBufSize` and the requested `count`. If any validation fails, an error is returned via `smb_EIO2`, and the `memcpy` operation is skipped.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 1731
Taint snippetunsigned int data_length = le16_to_cpu(pSMBr->DataLengthHigh);
Tainted vardata_length
Sinkmemcpy() line 1760 (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 constructed from server-supplied `pSMBr->DataLengthHigh` and `pSMBr->DataLength`. It is used as the size argument to `memcpy`. The code includes multiple bounds checks: 1. Line 1738: `data_length > CIFSMaxBufSize` ensures `data_length` does not exceed a kernel-defined maximum buffer size. 2. Line 1739: `data_length > count` ensures the server does not claim to send more data than the client requested (`count` is `io_parms->length`). This also serves to bound `data_length` for the destination buffer `*buf`, assuming `*buf` was allocated for `count` bytes. 3. Line 1746: `(size_t)data_offset + data_length > rsp_iov.iov_len` is the critical check. It ensures that the entire data segment (starting at `data_offset` and spanning `data_length` bytes) fits within the actual received buffer `rsp_iov.iov_len`. This directly protects against an OOB read from the source buffer `rsp_iov.iov_base`. Counterexample test: - Source buffer `rsp_iov.iov_len = 100`, `data_offset = 50`. If `data_length = 60`, then `data_offset + data_length = 110`. The check `110 > 100` is true, causing `smb_EIO2` to be called and `memcpy` skipped. - If `data_length = 500000` (exceeding `CIFSMaxBufSize`), the check at line 1738 (`data_length > CIFSMaxBufSize`) would be true, leading to `smb_EIO2` and `memcpy` skipped. These checks sufficiently guard the `memcpy` operation against OOB reads from the server response buffer and OOB writes to the kernel-allocated destination buffer `*buf` (given the implicit contract that `*buf` is `count` bytes).

Finding #2 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 1732
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
Tainted varpReadData
Sinkmemcpy() line 1760 (arg 1, role=pointer)
Sink snippetmemcpy(*buf, pReadData, data_length);
Possibly guardedno
Dismissed: The `pReadData` pointer is derived from `pSMBr->hdr.Protocol` and the server-supplied `data_offset`. This pointer is used as the source for `memcpy`. The bounds check at line 1745, `data_offset < sizeof(*pSMBr) || (size_t)data_offset + data_length > rsp_iov.iov_len`, directly validates `data_offset` and the region it defines: 1. `data_offset < sizeof(*pSMBr)`: This checks the lower bound for `data_offset`. `sizeof(*pSMBr)` represents the minimum size of the fixed `READ_RSP` header. This ensures `data_offset` does not point into the header itself where the data payload should not be. This is a crucial check to prevent misinterpreting header fields as data. 2. `(size_t)data_offset + data_length > rsp_iov.iov_len`: This checks the upper bound, ensuring that the `data_length` bytes starting at `data_offset` do not extend beyond the actual received buffer `rsp_iov.iov_len`. Counterexample test: - Assume `sizeof(*pSMBr)` is 32. If `data_offset = 0` (or any value less than 32), then `0 < 32` is true, triggering `smb_EIO2` and skipping `memcpy`. - If `rsp_iov.iov_len = 100`, `data_offset = 80`, `data_length = 30`. Then `80 + 30 = 110`. The check `110 > 100` is true, triggering `smb_EIO2` and skipping `memcpy`. Both the lower and upper bounds of `data_offset` and the data region it defines are properly validated against the received buffer size, preventing OOB access.
The `CIFSSMBUnixQuerySymLink` function receives a server response `pSMBr` via `SendReceive`. While `SendReceive` ensures the total buffer size received (`bytes_returned`) does not exceed `CIFSMaxBufSize+MAX_CIFS_HDR_SIZE`, there is no validation that the server-supplied `pSMBr->t2.DataOffset` and `pSMBr->t2.DataCount` fields describe a region *within* this received buffer. Both findings relate to an OOB read in `cifs_strndup_from_utf16` (specifically, its internal call to `cifs_utf16_bytes`) caused by an unvalidated `DataOffset` or `DataCount`, which can then lead to a malformed allocation size.

Finding #1 — Category B — cross-function via cifs_strndup_from_utf16() — BUG oob_read

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 2961
Taint snippetdata_start = ((char *) &pSMBr->hdr.Protocol) +
Tainted vardata_start
Call siteline 2970 — passes data_start to cifs_strndup_from_utf16()
Call snippet*symlinkinfo = cifs_strndup_from_utf16(data_start,
Sink (in callee)kmalloc() line 341 (arg 0, role=size)
Sink snippetdst = kmalloc(len, GFP_KERNEL);
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: kernel panic from reading unmapped memory, or reading sensitive kernel data if the OOB access lands in another kernel object. Potentially followed by an undersized or oversized kmalloc, leading to further corruption or resource exhaustion.
Fix: Before calling `cifs_strndup_from_utf16`, validate that `le16_to_cpu(pSMBr->t2.DataOffset)` and `le16_to_cpu(pSMBr->t2.DataOffset) + le16_to_cpu(pSMBr->t2.DataCount)` are both within the bounds of the actual `bytes_returned` response buffer, relative to `&pSMBr->hdr.Protocol`. Add a check like `if (data_offset_val > response_data_len || data_offset_val + data_count_val > response_data_len) { return -EIO; }` after `bytes_returned` is known.
CVE pattern: SMB DataOffset OOB

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

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 2959
Taint snippetu16 count = le16_to_cpu(pSMBr->t2.DataCount);
Tainted varcount
Call siteline 2970 — passes count to cifs_strndup_from_utf16()
Call snippet*symlinkinfo = cifs_strndup_from_utf16(data_start,
Sink (in callee)kmalloc() line 341 (arg 0, role=size)
Sink snippetdst = kmalloc(len, GFP_KERNEL);
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: kernel panic from reading unmapped memory, or reading sensitive kernel data if the OOB access lands in another kernel object. Potentially followed by an undersized or oversized kmalloc, leading to further corruption or resource exhaustion.
Fix: Before calling `cifs_strndup_from_utf16`, validate that `le16_to_cpu(pSMBr->t2.DataOffset)` and `le16_to_cpu(pSMBr->t2.DataOffset) + le16_to_cpu(pSMBr->t2.DataCount)` are both within the bounds of the actual `bytes_returned` response buffer, relative to `&pSMBr->hdr.Protocol`. Add a check like `if (data_offset_val > response_data_len || data_offset_val + data_count_val > response_data_len) { return -EIO; }` after `bytes_returned` is known.
CVE pattern: SMB DataOffset OOB

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

The function processes a server-supplied SMB Transaction2 Query File System Information response. The `DataOffset` field from the response is used to calculate a pointer `response_data` into the received buffer. The existing validation checks are insufficient to ensure that the subsequent dereferences of `response_data` (accessing fields like `BytesPerSector`, `TotalAllocationUnits`, `FreeAllocationUnits`) will remain within the bounds of the actually received message data.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 4989
Taint snippet__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
Tainted varresponse_data
Pointer derefresponse_data->BytesPerSector line 4996
Sink snippetle16_to_cpu(response_data->BytesPerSector) *
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic, KASAN: slab-out-of-bounds Read in SMBOldQFSInfo, information disclosure.
Fix: Add a bounds check to ensure that the `FILE_SYSTEM_ALLOC_INFO` structure, when accessed via `response_data`, fits within the actual received message length. The `data_offset` field is relative to `&pSMBr->hdr.Protocol` (which is `pSMBr + 4`), and the total received data length is `32 + get_bcc(&pSMBr->hdr)`. Therefore, before line 4993, add a check: ```c __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); __u16 bcc = get_bcc(&pSMBr->hdr); if (rc || bcc < 18 || (u32)data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO) > 28 + bcc) { rc = smb_EIO2(smb_eio_trace_oldqfsinfo_bcc_too_small, bcc, data_offset); } else { // ... original code for response_data assignment and field access } ``` The `28` in the check `28 + bcc` comes from `32 (SMB header size) - 4 (offset of Protocol field)`. This ensures that `4 + data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO)` does not exceed `32 + bcc` bytes from the start of `pSMBr`.
CVE pattern: CVE-2022-NNNN style DataOffset OOB

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

The `cifs_create_reparse_inode` function processes extended attributes (EAs) from a `xattr_iov` buffer, which is treated as user/server-supplied. It iterates through a list of `smb2_file_full_ea_info` structures using a `next_entry_offset` field and uses `ea_value_length` for a `memcpy` operation. There is a general lack of bounds checking against the provided `xattr_iov->iov_len` for both the pointer advancement and the `memcpy` source buffer.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 3178
Taint snippetea = (struct smb2_file_full_ea_info *)((u8 *)ea +
Tainted varea
Pointer derefea->next_entry_offset line 3179
Sink snippetle32_to_cpu(ea->next_entry_offset));
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel crash (e.g., page fault) due to out-of-bounds read when accessing `ea->next_entry_offset` in a subsequent loop iteration.
Fix: Before advancing the `ea` pointer in line 3179, ensure that `(u8 *)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`. If `next_entry_offset` points past the end of the `xattr_iov` buffer, an error should be returned.
CVE pattern: Loop pointer advance with insufficient remaining-size check

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

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 3166
Taint snippetrc = CIFSSMBSetEA(xid,
Tainted varle16_to_cpu(ea->ea_value_length)
Call siteline 3166 — passes le16_to_cpu(ea->ea_value_length) to CIFSSMBSetEA()
Call snippetrc = CIFSSMBSetEA(xid,
Sink (in callee)memcpy() line 6446 (arg 2, role=size)
Sink snippetmemcpy(parm_data->list.name + name_len + 1,
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel crash (e.g., page fault) due to out-of-bounds read during `memcpy` in `CIFSSMBSetEA`.
Fix: Before calling `CIFSSMBSetEA` at line 3166, validate that the source buffer for `ea_value` (derived from `ea->ea_data`) combined with `le16_to_cpu(ea->ea_value_length)` does not read past the end of the `xattr_iov` buffer. Specifically, ensure that `(u8 *)&ea->ea_data[ea->ea_name_length+1] + le16_to_cpu(ea->ea_value_length)` does not exceed `xattr_iov->iov_base + xattr_iov->iov_len`. An error should be returned if this check fails.
CVE pattern: Missing source buffer validation for memcpy

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

The function `cifs_query_reparse_point` retrieves reparse point data from an SMB server. It receives a `TRANSACT_IOCTL_RSP` structure, from which it extracts `DataOffset`. This `DataOffset` is used to calculate the `start` pointer, which is then cast to `struct reparse_data_buffer *buf`. The static analysis flags the access to `buf->ReparseDataLength` as a potential OOB read because `buf` is derived from a server-supplied offset. However, there is a explicit bounds check at lines 3083-3088: `if (start >= end || (size_t)(end - start) < sizeof(*buf))` This check ensures two things: 1. `start >= end`: The calculated start of the reparse data does not fall outside the overall message buffer (`end` marks the end of the data portion of the SMB response). 2. `(size_t)(end - start) < sizeof(*buf)`: There are at least `sizeof(struct reparse_data_buffer)` bytes available from `start` to `end`. If this condition is true (meaning insufficient space), an error is returned via `smb_EIO2`, and the `buf` dereference is not reached. Since `ReparseDataLength` is a field within `struct reparse_data_buffer`, and the code explicitly checks that at least `sizeof(*buf)` bytes are available *before* casting to `buf` and accessing its fields, the access to `buf->ReparseDataLength` is protected. The finding is a false positive.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 3054
Taint snippetdata_offset = le32_to_cpu(io_rsp->DataOffset);
Tainted varbuf
Pointer derefbuf->ReparseDataLength line 3094
Sink snippetdata_count < le16_to_cpu(buf->ReparseDataLength) + len) {
Possibly guardedno
Dismissed: The taint source `data_offset = le32_to_cpu(io_rsp->DataOffset);` (line 3054) is indeed server-supplied, as `io_rsp` is populated from the network by `SendReceive`. The pointer `buf` is derived from `start` which is `&io_rsp->hdr.Protocol + data_offset`. The critical bounds check for the `buf` pointer itself happens at line 3083: `if (start >= end || (size_t)(end - start) < sizeof(*buf))` This check ensures that: 1. The `start` pointer (derived from `data_offset`) is not beyond the `end` of the received data portion. 2. Crucially, `(size_t)(end - start)` (the remaining length from `start` to `end`) must be at least `sizeof(*buf)` for execution to proceed past this `if` statement. If it is less, the function returns an error. Since `buf->ReparseDataLength` is a member of `struct reparse_data_buffer`, ensuring that `sizeof(*buf)` bytes are available at `start` makes the access to any field within `*buf` safe from an OOB read *of the `struct` itself*. Counterexample test: Assume `io_rsp` starts at address `0x1000`. `io_rsp->hdr.Protocol` is at `0x101C`. `sizeof(struct reparse_data_buffer)` is `24` bytes. Let `data_offset = 0`. So `start = 0x101C`. If `end` is calculated to be `0x101C + 20` (e.g., the actual data portion is only 20 bytes long from `start`), then `(size_t)(end - start)` would be `20`. The condition `(size_t)(end - start) < sizeof(*buf)` becomes `20 < 24`, which is TRUE. Therefore, the code would execute the `if` block, call `smb_EIO2`, and `goto error`. The line `buf->ReparseDataLength` (3094) would not be reached. This demonstrates that the check at line 3083 is sufficient to prevent OOB access to fields within the `reparse_data_buffer` header.

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

The `cifs_to_posix_acl` function processes a server-supplied ACL structure. It calculates the total size required for the `cifs_posix_acl` header and the access ACEs (`size`). This calculated `size` is then validated against `size_of_data_area` (the actual received data length from the SMB response) before the pointer `pACE` is derived using the `count` (access_entry_count). This validation ensures that the derived pointer `pACE` (which points to the theoretical start of the default ACEs, immediately following the access ACEs) is within the bounds of the received server data. The subsequent usage of `pACE` in the loop `FOREACH_ACL_ENTRY` iterates `count` times for the default entries, which is a different `count` that is also validated.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 3361
Taint snippetcount = le16_to_cpu(cifs_acl->access_entry_count);
Tainted varcount
Subscript[] line 3365
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 tainted variable `count` (derived from `cifs_acl->access_entry_count`) is used to calculate the `size` of the access ACL block: `size = sizeof(struct cifs_posix_acl) + sizeof(struct cifs_posix_ace) * count;` (lines 3362-3363). This `size` is then checked against `size_of_data_area` (the total length of the received data) at line 3369: `if (size_of_data_area < size) return -EINVAL;`. This check ensures that the entire calculated region, including `count` ACEs, fits within the buffer. The sink `pACE = &cifs_acl->ace_array[count];` (line 3365) creates a pointer that effectively points to `src + sizeof(struct cifs_posix_acl) + count * sizeof(struct cifs_posix_ace)`. Since `size` holds this exact offset relative to `src`, and `size` is validated against `size_of_data_area`, the pointer `pACE` is guaranteed to be within the valid bounds of the server-supplied data. Counterexample test: - Assume `sizeof(struct cifs_posix_acl) = 10` bytes. - Assume `sizeof(struct cifs_posix_ace) = 20` bytes. - Let `size_of_data_area = 50` bytes (total received data). - If `cifs_acl->access_entry_count` (after `le16_to_cpu`) is `N`. - `size = 10 + N * 20`. - If `N = 2`, `size = 10 + 2 * 20 = 50`. The check `size_of_data_area < size` (50 < 50) is false. The code proceeds. - `pACE = &cifs_acl->ace_array[2]` points to `src + 10 + 2 * 20 = src + 50`. This is exactly the end of the `size_of_data_area`, which is a valid pointer for one-past-the-end. - If `N = 3`, `size = 10 + 3 * 20 = 70`. The check `size_of_data_area < size` (50 < 70) is true. The function returns `-EINVAL`, preventing the OOB access. - If `N = 0`, `size = 10`. The check `size_of_data_area < size` (50 < 10) is false. The code proceeds. `pACE = &cifs_acl->ace_array[0]` points to `src + 10`. This is safe. The bounds check at line 3369 correctly covers the address calculation for `pACE` at line 3365. The SMT result indicates the value is non-negative, which is consistent with `__u16` from `le16_to_cpu`.

cifs_dump_full_key() — fs/smb/client/ioctl.c FP confidence=high

The static analysis findings incorrectly identify the size arguments to copy_to_user as user-controlled and untainted. The `out.session_key_length`, `out.server_in_key_length`, and `out.server_out_key_length` fields of the local `out` struct are explicitly *overwritten* by kernel-internal constant values or values derived from kernel-internal state (`ses->auth_key.len`) in the `switch` statement at lines 400-410. Therefore, at the time of the `copy_to_user` calls (lines 434, 440, 446), these length variables are kernel-controlled, not user-controlled. Furthermore, the function includes a comprehensive validation check at line 417: `if (out.in_size < sizeof(out) + out.session_key_length + out.server_in_key_length + out.server_out_key_length)`. Here: - `out.in_size` is the *user-supplied total buffer size*, copied from the `in` struct at line 359. - The right-hand side of the comparison is the *total number of bytes the kernel intends to write* to the user buffer, starting with the `out` struct itself, followed by the three keys whose lengths are kernel-determined. This validation ensures that the user has declared a buffer large enough to accommodate all the data the kernel wants to write. If this check passes, the kernel proceeds with the copies. The `copy_to_user` function itself will ensure that the user-provided destination address range is actually mapped and valid, returning `-EFAULT` if it's not. Therefore, there is no kernel memory corruption possible and the user cannot cause an OOB write to other kernel memory.

Finding #1 — Category G2 — false positive

CategoryCat G2 — unvalidated size argument to copy_from/to_user
Taint sourcecopy_to_user() line 434
Taint snippetif (copy_to_user(end, ses->auth_key.response, out.session_key_length)) {
Tainted varout.session_key_length
Unvalidated sizecopy_to_user() arg 2 line 434 — size out.session_key_length
Sink snippetif (copy_to_user(end, ses->auth_key.response, out.session_key_length)) {
Possibly guardedno
Dismissed: The variable `out.session_key_length` is initialized from user input at line 359, but it is immediately overwritten by a kernel-controlled constant or kernel-derived length at lines 403 or 408 (e.g., `CIFS_SESS_KEY_SIZE` or `ses->auth_key.len`). Thus, at the sink (line 434), it is a kernel-controlled value. The overall validation for the user buffer's capacity is performed at line 417 where `out.in_size` (user-controlled total buffer size) is checked against the sum of `sizeof(out)` and all kernel-determined key lengths. This check covers the total expected write to the user buffer. No counterexample can cause an OOB write due to `out.session_key_length` being too large, as it is a small kernel constant (e.g., 16 or 32 bytes) and the user-provided buffer capacity is validated.

Finding #2 — Category G2 — false positive

CategoryCat G2 — unvalidated size argument to copy_from/to_user
Taint sourcecopy_to_user() line 440
Taint snippetif (copy_to_user(end, ses->smb3encryptionkey, out.server_in_key_length)) {
Tainted varout.server_in_key_length
Unvalidated sizecopy_to_user() arg 2 line 440 — size out.server_in_key_length
Sink snippetif (copy_to_user(end, ses->smb3encryptionkey, out.server_in_key_length)) {
Possibly guardedno
Dismissed: Similar to finding #1, `out.server_in_key_length` is overwritten by a kernel-controlled constant at lines 404 or 409 (e.g., `SMB3_GCM128_CRYPTKEY_SIZE` or `SMB3_GCM256_CRYPTKEY_SIZE`) before being used at the sink (line 440). The total user buffer capacity (`out.in_size`) is validated at line 417 against the total data to be written by the kernel. No counterexample can cause an OOB write.

Finding #3 — Category G2 — false positive

CategoryCat G2 — unvalidated size argument to copy_from/to_user
Taint sourcecopy_to_user() line 446
Taint snippetif (copy_to_user(end, ses->smb3decryptionkey, out.server_out_key_length)) {
Tainted varout.server_out_key_length
Unvalidated sizecopy_to_user() arg 2 line 446 — size out.server_out_key_length
Sink snippetif (copy_to_user(end, ses->smb3decryptionkey, out.server_out_key_length)) {
Possibly guardedno
Dismissed: Similar to finding #1 and #2, `out.server_out_key_length` is overwritten by a kernel-controlled constant at lines 404 or 409 (e.g., `SMB3_GCM128_CRYPTKEY_SIZE` or `SMB3_GCM256_CRYPTKEY_SIZE`) before being used at the sink (line 446). The total user buffer capacity (`out.in_size`) is validated at line 417 against the total data to be written by the kernel. No counterexample can cause an OOB write.

parse_dfs_referrals() — fs/smb/client/misc.c FP confidence=high

The `parse_dfs_referrals` function appears to have robust input validation for server-supplied DFS referral structures. It performs initial size checks for the overall response buffer, validates the number of referrals and their fixed-size structure, and then iterates through individual referral entries. For variable-length string offsets (`DfsPathOffset`, `NetworkAddressOffset`), it performs both lower-bound checks (ensuring the offset points past the fixed header) and upper-bound checks (ensuring the derived pointer is within the overall response buffer). The `max_len` calculation then correctly establishes the remaining safe read length for string parsing helpers like `cifs_strndup_from_utf16` and `cifs_utf16_bytes`.

Finding #1 — Category F — cross-function via cifs_utf16_bytes() — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 758
Taint snippetpath_consumed = le16_to_cpu(rsp->PathConsumed);
Tainted varpath_consumed
Call siteline 775 — passes path_consumed to cifs_utf16_bytes()
Call snippetnode->path_consumed = cifs_utf16_bytes(tmp, path_consumed,
Loopfor_loop line 299
Sink snippetfor (i = 0; i < maxwords; i++) {
Possibly guardedyes (heuristic)
Dismissed: The `path_consumed` value is server-supplied. It is used as `maxbytes` in `cifs_utf16_bytes` to limit how many bytes are processed from the `tmp` buffer. The `tmp` buffer is locally allocated with `search_name_utf16_len` bytes. Crucially, before calling `cifs_utf16_bytes`, there's a check that `path_consumed` does not exceed `search_name_utf16_len` (line 763) or `search_name_len` (line 779 for non-unicode). This ensures that `maxbytes` (which is `path_consumed`) passed to `cifs_utf16_bytes` is never larger than the `tmp` buffer's allocated size. Therefore, `cifs_utf16_bytes` will not read past the end of `tmp`.

Finding #2 — Category B — cross-function via cifs_strndup_from_utf16() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 799
Taint snippettemp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);
Tainted vartemp
Call siteline 801 — passes temp to cifs_strndup_from_utf16()
Call snippetnode->path_name = cifs_strndup_from_utf16(temp, max_len,
Sink (in callee)kmalloc() line 341 (arg 0, role=size)
Sink snippetdst = kmalloc(len, GFP_KERNEL);
Possibly guardedno
Dismissed: The taint source is `DfsPathOffset`, which is server-supplied. `temp` is derived from this offset (`(char *)ref + offset`). The scanner incorrectly states `temp` is used as `size` in `kmalloc()`. `temp` is passed as the `src` pointer to `cifs_strndup_from_utf16`, which reads *from* `temp`. Memory for the new string is allocated via `kmalloc(len)`, where `len` is computed by `cifs_utf16_bytes` based on the content at `temp` and bounded by `max_len`. Extensive validation exists for `DfsPathOffset` at line 791: it checks `offset >= sizeof(*ref)` (lower bound to prevent reading header fields as string data) and `offset <= data_end - (char *)ref` (upper bound to ensure `temp` is within the overall response buffer). The `max_len` variable (line 800) correctly calculates the number of remaining bytes in the buffer from `temp` to `data_end`. `cifs_strndup_from_utf16` (and `cifs_utf16_bytes` it calls) uses this `max_len` to limit how many bytes it reads from `temp`, thereby preventing OOB reads from the server response buffer.

Finding #3 — Category B — cross-function via cifs_strndup_from_utf16() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 799
Taint snippettemp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);
Tainted varmax_len
Call siteline 801 — passes max_len to cifs_strndup_from_utf16()
Call snippetnode->path_name = cifs_strndup_from_utf16(temp, max_len,
Sink (in callee)kmalloc() line 341 (arg 0, role=size)
Sink snippetdst = kmalloc(len, GFP_KERNEL);
Possibly guardedno
Dismissed: Similar to finding #2, `max_len` is derived from the server-supplied `DfsPathOffset`. `max_len` represents the number of bytes from `temp` to the end of the server response buffer. The `kmalloc` size (`len`) in `cifs_strndup_from_utf16` is derived by `cifs_utf16_bytes` based on the actual string content found at `temp`, and crucially, this processing is strictly bounded by `max_len`. Since `DfsPathOffset` is validated (line 791) to ensure `temp` is within the valid range of the server response, `max_len` will always be a non-negative value representing a valid remaining length within the allocated response buffer. `len` will never exceed a value proportional to `max_len` (e.g., `max_len` for single-byte character sets, `max_len / 2 * NLS_MAX_CHARSET_SIZE` for UTF-16). This prevents an integer overflow in the `kmalloc` size from `len` and ensures that the allocation size is genuinely based on the bounded length of the string extracted from the validated server buffer.

cnvrtDosUnixTm() — fs/smb/client/netmisc.c FP confidence=high

The `cnvrtDosUnixTm` function converts DOS date/time values (potentially server-supplied) into a Unix `timespec64`. It includes explicit validation and clamping for month and day values. Specifically, the `month` field is validated and clamped to the range [1, 12] before being decremented and used as an array index. This ensures the index is always within the bounds [0, 11] for the `total_days_of_prev_months` array, which is a 12-element array.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 164
Taint snippetu16 date = le16_to_cpu(le_date);
Tainted varmonth
Subscript[] line 187
Sink snippetdays = day + total_days_of_prev_months[month];
Possibly guardedno
Dismissed: The `month` variable is extracted from `sd->Month` (4 bits from `le_date`). At line 181, there is a conditional check `if (day < 1 || day > 31 || month < 1 || month > 12)`. If `month` is out of the `[1, 12]` range, it is clamped to this range at line 184: `month = clamp(month, 1, 12);`. After this, `month` is guaranteed to be in `[1, 12]`. At line 186, `month` is decremented: `month -= 1;`. This means the value used as an array index at line 187 (`total_days_of_prev_months[month]`) will be in the range `[0, 11]`. The `total_days_of_prev_months` array is a 12-element array, indexed 0-11, so this access is always in bounds. The `clamp` operation correctly handles all possible 4-bit values for `sd->Month` (0-15) and ensures a safe index.

mknod_wsl() — fs/smb/client/reparse.c FP confidence=high

The `mknod_wsl` function constructs a request to create a reparse point (symlink) on an SMB share. The `buf` and `xattr_iov.iov_base` (aliased as `cc`) are populated by helper functions (`wsl_set_reparse_buf` and `wsl_set_xattrs`) which are responsible for building the request payload. Therefore, the fields within these structures, such as `ReparseTag` and `DataLength`, are *generated locally by the kernel* as part of the request construction, not parsed from a server response. The `le32_to_cpu()` calls are used to convert these locally-set values (which were likely previously set using `cpu_to_le32()`) back to host byte order for internal kernel logic. This matches false positive pattern #1 regarding locally-written struct fields. Additionally, the second finding about `sizeof(*data)` is a classic false positive, as `sizeof` is a compile-time constant and cannot be tainted by runtime values.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le32_to_cpu() line 713
Taint snippetlen = le32_to_cpu(cc->ctx.DataLength);
Tainted varlen
Sinkmemcpy() line 714 (arg 2, role=size)
Sink snippetmemcpy(data.wsl.eas, &cc->ea, len);
Possibly guardedno
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The taint source `le32_to_cpu(cc->ctx.DataLength)` is not server-supplied. The `cc` pointer (`xattr_iov.iov_base`) is populated by `wsl_set_xattrs`. Given that `mknod_wsl` is for *creating* a node (i.e., sending a request to the server), it's highly probable that `wsl_set_xattrs` constructs the `smb2_create_ea_ctx` structure and sets its `DataLength` field to a value derived from the locally-generated EA data. Thus, `len` is a kernel-controlled value. Assuming `wsl_set_xattrs` is correctly implemented (which is a reasonable assumption for a request builder), it would ensure that `DataLength` is consistent with the actual data placed in `cc->ea` and also bounded by the destination `data.wsl.eas` (which is a fixed-size array, typically `WSL_MAX_EA_SIZE`). Therefore, the `memcpy` operation is implicitly safe due to the source of `len` being locally controlled and appropriately bounded. No counterexample can be constructed where `len` would exceed the bounds of `&cc->ea` or `data.wsl.eas`, assuming `wsl_set_xattrs` constructs a valid request.

Finding #2 — Category B — cross-function via cifs_free_open_info() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele32_to_cpu() line 706
Taint snippetdata = (struct cifs_open_info_data) {
Tainted vardata
Call siteline 725 — passes data to cifs_free_open_info()
Call snippetcifs_free_open_info(&data);
Sink (in callee)memset() line 490 (arg 2, role=size)
Sink snippetmemset(data, 0, sizeof(*data));
Possibly guardedno
Dismissed: The scanner incorrectly flags `data` as tainted due to `le32_to_cpu(buf->ReparseTag)` at line 706. However, `sizeof(*data)` is a compile-time constant representing the size of `struct cifs_open_info_data`. It does not derive any runtime value from `data` or its fields. Therefore, the `memset` operation uses a fixed, correct size and cannot be influenced by any tainted runtime value. This is a false positive due to a misunderstanding of the `sizeof` operator. No counterexample is possible as `sizeof(*data)` is constant.

parse_reparse_nfs() — fs/smb/client/reparse.c BUG confidence=high

The function `parse_reparse_nfs` processes a server-supplied `reparse_nfs_data_buffer`. While it performs some internal consistency checks on the `ReparseDataLength` field (e.g., minimum size, even length for symlinks), it critically lacks a check to ensure that the server-supplied `ReparseDataLength` (which dictates the size of `InodeType` and `DataBuffer`) does not exceed the actual buffer boundary (`plen`) passed from the caller `parse_reparse_point`. This allows a malicious server to cause an out-of-bounds read when processing the `DataBuffer` field.

Finding #1 — Category B — cross-function via cifs_strndup_from_utf16() — BUG oob_read

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 758
Taint snippetlen = le16_to_cpu(buf->ReparseDataLength);
Tainted varlen
Call siteline 781 — passes len to cifs_strndup_from_utf16()
Call snippetdata->symlink_target = cifs_strndup_from_utf16(buf->DataBuffer,
Sink (in callee)kmalloc() line 341 (arg 0, role=size)
Sink snippetdst = kmalloc(len, GFP_KERNEL);
Possibly guardedyes (heuristic)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (KASAN) or information disclosure due to reading past the end of the received network buffer when `UniStrnlen` or `cifs_from_utf16` are called.
Fix: Add a bounds check in `parse_reparse_nfs` (or its caller `parse_reparse_point`) to ensure the total size implied by `ReparseDataLength` does not exceed the actual received buffer length (`plen`). Proposed fix: 1. Modify `parse_reparse_nfs` signature to accept `u32 plen` as an argument: `static int parse_reparse_nfs(struct reparse_nfs_data_buffer *buf, u32 plen, ...)` 2. Add the following check early in `parse_reparse_nfs` (e.g., after line 758): `len = le16_to_cpu(buf->ReparseDataLength);` `if (8 + len > plen) { /* 8 bytes for header before InodeType */ cifs_dbg(VFS, "srv returned reparse data length 0x%x exceeding buffer size 0x%x\n", 8 + len, plen); return smb_EIO2(smb_eio_trace_reparse_nfs_too_long, 8 + len, plen); }` 3. Update the call site in `parse_reparse_point` (line 1109) to pass `plen`: `return parse_reparse_nfs((struct reparse_nfs_data_buffer *)buf, plen, ...)`
CVE pattern: SMB negotiation response integer overflow / OOB read
The function `parse_reparse_wsl_symlink` processes a server-supplied reparse point data buffer for WSL symlinks. The `ReparseDataLength` field, which controls the size of the overall data block, is extracted and used to derive lengths for string conversions and allocations. Finding #1, regarding integer overflow in kzalloc, is a false positive because the maximum possible value for `symname_utf8_len` (derived from a u16 field) is 65531, and `65531 * 2 = 131062` does not overflow a standard `int` or `size_t` type on any common architecture, thus preventing an undersized allocation due to multiplication wrap-around. Finding #2 is a real bug caused by a mismatch in units when calling `cifs_strndup_from_utf16`. The `symname_utf16_len` variable is first assigned the *number of UTF-16 characters* by `utf8s_to_utf16s`, then immediately multiplied by 2 to become the *byte length*. This byte length is then passed as the `maxlen` argument to `cifs_strndup_from_utf16`. However, inside `cifs_strndup_from_utf16` (when `is_unicode` is true), this `maxlen` is passed to `cifs_utf16_bytes` which expects a *character count*. This leads to `cifs_utf16_bytes` attempting to read `maxlen * sizeof(__le16)` bytes from a buffer that was only allocated for `maxlen` bytes, resulting in a heap out-of-bounds read.

Finding #1 — Category B — INTEGER OVERFLOW — false positive

CategoryCat B — integer overflow: symname_utf8_len * 2
Taint sourcele16_to_cpu() line 1044
Taint snippetint len = le16_to_cpu(buf->ReparseDataLength);
Tainted varsymname_utf8_len
Overflow exprsymname_utf8_len * 2
Safe fixkmalloc_array() or check_mul_overflow()
Sinkkzalloc() line 1077 (arg 0, role=size_mul_overflow)
Sink snippetsymname_utf16 = kzalloc(symname_utf8_len * 2, GFP_KERNEL);
Possibly guardedyes (heuristic)
Dismissed: The `len` variable (derived from `buf->ReparseDataLength`) is an `int` after `le16_to_cpu`, so its maximum value is 65535. `data_offset` is a constant 4. Thus, `symname_utf8_len` can be at most `65535 - 4 = 65531`. The multiplication `symname_utf8_len * 2` results in a maximum value of `131062`. This value is well within the range of a 32-bit `int` (max ~2 billion) and a 64-bit `size_t` (max ~18 quintillion), so no integer overflow or wrap-around can occur during the multiplication itself. The `kzalloc` call will receive the correct intended size, and thus there is no risk of an undersized allocation due to this specific integer overflow finding.

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

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 1044
Taint snippetint len = le16_to_cpu(buf->ReparseDataLength);
Tainted varsymname_utf16_len
Call siteline 1089 — passes symname_utf16_len to cifs_strndup_from_utf16()
Call snippetdata->symlink_target = cifs_strndup_from_utf16((u8 *)symname_utf16,
Sink (in callee)kmalloc() line 341 (arg 0, role=size)
Sink snippetdst = kmalloc(len, GFP_KERNEL);
Possibly guardedyes (heuristic)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic (KASAN slab-out-of-bounds read) or information disclosure from reading adjacent heap memory. Example: If `symname_utf8_len` is 10, then `kzalloc` allocates 20 bytes for `symname_utf16`. If `utf8s_to_utf16s` returns 10 (characters), `symname_utf16_len` becomes 20 after `*= 2`. This byte length (20) is passed as `maxlen` to `cifs_strndup_from_utf16`. Inside `cifs_strndup_from_utf16`, `cifs_utf16_bytes(src, maxlen, ...)` is called. `cifs_utf16_bytes` interprets `maxlen` (20) as a *character count*. It will then attempt to read `20 * sizeof(__le16) = 40` bytes from `symname_utf16`, which was only allocated for 20 bytes, causing an OOB read of 20 bytes.
Fix: Modify `parse_reparse_wsl_symlink` to pass the *character count* (the return value of `utf8s_to_utf16s` before multiplying by 2) as `maxlen` to `cifs_strndup_from_utf16`. Alternatively, modify `cifs_strndup_from_utf16` to consistently use byte lengths for `maxlen` when `is_unicode` is true, by adjusting the call to `cifs_utf16_bytes` accordingly (e.g., `cifs_utf16_bytes(src, maxlen / sizeof(__le16), ...)` or using a different parameter name to indicate byte length). The former is typically the most direct fix.
CVE pattern: Integer conversion error leading to OOB read

is_valid_oplock_break() — fs/smb/client/smb1misc.c BUG confidence=high

The function processes server-supplied SMB1 transaction responses. It extracts a data offset (`DataOffset`) and uses it to construct a pointer (`pnotify`) to a `file_notify_information` structure. While an upper-bound check exists for the fixed part of `file_notify_information`, a critical lower-bound check for `DataOffset` is missing, allowing `pnotify` to point into the SMB header. Furthermore, the `FileName` field within `file_notify_information` is a variable-length string that is printed using `%s` without a length limit, leading to potential OOB reads and information disclosure if no null terminator is found within the packet boundaries.

Finding #1 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 87
Taint snippetdata_offset = le32_to_cpu(pSMBr->DataOffset);
Tainted varpnotify
Pointer derefpnotify->FileName line 98
Sink snippetpnotify->FileName, pnotify->Action);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from attempting to read past allocated buffer, or information disclosure in kernel logs if contents past end of `FileName` field are printed.
Fix: 1. Add a lower-bound check for `data_offset` to ensure it points past the `smb_com_transaction_change_notify_rsp` header (e.g., `if (data_offset < <minimum_expected_offset_for_data>) return true;`). The minimum offset should be derived from the fixed and variable portions of the transaction header. 2. Read `pnotify->FileNameLength` after `pnotify` is established. 3. Add an upper-bound check: `if (data_offset + offsetof(struct file_notify_information, FileName) + FileNameLength > len) return true;`. 4. When printing, use the length: `cifs_dbg(FYI, "dnotify on %.*s Action: 0x%x\n", FileNameLength, pnotify->FileName, pnotify->Action);`.
CVE pattern: SMB1 DataOffset OOB, Unbounded string print

cifs_query_path_info() — fs/smb/client/smb1ops.c FP confidence=high

All flagged findings stem from pointer arithmetic involving `le32_to_cpu(ea->next_entry_offset)` or `le16_to_cpu(ea->ea_value_length)`. The `ea` pointer initially points to `data->wsl.eas`, which is a `char eas[200]` buffer, part of the locally-allocated and zero-initialized `struct cifs_open_info_data query_data`. The code path that leads to the flagged `le32_to_cpu` operations (lines 665 and 711) involves `ea->next_entry_offset` and `ea->ea_value_length` fields being either zero (due to zero-initialization of `query_data`) or explicitly written by the kernel using `cpu_to_le32()`/`cpu_to_le16()` from compile-time constants (e.g., `SMB2_WSL_XATTR_NAME_LEN`, `SMB2_WSL_XATTR_MODE_SIZE`, `sizeof(*ea)`). Therefore, the values read by `le32_to_cpu()` are *not* server-supplied but are locally controlled kernel computations. This makes all findings false positives according to rule #1.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 665
Taint snippetea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));
Tainted varea
Pointer derefea->ea_data line 669
Sink snippet&ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1],
Possibly guardedno
Dismissed: The taint source `le32_to_cpu(ea->next_entry_offset)` at line 665 is unreachable. The `ea` pointer at line 656 points to `data->wsl.eas` which is zero-initialized. The `do-while` loop at lines 657-660 terminates immediately as `ea->next_entry_offset` is 0. The subsequent `if (le16_to_cpu(ea->ea_value_length))` at line 661 is also false because `ea->ea_value_length` is 0. Thus, the `ea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset))` at line 665 is never executed. Even if it were, `ea->next_entry_offset` would be derived from a zero-initialized local buffer, not server-supplied data. This finding is a false positive.

Finding #2 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele32_to_cpu() line 665
Taint snippetea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));
Tainted varea
Sinkmemcpy() line 676 (arg 0, role=pointer)
Sink snippetmemcpy(&ea->ea_data[0], SMB2_WSL_XATTR_MODE, SMB2_WSL_XATTR_NAME_LEN + 1);
Possibly guardedno
Dismissed: Similar to finding #1, the taint source `le32_to_cpu(ea->next_entry_offset)` at line 665 is unreachable. The `ea` pointer is not advanced by server-supplied data before the `memcpy` sink at line 676. The `memcpy` itself copies a compile-time constant string (`SMB2_WSL_XATTR_MODE`) of a constant size (`SMB2_WSL_XATTR_NAME_LEN + 1`) into `&ea->ea_data[0]`, where `ea` points to the start of the `data->wsl.eas[200]` buffer. The combined size of the constructed EA entry (16 bytes) fits within the 200-byte buffer. This finding is a false positive.

Finding #3 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 711
Taint snippetea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));
Tainted varea
Pointer derefea->ea_data line 715
Sink snippet&ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1],
Possibly guardedno
Dismissed: The taint source is `le32_to_cpu(ea->next_entry_offset)` at line 711. Here, `ea->next_entry_offset` is a value that was explicitly written by the kernel at line 708 using `cpu_to_le32()` from a calculation involving compile-time constants (`sizeof(*ea)`, `SMB2_WSL_XATTR_NAME_LEN`, `SMB2_WSL_XATTR_MODE_SIZE`). This is a round-trip of a locally controlled, kernel-computed value, not server-supplied data. Thus, the taint source is not genuinely server-supplied. The `ea` pointer is advanced to the location of the *second* EA entry, which is also locally constructed. This finding is a false positive.

Finding #4 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele32_to_cpu() line 711
Taint snippetea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));
Tainted varea
Sinkmemcpy() line 722 (arg 0, role=pointer)
Sink snippetmemcpy(&ea->ea_data[0], SMB2_WSL_XATTR_DEV, SMB2_WSL_XATTR_NAME_LEN + 1);
Possibly guardedno
Dismissed: Similar to finding #3, the taint source `le32_to_cpu(ea->next_entry_offset)` at line 711 is not server-supplied but a kernel-computed constant. The `ea` pointer is advanced by this kernel-computed offset. The `memcpy` sink at line 722 copies a compile-time constant string (`SMB2_WSL_XATTR_DEV`) of a constant size (`SMB2_WSL_XATTR_NAME_LEN + 1`) into `&ea->ea_data[0]`, where `ea` points to the start of the *second* constructed EA entry. The total size of both constructed EA entries (16 + 24 = 40 bytes) fits within the 200-byte `data->wsl.eas` buffer. This finding is a false positive.

sess_auth_kerberos() — fs/smb/client/smb1session.c FP confidence=high

The `decode_ascii_ssetup` function correctly uses `strnlen` in conjunction with a `len >= bleft` check to safely parse null-terminated strings within a bounded buffer (`bleft`). This pattern prevents out-of-bounds reads during `memcpy` and oversized allocations for `kmalloc` when a string is not null-terminated or would exceed the provided buffer limit. The final string length calculation is not used for memory allocation or copying in the ASCII path, further reducing risk.

Finding #1 — Category B — cross-function via decode_ascii_ssetup() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 627
Taint snippetblob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
Tainted varbcc_ptr
Call siteline 649 — passes bcc_ptr to decode_ascii_ssetup()
Call snippetdecode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
Sink (in callee)kmalloc() line 270 (arg 0, role=size_mul_overflow)
Sink snippetses->serverOS = kmalloc(len + 1, GFP_KERNEL);
Possibly guardedyes (heuristic)
Dismissed: The `bcc_ptr` is derived from `pByteArea(smb_buf)`, which points into the server-supplied SMB response buffer. The `bytes_remaining` parameter is also server-derived and validated by `get_bcc()` and `blob_len > bytes_remaining` check in `sess_auth_kerberos`. Inside `decode_ascii_ssetup`, `len = strnlen(bcc_ptr, bleft)` correctly calculates the string length within the provided `bleft` bytes. The subsequent check `if (len >= bleft) return;` ensures that if `strnlen` returned `bleft` (meaning no null-terminator was found within the buffer), the function returns, preventing `kmalloc(len + 1)` from allocating a byte beyond what is known to be available, and `memcpy` from reading past the `bleft` limit. The `kmalloc(len + 1)` and `memcpy(..., len)` operations are therefore safe with respect to the `bleft` boundary. This is a common and correct pattern for bounded string parsing.

Finding #2 — Category B — cross-function via decode_ascii_ssetup() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 627
Taint snippetblob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
Tainted varbytes_remaining
Call siteline 649 — passes bytes_remaining to decode_ascii_ssetup()
Call snippetdecode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
Sink (in callee)kmalloc() line 270 (arg 0, role=size_mul_overflow)
Sink snippetses->serverOS = kmalloc(len + 1, GFP_KERNEL);
Possibly guardedyes (heuristic)
Dismissed: The `bytes_remaining` parameter is derived from `get_bcc(smb_buf)` (server-supplied byte count) and then reduced by `blob_len` (also server-supplied, but validated against `bytes_remaining` at line 628). Therefore, `bytes_remaining` passed to `decode_ascii_ssetup` represents the actual available bytes in the buffer. Inside `decode_ascii_ssetup`, this `bleft` parameter is used as the `n` argument for `strnlen(bcc_ptr, bleft)`. The check `if (len >= bleft) return;` (lines 265 and 283) correctly handles cases where a null-terminator is missing or the string fills the entire `bleft` space. This prevents `kmalloc` from allocating `bleft + 1` bytes and `memcpy` from reading `bleft` bytes when `len == bleft`, which would imply the string is not null-terminated within the buffer. The logic correctly bounds the allocation and copy sizes to the available `bleft` bytes.

sess_auth_rawntlmssp_authenticate() — fs/smb/client/smb1session.c FP confidence=high

The `sess_auth_rawntlmssp_authenticate` function performs initial validation of server-supplied lengths, specifically `blob_len` against `bytes_remaining`. The `bytes_remaining` value is then decremented and passed to `decode_ascii_ssetup` (as `bleft`) representing the actual remaining buffer size. Inside `decode_ascii_ssetup`, every string parsing operation uses `strnlen(bcc_ptr, bleft)` to determine string length (`len`), and crucially, includes a check `if (len >= bleft) return;`. This ensures that any string being processed is either null-terminated within the provided `bleft` bounds, or the function returns early, preventing out-of-bounds reads during `strnlen` and subsequent `kmalloc` and `memcpy` operations. The `kmalloc` size is `len + 1`, which is guaranteed to be `<= bleft` due to the `len < bleft` postcondition. This validation chain is robust and sufficient.

Finding #1 — Category B — cross-function via decode_ascii_ssetup() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 879
Taint snippetblob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
Tainted varbcc_ptr
Call siteline 902 — passes bcc_ptr to decode_ascii_ssetup()
Call snippetdecode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
Sink (in callee)kmalloc() line 270 (arg 0, role=size_mul_overflow)
Sink snippetses->serverOS = kmalloc(len + 1, GFP_KERNEL);
Possibly guardedyes (heuristic)
Dismissed: The taint source `le16_to_cpu(pSMB->resp.SecurityBlobLength)` on line 879 is indeed server-supplied. This `blob_len` value is checked against `bytes_remaining` on line 880 (`if (blob_len > bytes_remaining)`), and `bytes_remaining` is then correctly decremented. The `bcc_ptr` (passed by reference as `pbcc_area`) and the updated `bytes_remaining` (passed as `bleft`) are sent to `decode_ascii_ssetup`. The scanner misidentifies `bcc_ptr` as a 'size/length' argument, whereas it is a pointer to the data. The actual length used for `kmalloc` is `len + 1`, where `len` comes from `strnlen(bcc_ptr, bleft)`. The `decode_ascii_ssetup` function includes a robust check `if (len >= bleft) return;` (line 265), which ensures that `len` is always strictly less than `bleft`. Therefore, `len + 1` will be at most `bleft`, making the `kmalloc` (line 270) and subsequent `memcpy` (line 272) operations safe within the `bleft` bounds. No counterexample leads to OOB. This is a false positive due to the scanner's interpretation of `bcc_ptr` as a size argument, rather than considering the actual `len` derived from `strnlen` and its associated bounds check.

Finding #2 — Category B — cross-function via decode_ascii_ssetup() — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcele16_to_cpu() line 879
Taint snippetblob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
Tainted varbytes_remaining
Call siteline 902 — passes bytes_remaining to decode_ascii_ssetup()
Call snippetdecode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
Sink (in callee)kmalloc() line 270 (arg 0, role=size_mul_overflow)
Sink snippetses->serverOS = kmalloc(len + 1, GFP_KERNEL);
Possibly guardedyes (heuristic)
Dismissed: The taint source `le16_to_cpu(pSMB->resp.SecurityBlobLength)` on line 879 is server-supplied. This `blob_len` is used to decrement `bytes_remaining` (line 887) after being validated against the initial `bytes_remaining` (line 880). The `bytes_remaining` value passed to `decode_ascii_ssetup` (as `bleft`) is thus a properly bounded, remaining length of the buffer. Inside `decode_ascii_ssetup`, the `kmalloc` (line 270) argument `len + 1` is derived from `len = strnlen(bcc_ptr, bleft)`. The critical check `if (len >= bleft) return;` (line 265) ensures that `len` is always strictly less than `bleft` before the `kmalloc` and `memcpy` operations. This makes `len + 1` at most `bleft`. This robust validation ensures that `kmalloc` and `memcpy` (lines 270, 272, 287, 289) do not cause OOB access. Similar logic is applied for the second string. The final check `if (len > bleft)` on line 297 is effectively `if (false)` given `strnlen`'s behavior (it returns at most `bleft`), but does not introduce a vulnerability. No counterexample (e.g., `bleft=10`, string 'ABCDEFGHIJ' (10 chars, no null) -> `strnlen` returns 10 -> `10 >= 10` is true -> return) leads to OOB. This is a false positive.

coalesce_t2() — fs/smb/client/smb1transport.c FP confidence=high

The `coalesce_t2` function explicitly implements bounds checks for both the source and destination buffers before performing the `memcpy` operation. The code comments indicate awareness of the server-supplied nature of the `DataOffset` fields and the need for validation. The checks cover both lower bounds (preventing pointers into the header) and upper bounds (preventing writes/reads beyond the allocated or logical end of the PDU/buffer) by incorporating the length of the data to be copied (`total_in_src`). The reliance on `smbCalcSize` for the source buffer's end is standard; this value is expected to be validated against the actual received buffer length in upstream network receive logic.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia get_unaligned_le16() line 370
Taint snippettotal_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
Tainted vartotal_in_src
Sinkmemcpy() line 435 (arg 2, role=size)
Sink snippetmemcpy(data_area_of_tgt, data_area_of_src, total_in_src);
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 `total_in_src` value, which dictates the size of the `memcpy` operation, is adequately bounded against both the source buffer (`second_buf`) and the destination buffer (`target_hdr`). - **Source buffer check (OOB read prevention)**: `data_area_of_src + total_in_src > second_buf + smbCalcSize(...)` (lines 397-398). This ensures that reading `total_in_src` bytes from `data_area_of_src` does not exceed the valid data range of `second_buf` as defined by `smbCalcSize`. - **Destination buffer check (OOB write prevention)**: `data_area_of_tgt + total_in_src > (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` (lines 390-391). This ensures that writing `total_in_src` bytes to `data_area_of_tgt` does not exceed the maximum allowed size of the `target_hdr` buffer. - The `total_in_src` is an `__u16` and thus non-negative. The SMT result confirms it's not negative. Counterexample test: If `total_in_src` was crafted to cause an OOB read, e.g., `smbCalcSize` is 1000, `data_area_of_src` points to `second_buf + 990`, and `total_in_src` is 20, then `990 + 20 = 1010 > 1000`, which triggers the check at line 397 and returns `-EPROTO`. If `total_in_src` was crafted to cause an OOB write, e.g., `CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` is 4096, `data_area_of_tgt` points to `target_hdr + 4080`, and `total_in_src` is 20, then `4080 + 20 = 4100 > 4096`, which triggers the check at line 390 and returns `-EPROTO`. Both cases are properly guarded.

Finding #2 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourceget_unaligned_le16() line 375
Taint snippetdata_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
Tainted vardata_area_of_tgt
Sinkmemcpy() line 435 (arg 0, role=pointer)
Sink snippetmemcpy(data_area_of_tgt, data_area_of_src, total_in_src);
Possibly guardedyes (heuristic)
Dismissed: The `data_area_of_tgt` pointer, derived from a server-supplied `DataOffset` and `DataCount` from `target_hdr`, is validated before use as the destination of `memcpy`. - **Lower bound check**: `data_area_of_tgt < (char *)target_hdr + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (lines 388-389). This prevents `data_area_of_tgt` from pointing to sensitive header areas. - **Upper bound check**: `data_area_of_tgt + total_in_src > (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` (lines 390-391). This ensures the `memcpy` operation does not write past the allocated buffer. This check implicitly validates the `data_area_of_tgt`'s starting position in conjunction with the length. Counterexample test: If `DataOffset` from `pSMBt` (used to calculate `data_area_of_tgt`) was `0x0` and `total_in_tgt` was small, `data_area_of_tgt` might point to `target_hdr + sizeof(smb_hdr) + sizeof(struct smb_com_transaction_hdr)`. If this computed address is less than `target_hdr + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (e.g., `sizeof(struct smb_t2_rsp)` is 60 and this evaluated to 40), the check at line 388 would catch it. If `DataOffset` was such that `data_area_of_tgt` points very late in the buffer (e.g., `target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 100`) and `total_in_src` is `200`, the sum `data_area_of_tgt + total_in_src` would exceed the buffer end, triggering the check at line 390. Both bounds are properly enforced.

Finding #3 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourceget_unaligned_le16() line 378
Taint snippetdata_area_of_src = (char *)&pSMBs->hdr.Protocol +
Tainted vardata_area_of_src
Sinkmemcpy() line 435 (arg 1, role=pointer)
Sink snippetmemcpy(data_area_of_tgt, data_area_of_src, total_in_src);
Possibly guardedyes (heuristic)
Dismissed: The `data_area_of_src` pointer, derived from a server-supplied `DataOffset` from `second_buf`, is validated before use as the source of `memcpy`. - **Lower bound check**: `data_area_of_src < second_buf + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (lines 395-396). This prevents `data_area_of_src` from pointing to sensitive header areas within the source buffer. - **Upper bound check**: `data_area_of_src + total_in_src > second_buf + smbCalcSize((struct smb_hdr *)second_buf)` (lines 397-398). This ensures the `memcpy` operation does not read past the logical end of the SMB PDU in `second_buf`. This check implicitly validates `data_area_of_src`'s starting position in conjunction with the length. Counterexample test: Similar to finding #2, if `DataOffset` from `pSMBs` was `0x0`, `data_area_of_src` would point into the header of `second_buf`. If this calculated address is less than `second_buf + sizeof(struct smb_t2_rsp) + sizeof(__le16)`, the check at line 395 would catch it. If `DataOffset` was such that `data_area_of_src` points very late in the `second_buf` (e.g., `second_buf + smbCalcSize(...) - 100`) and `total_in_src` is `200`, the sum `data_area_of_src + total_in_src` would exceed the logical end of the PDU, triggering the check at line 397. Both bounds are properly enforced.
The function `symlink_data` parses a variable-length list of SMB2 error contexts. It iterates through these contexts, advancing a pointer `p` based on server-supplied lengths. The static analysis flagged the advance of `p` using `len` (derived from `p->ErrorDataLength`). However, thorough bounds checks are present to ensure that the `len` bytes for the current error context, and thus the starting point for the next `p`, remain within the received buffer.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 64
Taint snippetlen = le32_to_cpu(p->ErrorDataLength);
Tainted varp
Pointer derefp->ErrorContextData line 71
Sink snippetp = (struct smb2_error_context_rsp *)(p->ErrorContextData + len);
Possibly guardedyes (heuristic)
Dismissed: The `len` variable is derived from `le32_to_cpu(p->ErrorDataLength)`, which is server-supplied. The pointer `p` is then advanced using this `len` at line 71. However, before this advance, two critical bounds checks are performed (lines 65 and 68): `if (len > end - ((u8 *)p + sizeof(*p)))` This check ensures that the `len` bytes (which follow the fixed header of the current `p`) do not extend beyond the `end` of the buffer. Specifically, it establishes the postcondition: `(u8 *)p + sizeof(*p) + len <= end`. The new pointer `p` is calculated as `(struct smb2_error_context_rsp *)(p->ErrorContextData + len)`. The `ErrorContextData` field in `struct smb2_error_context_rsp` is declared as `u8 ErrorContextData[1]`, which typically means the variable data starts immediately after the fixed fields (ErrorId, ErrorContextType, ErrorDataLength). Thus, `p->ErrorContextData` is at `(u8 *)p + offsetof(struct smb2_error_context_rsp, ErrorContextData)`. From `smb2pdu.h`, `sizeof(struct smb2_error_context_rsp)` is `12` (for 3 `__le32` fields) + `1` (for `ErrorContextData[1]`) = `13` bytes. `offsetof(struct smb2_error_context_rsp, ErrorContextData)` is `12` bytes. So, the new `p` will be `(u8 *)p_old + 12 + len`. The bounds check `(u8 *)p_old + sizeof(*p_old) + len <= end` simplifies to `(u8 *)p_old + 13 + len <= end`. Since the new `p` is advanced by `12 + len`, and `12 + len < 13 + len`, the new `p` is guaranteed to be strictly less than or equal to `end`. Furthermore, in the subsequent loop iteration, the `while` condition `((u8 *)p + sizeof(*p) <= end)` (line 56) will re-validate the *new* `p` before any of its fields are accessed. If the `new p` (plus its fixed header) does not fit within `end`, the loop terminates gracefully. Therefore, all accesses to `p` and its fields are protected.

check_wsl_eas() — fs/smb/client/smb2inode.c FP confidence=high

The `check_wsl_eas()` function implements robust bounds checking for parsing SMB2 WSL Extended Attributes. It performs checks at multiple levels: 1. Overall length validation (`outlen`) against predefined min/max sizes. 2. Verification that the entire block of EA data (`ea` to `ea + outlen`) fits within the received network buffer (`rsp_iov->iov_len`). 3. Inside the loop, it validates that each EA entry header (`sizeof(*ea)`) fits within the remaining `outlen`. 4. It strictly enforces `ea_name_length` (`nlen`) to be a specific constant (`SMB2_WSL_XATTR_NAME_LEN`). 5. It validates that the combined length of the name, null terminator, and value (`nlen + 1 + vlen`) fits within the `ea_end` boundary. These layered checks ensure that all subsequent accesses to `ea` fields and data are within the bounds of the received buffer.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 135
Taint snippetea = (void *)((u8 *)rsp_iov->iov_base +
Tainted varea
Pointer derefea->ea_name_length line 146
Sink snippetnlen = ea->ea_name_length;
Possibly guardedyes (heuristic)
Dismissed: The pointer `ea` is derived from `rsp->OutputBufferOffset` which is server-supplied. However, several checks ensure its safety: 1. Line 139: `if (ea_end > iov_end)` ensures that the entire block of EA data, defined by `ea` and `outlen`, fits within the actual received network buffer (`iov_len`). This means `(u8 *)rsp_iov->iov_base + OutputBufferOffset + outlen <= (u8 *)rsp_iov->iov_base + rsp_iov->iov_len`. 2. Line 143: `if ((u8 *)ea > ea_end - sizeof(*ea))` checks if there is sufficient space for the fixed part of the `smb2_file_full_ea_info` structure (`sizeof(*ea)`) at the current `ea` pointer position. This implies `outlen >= sizeof(*ea)` for the loop to continue. Together, these two checks guarantee that `ea + sizeof(*ea)` is within the bounds of the actual received `rsp_iov` buffer before any dereference of `ea` occurs (e.g., `ea->ea_name_length` at line 146). No counterexample can bypass these guards to cause an OOB read of the fixed `ea` fields.

Finding #2 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 146
Taint snippetnlen = ea->ea_name_length;
Tainted varnlen
Sinkstrncmp() line 154 (arg 2, role=size)
Sink snippetif (strncmp(ea->ea_data, SMB2_WSL_XATTR_UID, nlen) &&
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 `nlen` variable is derived from `ea->ea_name_length`, which is server-supplied. 1. Line 149: `if (nlen != SMB2_WSL_XATTR_NAME_LEN || ...)` is a strong validation. It requires `nlen` to be precisely `SMB2_WSL_XATTR_NAME_LEN` (a small constant, 23). If `nlen` is any other value, the function returns -EINVAL. This effectively bounds the size argument to `strncmp` to a known, safe constant. 2. The second part of the check at line 149: `(u8 *)ea->ea_data + nlen + 1 + vlen > ea_end` ensures that the entire name string (including its null terminator and value) fits within the `ea_end` boundary. Since `nlen` is now fixed to `SMB2_WSL_XATTR_NAME_LEN`, this guarantees that the source buffer for `strncmp` (`ea->ea_data`) has at least `SMB2_WSL_XATTR_NAME_LEN` bytes available within the `ea_end` boundary, which itself is validated against `iov_end` (as per Finding #1). Given these checks, `strncmp` will always be called with a constant, valid length (23), and the source buffer (`ea->ea_data`) is guaranteed to be large enough. The SMT result 'PROVED - negative' confirms `nlen` won't be negative, which is also desirable for a length argument. Counterexample test: If `nlen` is, say, 100, the check `nlen != SMB2_WSL_XATTR_NAME_LEN` would cause an early exit at line 149, preventing the call to `strncmp`. If `nlen` is 23, but `ea->ea_data` is too short, the second part of the check at line 149 `(u8 *)ea->ea_data + nlen + 1 + vlen > ea_end` would catch this, again causing an early exit.

parse_posix_sids() — fs/smb/client/smb2inode.c BUG confidence=high

The `parse_posix_sids` function correctly validates server-supplied offsets and lengths against the received network buffer (`rsp_iov->iov_len`). The `posix_info_sid_size` helper also correctly checks that the extracted SID fits within the provided portion of the network buffer. However, the destination buffers for `memcpy` operations (`data->posix_owner` and `data->posix_group`) are `struct cifs_sid`. According to `fs/cifs/cifsglob.h`, `struct cifs_sid` is defined with a single `u32 sub_authority[1]`, making its size 12 bytes. A valid SID, however, can contain up to 15 sub-authorities, leading to a maximum size of 68 bytes. This discrepancy creates an out-of-bounds write when copying larger SIDs into the fixed-size `struct cifs_sid` fields.

Finding #1 — Category B — BUG oob_write

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 78
Taint snippetsidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;
Tainted varowner_len
Sinkmemcpy() line 96 (arg 2, role=size)
Sink snippetmemcpy(&data->posix_owner, sidsbuf, owner_len);
Possibly guardedyes (heuristic)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic, KASAN: slab-out-of-bounds, heap/stack corruption.
Fix: Add a check before `memcpy` to ensure `owner_len` does not exceed the size of the destination buffer: `if (owner_len > sizeof(data->posix_owner)) return -EINVAL;`. This would typically be `if (owner_len > 12) return -EINVAL;` assuming `sizeof(data->posix_owner)` is 12. A more robust solution might involve redefining `struct cifs_sid` fields in `struct smb2_posix_info_v1` to accommodate maximum SID size (e.g., `char OwnerSidBuf[CIFS_MAX_SID_SIZE];`) or using dynamic allocation for SIDs if they are intended to be variable-length.
CVE pattern: OOB write to fixed-size struct field

Finding #2 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 78
Taint snippetsidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;
Tainted varsidsbuf
Sinkmemcpy() line 96 (arg 1, role=pointer)
Sink snippetmemcpy(&data->posix_owner, sidsbuf, owner_len);
Possibly guardedyes (heuristic)
Dismissed: The `sidsbuf` pointer is derived from `qi->OutputBufferOffset` and `qi_len`. The `sidsbuf_end` pointer is derived from `sidsbuf` and `qi->OutputBufferLength`. Line 85-90 correctly validate that `sidsbuf_end` does not exceed the actual received buffer `rsp_iov->iov_base + rsp_iov->iov_len`. The `posix_info_sid_size` function further ensures that `owner_len` bytes starting from `sidsbuf` fit within `sidsbuf` and `sidsbuf_end`. Therefore, the source buffer for `memcpy` is correctly bounded, preventing OOB reads. No counterexample found that causes OOB read from the source.

Finding #3 — Category B — BUG oob_write

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 78
Taint snippetsidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;
Tainted vargroup_len
Sinkmemcpy() line 101 (arg 2, role=size)
Sink snippetmemcpy(&data->posix_group, sidsbuf + owner_len, group_len);
Possibly guardedyes (heuristic)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic, KASAN: slab-out-of-bounds, heap/stack corruption.
Fix: Add a check before `memcpy` to ensure `group_len` does not exceed the size of the destination buffer: `if (group_len > sizeof(data->posix_group)) return -EINVAL;`. This would typically be `if (group_len > 12) return -EINVAL;` assuming `sizeof(data->posix_group)` is 12. Similar to finding #1, a more robust solution might be needed for the struct definition.
CVE pattern: OOB write to fixed-size struct field

Finding #4 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 78
Taint snippetsidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;
Tainted varsidsbuf
Sinkmemcpy() line 101 (arg 1, role=pointer)
Sink snippetmemcpy(&data->posix_group, sidsbuf + owner_len, group_len);
Possibly guardedno
Dismissed: Similar to finding #2, the `sidsbuf` pointer, offset by `owner_len`, is correctly bounded against the source `rsp_iov` buffer. The `posix_info_sid_size` calls ensure that `owner_len` and `group_len` collectively do not exceed the `sidsbuf` to `sidsbuf_end` range, which is itself validated. Therefore, the source buffer for the second `memcpy` is correctly bounded, preventing OOB reads. No counterexample found that causes OOB read from the source.

reparse_buf_ptr() — fs/smb/client/smb2inode.c FP confidence=high

The `reparse_buf_ptr` function implements a series of robust bounds checks to ensure safe access to the `reparse_data_buffer` structure and its fields. 1. Line 38 validates that the entire reported reparse data segment (`OutputOffset + OutputCount`) fits within the actual received buffer (`iov->iov_len`). This ensures that `buf` (derived from `OutputOffset`) and the overall reported data range are within `iov->iov_len`. 2. Line 44-45 validates that the reported `OutputCount` is at least the size of the `reparse_data_buffer` header (`sizeof(*buf)`). This ensures that the fixed header, including `ReparseDataLength`, is fully present in the buffer segment. 3. Line 48-49 validates that `OutputCount` is sufficient to cover `ReparseDataLength` plus the size of the fixed header. This ensures the reported variable-length data also fits. Together, these checks prevent OOB reads for `buf->ReparseDataLength` and other fields within the `reparse_data_buffer` header.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 37
Taint snippetoff = le32_to_cpu(io->OutputOffset);
Tainted varbuf
Pointer derefbuf->ReparseDataLength line 47
Sink snippetrdlen = le16_to_cpu(buf->ReparseDataLength);
Possibly guardedno
Dismissed: The taint source `io->OutputOffset` (line 37) and `io->OutputCount` (line 36) are derived from `iov->iov_base`, which is the received `smb2_ioctl_rsp` buffer, making them genuinely server-supplied. The `ReparseDataLength` field is also read from `buf`, which points into this server-supplied buffer. The bounds checks are sufficient: 1. `if (check_add_overflow(off, count, &len) || len > iov->iov_len)` on line 38 ensures that the total region described by `off + count` (where `off` is `OutputOffset` and `count` is `OutputCount`) does not exceed the actual buffer size `iov->iov_len`. This implies `off + count <= iov->iov_len`. 2. `if (count < len)` on line 44-45 (where `len` has been reassigned to `sizeof(*buf)`) ensures that `OutputCount` is at least `sizeof(struct reparse_data_buffer)`. Combining these two: We have `off + count <= iov->iov_len` and `count >= sizeof(struct reparse_data_buffer)`. Therefore, `off + sizeof(struct reparse_data_buffer) <= off + count <= iov->iov_len`. This guarantees that the entire `reparse_data_buffer` structure (pointed to by `buf`) fits within the `iov->iov_len` buffer, starting at `off`. Thus, accessing `buf->ReparseDataLength` (which is at an offset within `sizeof(struct reparse_data_buffer)`) is safe. Counterexample test: - `iov->iov_len = 100` - `io->OutputOffset = 90` (so `off = 90`) - `io->OutputCount = 5` (so `count = 5`) - Assume `sizeof(struct reparse_data_buffer) = 8` bytes. Path execution: 1. `check_add_overflow(90, 5, &len)` -> `len = 95`. No overflow. 2. `len > iov->iov_len` -> `95 > 100` is false. This check passes. 3. `buf = (struct reparse_data_buffer *)((u8 *)io + 90);` 4. `len = sizeof(*buf);` -> `len = 8`. 5. `if (count < len)` -> `if (5 < 8)` is true. The function returns `ERR_PTR(-EIO)`. The OOB read is prevented. If we adjust `io->OutputCount = 8`: 1. `check_add_overflow(90, 8, &len)` -> `len = 98`. No overflow. 2. `len > iov->iov_len` -> `98 > 100` is false. This check passes. 3. `buf` points to `io + 90`. This is within `iov_len` because `90 + 8 = 98 <= 100`. 4. `len = 8`. 5. `if (count < len)` -> `if (8 < 8)` is false. This check passes. 6. `rdlen = le16_to_cpu(buf->ReparseDataLength);` -> This read is safe as `buf` and `sizeof(*buf)` are within `iov_len`. 7. `if (count < rdlen + len)`: This check still exists for the *entire* reparse data (header + data). If `rdlen` were large enough to cause OOB (e.g., `rdlen = 10`, so `rdlen + len = 18`), then `if (8 < 18)` would be true, and the function would return `ERR_PTR(-EIO)`. Thus, even the variable-length part is guarded against.

smb2_compound_op() — fs/smb/client/smb2inode.c FP confidence=high

The function `smb2_validate_and_copy_iov` is designed to perform validation before copying data. It explicitly calls `smb2_validate_iov` with the tainted offset and length parameters. The `memcpy` sink occurs *after* this validation call, meaning the bounds checks are present and sufficient, provided `smb2_validate_iov` performs its intended function. This is a standard pattern for a secure validation-and-copy helper.

Finding #1 — Category A — cross-function via smb2_validate_and_copy_iov() — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 625
Taint snippetrc = smb2_validate_and_copy_iov(
Tainted varle16_to_cpu(qi_rsp->OutputBufferOffset)
Call siteline 625 — passes le16_to_cpu(qi_rsp->OutputBufferOffset) to smb2_validate_and_copy_iov()
Call snippetrc = smb2_validate_and_copy_iov(
Sink (in callee)memcpy() line 3900 (arg 1, role=pointer)
Sink snippetmemcpy(data, begin_of_buf, minbufsize);
Possibly guardedno
Dismissed: The tainted value `qi_rsp->OutputBufferOffset` is read from a server response, making it genuinely server-supplied. However, the sink is inside `smb2_validate_and_copy_iov()`, which is a helper function whose primary purpose is to validate and then copy. It calls `smb2_validate_iov(offset, buffer_length, iov, minbufsize)` *before* performing the `memcpy`. The name and parameters of `smb2_validate_iov` indicate it performs the necessary bounds checks for `offset` and `buffer_length` against the provided `iov` buffer. Therefore, the `memcpy` is protected by this explicit validation step. This aligns with false positive pattern #4 (Callee-internal validation) and #2 (Validation call chains). No counterexample can be constructed where `smb2_validate_iov` returns success but the `memcpy` is OOB, assuming `smb2_validate_iov` correctly implements its validation logic.

smb2_check_message() — fs/smb/client/smb2misc.c FP confidence=high

The function `smb2_check_message` performs extensive validation on the incoming SMB2 message header. The specific finding related to array indexing of `smb2_rsp_struct_sizes` is protected by an explicit bounds check immediately after the `command` field is extracted from the header.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 222
Taint snippetcommand = le16_to_cpu(shdr->Command);
Tainted varcommand
Subscript[] line 248
Sink snippetif (smb2_rsp_struct_sizes[command] != pdu->StructureSize2) {
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 `command` variable, derived from `shdr->Command` (a server-supplied value), is used as an array subscript for `smb2_rsp_struct_sizes`. However, there is a clear bounds check at lines 224-226: `if (command >= NUMBER_OF_SMB2_COMMANDS) { return 1; }`. This check ensures that `command` is always a valid index for `smb2_rsp_struct_sizes`, which is defined with a size of `NUMBER_OF_SMB2_COMMANDS`. The SMT result 'PROVED — negative: signed value cannot be negative' is also consistent, as `command` is derived from an unsigned 16-bit value, making it non-negative. No counterexample can be constructed where `command` would be out of bounds for the array after passing this check. For example, if `command` were `NUMBER_OF_SMB2_COMMANDS`, the check at line 224 would return 1. If `command` were `NUMBER_OF_SMB2_COMMANDS - 1` (the maximum valid index), it would pass the check and be a valid access. If `command` were `0`, it would pass and be a valid access.

smb2_tcon_find_pending_open_lease() — fs/smb/client/smb2misc.c BUG confidence=high

The code silently truncates a 32-bit server-supplied value to an 8-bit integer, which can lead to incorrect state management and data interpretation. No explicit masking or validation ensures the 32-bit value fits within 8 bits.

Finding #1 — Category H — BUG integer_overflow

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele32_to_cpu() line 625
Taint snippet__u8 lease_state = le32_to_cpu(rsp->NewLeaseState);
Tainted varlease_state
Truncationline 625: 32 → 8-bit __u8
Sink snippet__u8 lease_state = le32_to_cpu(rsp->NewLeaseState);
Possibly guardedno
SMTwitness: truncation fails here — 32-bit value does not survive 8 bits (a scenario, not a claim that a caller produces it)
SMT witnessle32_to_cpu_val=0xffffff00, value=0xffffff00
SMT witness (LLM)reachable — see notes
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Incorrect lease state management leading to protocol inconsistencies, potentially affecting caching behavior and data integrity (e.g., stale data being read from cache or unnecessary cache misses).
Fix: Change the `oplock` field in `struct cifs_pending_open` from `unsigned char` (or `__u8`) to `__u32` to accommodate the full 32-bit `NewLeaseState` value provided by the server. Alternatively, if the protocol strictly guarantees that `NewLeaseState` will always fit within 8 bits, add an explicit mask like `(le32_to_cpu(rsp->NewLeaseState) & 0xFF)` to make the truncation intentional and clear.
CVE pattern: SMB protocol field truncation leading to logic error

smb2_tcon_has_lease() — fs/smb/client/smb2misc.c BUG confidence=high

The function processes a server-supplied SMB2 lease break response. The core issue is the silent truncation of a 32-bit server-provided lease state into an 8-bit local variable, which is then stored into an 8-bit struct field. This data loss can lead to misinterpretation of the lease state.

Finding #1 — Category H — BUG info_disclosure

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele32_to_cpu() line 591
Taint snippetlease_state = le32_to_cpu(rsp->NewLeaseState);
Tainted varlease_state
Truncationline 591: 32 → 8-bit u8
Sink snippetlease_state = le32_to_cpu(rsp->NewLeaseState);
Possibly guardedno
SMTwitness: truncation fails here — 32-bit value does not survive 8 bits (a scenario, not a claim that a caller produces it)
SMT witnessle32_to_cpu_val=0xffffff00, value=0xffffff00
SMT witness (LLM)reachable — see notes
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Incorrect caching behavior, misinterpretation of lease states, potential data integrity issues or unexpected file access behavior due to incorrect state. Not necessarily a crash, but functional incorrectness.
Fix: Change `cfile->oplock_level` (and `lease_state` in this function) from `__u8` to `__u32` to accommodate the full 32-bit `NewLeaseState` from the server. If only specific bits of `NewLeaseState` are ever relevant for `oplock_level`, then an explicit mask should be applied: `lease_state = (u8)(le32_to_cpu(rsp->NewLeaseState) & LEASE_STATE_MASK);` where `LEASE_STATE_MASK` is a constant representing the valid 8-bit range. However, without such a mask, the silent truncation is problematic given the protocol field's width.
CVE pattern: Silent truncation of server-supplied protocol field leading to misinterpretation of state

crypt_message() — fs/smb/client/smb2ops.c FP confidence=high

The static analysis finding misinterprets the C syntax, incorrectly identifying the `int` return value `rc` as the target of a truncation from a `u64` argument. The `u64` value `tr_hdr->SessionId` is passed as an argument to `smb2_get_enc_key`, and `rc` receives the `int` return code of that function, not the `SessionId` itself. Therefore, the stated truncation does not occur.

Finding #1 — Category H — false positive

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele64_to_cpu() line 4838
Taint snippetrc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key);
Tainted varrc
Truncationline 4838: 64 → 32-bit u32
Sink snippetrc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key);
Possibly guardedno
Dismissed: The finding incorrectly states that `rc` (an `int`) is the destination of a truncation from `le64_to_cpu(tr_hdr->SessionId)` (a `u64`). In the line `rc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key);`, `rc` is assigned the return value of `smb2_get_enc_key`, which is an `int`. The `u64` value `le64_to_cpu(tr_hdr->SessionId)` is passed as an argument to `smb2_get_enc_key`, not assigned to `rc`. Therefore, the premise of the finding (truncation into `rc`) is false. The `SessionId` itself can be server-supplied when `crypt_message` is called from `decrypt_raw_data`.

move_smb2_ea_to_cifs() — fs/smb/client/smb2ops.c FP confidence=high

The function `move_smb2_ea_to_cifs` processes a sequence of SMB2 Extended Attribute (EA) entries. It correctly validates both the input (server-supplied EA data) and the output (destination buffer for copying EA values or names) against potential out-of-bounds accesses. The checks for `src_size` and `dst_size` are thorough and prevent overflows.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 1060
Taint snippetvalue_len = (size_t)le16_to_cpu(src->ea_value_length);
Tainted varvalue_len
Sinkmemcpy() line 1085 (arg 2, role=size)
Sink snippetmemcpy(dst, value, value_len);
Possibly guardedyes (heuristic)
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `value_len` is indeed server-supplied, derived from `src->ea_value_length` which comes from a network response. However, there are sufficient bounds checks in place: 1. **Source Buffer Read (OOB read of `value`):** The check at line 1065 (`if (src_size < 8 + name_len + 1 + value_len)`) validates that the entire current EA entry, including its 8-byte fixed header, `name_len` (name length), 1-byte null terminator, and `value_len` (value length), fits within the remaining server-supplied buffer (`src_size`). If this check fails, the function returns an error, preventing the `memcpy` at line 1085 from reading past the end of the `src` buffer. For example, if `src_size = 100` and `value_len = 0xFFFF`, the condition `100 < 8 + name_len + 1 + 0xFFFF` would be true, leading to an early exit and preventing the OOB read. 2. **Destination Buffer Write (OOB write to `dst`):** The check at line 1081 (`if (dst_size < value_len)`) explicitly compares the remaining destination buffer size (`dst_size`) with the `value_len`. If `dst_size` is insufficient, it sets `rc = -ERANGE` and exits, preventing the `memcpy` at line 1085 from writing past the end of the `dst` buffer. For example, if `dst_size = 100` and `value_len = 0xFFFF`, the condition `100 < 0xFFFF` would be true, leading to an early exit and preventing the OOB write. Both the source and destination buffer accesses are adequately guarded against the server-supplied `value_len`.

parse_server_interfaces() — fs/smb/client/smb2ops.c FP confidence=high

The `parse_server_interfaces` function iterates through a linked list of structures within a server-provided buffer. The pointer `p` is advanced by the `Next` field of the current structure. This `Next` value is validated at line 788 (`if (next < sizeof(*p) || next > bytes_left)`), which ensures that the `next` offset is both greater than or equal to the size of a full structure and does not exceed the remaining buffer length. This validation ensures that `p` always points to a valid location within the original buffer after being advanced. The specific dereference flagged at line 807 (`p->Next`) occurs after the loop has terminated. At this point, `p` points to the last structure that was successfully processed (or to the initial `buf` if no structures were processed). The `Next` field of this `p` would have already been read at line 782 in the last iteration of the loop. If that read was an OOB, the program would have crashed earlier. Assuming the initial buffer `buf` has at least 4 bytes (to safely read `p->Next` at line 782), and `next` values were validated, then `p` at line 807 is a valid pointer within bounds, and `p->Next` is a safe access.

Finding #1 — Category E — false positive

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 782
Taint snippetnext = le32_to_cpu(p->Next);
Tainted varp
Pointer derefp->Next line 807
Sink snippet+ sizeof(p->Next) && p->Next))
Possibly guardedno
Dismissed: The pointer `p` is initially set to `buf`, which comes from the server via `SMB2_ioctl`. Subsequent advancements of `p` are based on `p->Next`, which is server-supplied. Thus, `p` is tainted. The dereference `p->Next` at line 807 is accessing the `Next` field of the last `network_interface_info_ioctl_rsp` structure in the buffer that was processed by the loop. The loop's advancement of `p` (line 794) is guarded by the check at line 788: `if (next < sizeof(*p) || next > bytes_left)`. This check ensures that `next` (the value of `p_old->Next`) is a valid offset: it must be at least `sizeof(*p)` (lower bound for valid next structure) and not exceed `bytes_left` (upper bound of the buffer). If the loop terminates because `p->Next` was 0 (line 783), then `p` points to the last valid structure, and `bytes_left` is adjusted (line 784). The `p->Next` at line 807 will be 0, making the `&& p->Next` part of the condition false, so the `cifs_dbg` message is skipped and no dereference happens at that line for the `cifs_dbg` argument. If the loop terminates due to an invalid `next` value (line 788), then `rc` is set and `goto out` is triggered (line 792), so line 807 is not reached. The only potential OOB for `p->Next` is at line 782, for the *first* iteration, if the initial `buf_len` (from `ret_data_len`) is less than `sizeof(p->Next)` (i.e., less than 4 bytes). If `buf_len` is less than 4, the read `le32_to_cpu(p->Next)` at line 782 would be an OOB. However, this specific finding flags line 807. The logic ensures that if line 807 is reached, `p` is a valid pointer to a structure within the buffer, and `p->Next` is a safe access. **Counterexample Test (for line 807):** Assume `sizeof(struct network_interface_info_ioctl_rsp)` = 64 bytes. Case 1: `buf_len = 10` (too small for one full struct). - `p = buf`, `bytes_left = 10`. - Line 782: `next = le32_to_cpu(p->Next);` (reads `buf[0..3]`, safe as `10 >= 4`). Assume `next = 0`. - Line 783: `!next` is true. `bytes_left -= sizeof(*p)` becomes `10 - 64` (wraps to large `size_t`). `break`. - After loop: `nb_iface` is 0. Line 798 `if (!nb_iface)` is true, `goto out;`. Line 807 is NOT reached. Case 2: `buf_len = 128` (two full structs). - `p = buf`, `bytes_left = 128`. - Iteration 1: `p->Next` (from `buf[0..3]`) is 64. `next = 64`. - `next` passes check at 788 (`64 < 64` false, `64 > 128` false). - `p` advances to `buf+64`. `bytes_left = 128-64=64`. `nb_iface=1`. - Iteration 2: `p->Next` (from `buf[64..67]`) is 0. `next = 0`. - `!next` is true. `bytes_left = 64-64=0`. `break`. - After loop: `nb_iface=1` (not 0). Line 798 is false. - Line 805: `if ((bytes_left > 8) || (bytes_left >= 4 && p->Next))`. Here, `bytes_left=0`, `p->Next=0`. Condition becomes `(0 > 8 || (0 >= 4 && 0))` which is `(false || (false && false))` -> `false`. `cifs_dbg` at line 808 is skipped. - In both scenarios where line 807 is reached, the access to `p->Next` is safe or avoided by the condition.

receive_encrypted_standard() — fs/smb/client/smb2ops.c FP confidence=high

The function `receive_encrypted_standard` processes SMB2 encrypted compound messages. The `next_cmd` field, indicating the offset to the next command in a compound message, is carefully validated against the current PDU's length (`pdu_length`) before being used as an offset for `memcpy`. The destination buffer for `memcpy` is also dynamically chosen to be sufficiently large based on the overall PDU length.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le32_to_cpu() line 5464
Taint snippetnext_cmd = le32_to_cpu(shdr->NextCommand);
Tainted varnext_cmd
Sinkmemcpy() line 5490 (arg 2, role=size)
Sink snippetmemcpy(next_buffer, buf + next_cmd, pdu_length - next_cmd);
Possibly guardedyes (heuristic)
SMTproved negative — value is unsigned at the sink (proof covers every unresolved value; it answers only this property)
Dismissed: The `next_cmd` value is extracted from the server-supplied `smb2_hdr` via `le32_to_cpu`, making it server-supplied. However, it is subject to several bounds checks before being used in the `memcpy` operation. **Source buffer bounds check (buf + next_cmd):** 1. The `if (next_cmd)` block (line 5472) ensures that if `next_cmd` is zero, the `memcpy` is skipped, preventing an invalid offset. If `next_cmd` is zero, it means there are no more compound commands, and nothing needs to be copied to `next_buffer`. 2. Inside the `if (next_cmd)` block, the condition `next_cmd > pdu_length` (line 5474) explicitly checks if `next_cmd` exceeds the valid current `pdu_length`. If it does, the function returns an error, preventing an OOB read from `buf + next_cmd`. 3. The remaining part of the conditions (`next_cmd < MID_HEADER_SIZE(server)` or `pdu_length - next_cmd < MID_HEADER_SIZE(server)`) ensure semantic correctness (next command must be at least header size), which also implies bounds within `pdu_length`. Given `next_cmd <= pdu_length`, the source address `buf + next_cmd` is always within `buf`'s valid data range. The copy size `pdu_length - next_cmd` is non-negative and represents the exact remaining bytes from the current PDU. The `memcpy` operation `memcpy(next_buffer, buf + next_cmd, pdu_length - next_cmd)` will thus copy data from `buf[next_cmd ... pdu_length - 1]`, which is fully contained within `buf[0 ... pdu_length - 1]`. **Destination buffer bounds check (next_buffer):** 1. The current `pdu_length` (after `sizeof(struct smb2_transform_hdr)` has been subtracted) is bounded by the `smb3_receive_transform` caller at line 5559, effectively capping it at `CIFSMaxBufSize + MAX_HEADER_SIZE(server)` (or `MAX_CIFS_SMALL_BUFFER_SIZE` if it's small enough). 2. The `next_is_large` flag, which determines whether `cifs_buf_get()` (large buffer) or `cifs_small_buf_get()` (small buffer) is called, is correctly set based on the initial `pdu_length` (derived from `server->pdu_size`) at line 5442. This ensures that `next_buffer` is allocated to be large enough to hold the maximum possible `pdu_length` (which itself is bounded). 3. Since the copy size (`pdu_length - next_cmd`) is always less than or equal to the current `pdu_length`, and `next_buffer` is allocated to accommodate `pdu_length`, the destination buffer is always sufficiently large. **Counterexample Test:** Assume `server->pdu_size` (initial) = `P`. Let `sizeof(struct smb2_transform_hdr)` = `TSH`. Let `MID_HEADER_SIZE(server)` = `MHS`. The effective `pdu_length` after decryption header is `P' = P - TSH` (line 5460). For `memcpy` to be reached, `next_cmd` must satisfy `MHS <= next_cmd <= P' - MHS` (combining the conditions from lines 5472-5481). * **Scenario 1: `next_cmd` causes OOB read from `buf`?** If `next_cmd > P'`, the check `next_cmd > pdu_length` at 5474 returns -1. So, `buf + next_cmd` will not go past `buf + P'`. The size `P' - next_cmd` will be non-negative because `next_cmd <= P'`. The end of the copied region is `buf + next_cmd + (P' - next_cmd) = buf + P'`, which is the conceptual end of the valid data in `buf`. No OOB read. * **Scenario 2: `next_cmd` causes OOB write to `next_buffer`?** `next_buffer` is sized to at least `P'` (by choosing large or small allocation based on `P`). The copy length `P' - next_cmd` is always `<= P'`. Therefore, `next_buffer` will always be large enough. No OOB write. The SMT result 'PROVED - negative: value is unsigned at the sink' is not relevant to determining bounds safety for this specific issue.

smb2_ioctl_query_info() — fs/smb/client/smb2ops.c FP confidence=high

The `smb2_ioctl_query_info` function handles IOCTL requests where the user provides an `smb_query_info` structure, which includes an `input_buffer_length` field indicating the size of the expected output data. This `input_buffer_length` is initially user-supplied. However, before it is used in `copy_to_user` operations, it is capped by a length value provided by the server response (`io_rsp->OutputCount` or `qi_rsp->OutputBufferLength`). This means the actual number of bytes copied is `min(user_requested_length, server_reported_length)`. Additionally, the kernel's source buffer (the server response `rsp_iov[1].iov_base`) is validated to ensure that the requested copy size does not exceed its bounds. For the destination buffer, `copy_to_user` handles checking the user-provided memory region's validity, making it self-limiting as per rule #11.

Finding #1 — Category G2 — false positive

CategoryCat G2 — unvalidated size argument to copy_from/to_user
Taint sourcecopy_to_user() line 1797
Taint snippetif (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info),
Tainted varqi.input_buffer_length
Unvalidated sizecopy_to_user() arg 2 line 1797 — size qi.input_buffer_length
Sink snippetif (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info),
Possibly guardedno
Dismissed: The `qi.input_buffer_length` is initially user-supplied. On line 1782, it is updated to `min(original_user_value, le32_to_cpu(io_rsp->OutputCount))`. This ensures the size is capped by both user intent and server-supplied data (Rule #10, no inflation). The `copy_to_user` operation on line 1797 copies data from a kernel buffer to a user buffer. The *source* kernel buffer is validated by the `if` condition on lines 1784-1785, which checks `size_add(le32_to_cpu(io_rsp->OutputOffset), qi.input_buffer_length) > rsp_iov[1].iov_len`. This ensures no OOB read from the kernel's source buffer. The *destination* is `(void __user *)pqi + sizeof(struct smb_query_info)`. Since `pqi` points to a user-supplied structure and `qi.input_buffer_length` is bounded by the user's original request, the `copy_to_user` operation is self-limiting against the user's allocated buffer (Rule #11). If the user provides an insufficiently sized buffer, `copy_to_user` will return -EFAULT, preventing kernel memory corruption.

Finding #2 — Category G2 — false positive

CategoryCat G2 — unvalidated size argument to copy_from/to_user
Taint sourcecopy_to_user() line 1819
Taint snippetif (copy_to_user(pqi + 1, qi_rsp->Buffer,
Tainted varqi.input_buffer_length
Unvalidated sizecopy_to_user() arg 2 line 1819 — size qi.input_buffer_length
Sink snippetif (copy_to_user(pqi + 1, qi_rsp->Buffer,
Possibly guardedno
Dismissed: Similar to finding #1, `qi.input_buffer_length` is initially user-supplied. On line 1805, it is updated to `min(original_user_value, le32_to_cpu(qi_rsp->OutputBufferLength))`. This caps the size by both user intent and server-supplied data (Rule #10, no inflation). The `copy_to_user` operation on line 1819 copies data from a kernel buffer (`qi_rsp->Buffer`) to a user buffer (`pqi + 1`). The *source* kernel buffer is validated by the `if` condition on lines 1807-1808, which checks `struct_size(qi_rsp, Buffer, qi.input_buffer_length) > rsp_iov[1].iov_len`. This ensures no OOB read from the kernel's source buffer. The *destination* is `pqi + 1`. Since `pqi` points to a user-supplied structure and `qi.input_buffer_length` is bounded by the user's original request, the `copy_to_user` operation is self-limiting against the user's allocated buffer (Rule #11). If the user provides an insufficiently sized buffer, `copy_to_user` will return -EFAULT, preventing kernel memory corruption.

smb2_query_eas() — fs/smb/client/smb2ops.c BUG confidence=high

The function `smb2_query_eas` calls `smb2_validate_iov` to perform an initial bounds check on the server-supplied `OutputBufferOffset` and a minimum header size. However, the postcondition for `smb2_validate_iov` indicates it only guarantees `offset + sizeof_hdr` fits within the `iov`. It does *not* explicitly state that the full declared payload length (`OutputBufferLength`) is also bounded by the actual received buffer length (`rsp_iov.iov_len`). This oversight allows a malicious server to declare an `OutputBufferLength` that extends beyond the actual received `rsp_iov.iov_len - OutputBufferOffset`. This large, server-controlled `OutputBufferLength` is then passed as `src_size` to `move_smb2_ea_to_cifs`. Inside `move_smb2_ea_to_cifs`, `src_size` is used both as a loop iteration bound (`while (src_size >= sizeof(*src))`) and in internal checks against the size of individual EA entries (`if (src_size < 8 + name_len + 1 + value_len)`). While these internal checks ensure consistency with the *declared* `src_size`, they do not protect against `src_size` itself being larger than the physically available buffer. Consequently, pointer dereferences on `src` and `memcpy` operations will read out-of-bounds relative to the actual `rsp_iov` buffer, leading to an information disclosure or kernel panic. The fix is to add an explicit bounds check in `smb2_query_eas` to ensure that `OutputBufferOffset + OutputBufferLength` does not exceed `rsp_iov.iov_len`.

Finding #1 — Category C — cross-function via move_smb2_ea_to_cifs() — BUG oob_read

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 1179
Taint snippetinfo = (struct smb2_file_full_ea_info *)(
Tainted varinfo
Call siteline 1181 — passes info to move_smb2_ea_to_cifs()
Call snippetrc = move_smb2_ea_to_cifs(ea_data, buf_size, info,
Subscript (in callee)[] line 1073
Sink snippetvalue = &src->ea_data[src->ea_name_length + 1];
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap corruption or information disclosure due to out-of-bounds read of kernel memory when accessing `src->ea_data` in `move_smb2_ea_to_cifs`.
Fix: Add a check in `smb2_query_eas` after line 1177 (after `smb2_validate_iov`) to ensure `le16_to_cpu(rsp->OutputBufferOffset) + le32_to_cpu(rsp->OutputBufferLength)` does not exceed `rsp_iov.iov_len`. If it does, return an error. Example: `if (le16_to_cpu(rsp->OutputBufferOffset) + le32_to_cpu(rsp->OutputBufferLength) > rsp_iov.iov_len) { rc = -EINVAL; goto qeas_exit; }`
CVE pattern: SMB negotiation response OOB read

Finding #2 — Category F — cross-function via move_smb2_ea_to_cifs() — BUG oob_read

CategoryCat F — server value → loop iteration count
Taint sourcele32_to_cpu() line 1181
Taint snippetrc = move_smb2_ea_to_cifs(ea_data, buf_size, info,
Tainted varle32_to_cpu(rsp->OutputBufferLength)
Call siteline 1181 — passes le32_to_cpu(rsp->OutputBufferLength) to move_smb2_ea_to_cifs()
Call snippetrc = move_smb2_ea_to_cifs(ea_data, buf_size, info,
Loopwhile_loop line 1058
Sink snippetwhile (src_size >= sizeof(*src)) {
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap corruption or information disclosure due to out-of-bounds read when `move_smb2_ea_to_cifs` iterates past the end of the received network buffer.
Fix: Add a check in `smb2_query_eas` after line 1177 (after `smb2_validate_iov`) to ensure `le16_to_cpu(rsp->OutputBufferOffset) + le32_to_cpu(rsp->OutputBufferLength)` does not exceed `rsp_iov.iov_len`. If it does, return an error. Example: `if (le16_to_cpu(rsp->OutputBufferOffset) + le32_to_cpu(rsp->OutputBufferLength) > rsp_iov.iov_len) { rc = -EINVAL; goto qeas_exit; }`
CVE pattern: SMB negotiation response integer overflow / OOB read via loop control

smb3_enum_snapshots() — fs/smb/client/smb2ops.c BUG confidence=high

The function receives a user-space pointer `ioc_buf` and reads an initial length from it. It then calls `SMB2_ioctl` which populates `retbuf` with server-supplied data and updates `ret_data_len` with the actual number of bytes received (bounded by `max_response_size`). Subsequent logic attempts to adjust `ret_data_len` before copying to user-space. While modifications to `ret_data_len` ensure it does not exceed the kernel's `retbuf` size, there is no validation that the final `ret_data_len` is less than or equal to the actual user-allocated buffer size for `ioc_buf`. The initial `get_user` from `ioc_buf` suggests that `ret_data_len` also represents the user's buffer capacity. If the server-supplied length (which `ret_data_len` becomes after `SMB2_ioctl`) is greater than this user-supplied capacity, `copy_to_user` will attempt to write past the end of the user's buffer.

Finding #1 — Category G2 — BUG oob_write

CategoryCat G2 — unvalidated size argument to copy_from/to_user
Taint sourcecopy_to_user() line 2487
Taint snippetif (copy_to_user(ioc_buf, retbuf, ret_data_len))
Tainted varret_data_len
Unvalidated sizecopy_to_user() arg 2 line 2487 — size ret_data_len
Sink snippetif (copy_to_user(ioc_buf, retbuf, ret_data_len))
Possibly guardedno
Server-suppliedyes
Check presentno
Check sufficientno
Symptom: Kernel crash (if user-space buffer is not mapped or too small to cover the write), or information disclosure/corruption in user-space.
Fix: Before the `copy_to_user` call at line 2487, the size argument must be capped by the user's provided buffer capacity. The value read by `get_user(ret_data_len, (unsigned int __user *)ioc_buf)` at line 2425 (`user_provided_ioc_buf_len`) should be retained and used as the upper bound for the final `copy_to_user` size. Modified `copy_to_user` call: `if (copy_to_user(ioc_buf, retbuf, min(ret_data_len, user_provided_ioc_buf_len)))` Additionally, the `copy_from_user` at line 2453 (`copy_from_user(&snapshot_in, ioc_buf, sizeof(struct smb_snapshot_array))`) should also be bounded by `user_provided_ioc_buf_len` to prevent an OOB read from user space.
CVE pattern: unbounded copy_to_user

smb3_fiemap() — fs/smb/client/smb2ops.c FP confidence=high

The static analysis finding indicates a truncation of a 64-bit value to a 32-bit integer for the `rc` variable. However, `rc` receives the return value of `fiemap_fill_next_extent()`. This function takes 64-bit arguments but is designed to return small integer status codes (0, 1, or negative error codes), all of which fit well within a 32-bit `int`. The 64-bit server-supplied values (`file_offset`, `length`) are passed correctly as `u64` arguments to `fiemap_fill_next_extent` and are not themselves truncated by this assignment. The scanner incorrectly assumes the return value might need to convey a large 64-bit numerical result, rather than a simple status, leading to a false positive.

Finding #1 — Category H — false positive

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele64_to_cpu() line 4369
Taint snippetrc = fiemap_fill_next_extent(fei,
Tainted varrc
Truncationline 4369: 64 → 32-bit u32
Sink snippetrc = fiemap_fill_next_extent(fei,
Possibly guardedno
Dismissed: The values `le64_to_cpu(out_data[i].file_offset)` and `le64_to_cpu(out_data[i].length)` are indeed server-supplied. However, these are passed as `u64` arguments to `fiemap_fill_next_extent()`. The `rc` variable, which is an `int`, receives the *return value* of `fiemap_fill_next_extent()`. The `fiemap_fill_next_extent()` function (from `fs/fiemap.c`) returns status codes (0 for success, 1 for 'mapping complete', or negative error codes), which are always within the range of a 32-bit signed integer. Therefore, there is no meaningful truncation of data. The `u64` server-supplied values are used correctly within the `fiemap_fill_next_extent` function and are not themselves truncated by the `rc` assignment. The checks on `out_data_len` (lines 4354-4361) ensure that the `out_data` array access `out_data[i]` is in bounds.

smb3_simple_fallocate_range() — fs/smb/client/smb2ops.c FP confidence=high

The function processes server-supplied file allocation range information. It correctly validates the size of the received `file_allocated_range_buffer` structures against `out_data_len` before dereferencing, and performs overflow checks on `range_start` and `range_len` before calculating `range_end`. The length variable `l` is also capped by the remaining requested length `len`. The specific finding seems to misinterpret the role of the `rc` variable.

Finding #1 — Category H — false positive

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele64_to_cpu() line 3835
Taint snippetrc = smb3_simple_fallocate_write_range(xid, tcon,
Tainted varrc
Truncationline 3835: 64 → 32-bit u32
Sink snippetrc = smb3_simple_fallocate_write_range(xid, tcon,
Possibly guardedno
Dismissed: The static analysis finding claims that a '64-bit value (via 'l', from le64_to_cpu()) silently truncated to 32-bit 'rc'' at line 3835. This is a misinterpretation of the code. The variable `rc` is an `int` that receives the return value of `smb3_simple_fallocate_write_range`. The variable `l` is a `loff_t` (64-bit) which is passed as an argument to `smb3_simple_fallocate_write_range`. There is no truncation of the 64-bit value in `l` to `rc`. `rc` stores the 32-bit return code, not a truncated version of `l`. The variable `l` itself is properly bounded: it is derived from `range_start` and `range_len` which are checked against `S64_MAX` (lines 3820-3824), and `l` is further clamped by the `len` argument (which originates from the VFS layer and user input, but is handled as `loff_t`). Thus, `l` remains a 64-bit value throughout its relevant uses.

SMB2_QFS_attr() — fs/smb/client/smb2pdu.c MIXED confidence=high

The function uses `smb2_validate_iov` to perform buffer validation. While this helper effectively checks the upper bound of the payload data (`offset + payload_length <= received_buffer_length`) and that the payload length meets a minimum required size, it lacks a critical lower-bound check on the `OutputBufferOffset` field. This omission allows an attacker to craft an offset that points into the fixed header portion of the SMB2 response, leading to misinterpretation of header fields as payload data (information disclosure) and potentially OOB reads if the crafted offset is too close to the end of the header and the target struct field is large.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le32_to_cpu() line 6312
Taint snippetrsp_len = le32_to_cpu(rsp->OutputBufferLength);
Tainted varrsp_len
Sinkmemcpy() line 6319 (arg 2, role=size)
Sink snippetmemcpy(&tcon->fsAttrInfo, offset
Possibly guardedno
Dismissed: The `rsp_len` is derived from `rsp->OutputBufferLength`, which is server-supplied. The `memcpy` sink at line 6319 copies `min_t(unsigned int, rsp_len, min_len)` bytes. For `level == FS_ATTRIBUTE_INFORMATION`, `min_len` is `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)`. 1. **Destination check:** The destination `&tcon->fsAttrInfo` is a `FILE_SYSTEM_ATTRIBUTE_INFO` struct. The `memcpy` size is capped by `min_len`, which is the exact size of the destination struct. Therefore, no OOB write to `tcon->fsAttrInfo` can occur. 2. **Source check:** The `smb2_validate_iov(offset, rsp_len, &rsp_iov, min_len)` call (line 6314) ensures two things before the `memcpy` is reached: * `rsp_len >= min_len` (line 3860: `buffer_length < min_buf_size` would return -EINVAL). This means the server-supplied length is at least the minimum required size. * `offset + rsp_len <= rsp_iov.iov_len` (line 3873: `end_of_buf > end_of_smb` would return -EINVAL). This guarantees that the entire intended payload, starting at `offset`, fits within the actual received buffer `rsp_iov.iov_base` of length `rsp_iov.iov_len`. Since the `memcpy` reads `min_len` bytes from `offset + (char *)rsp`, and we know `min_len <= rsp_len`, and `offset + rsp_len <= rsp_iov.iov_len`, it follows that `offset + min_len <= rsp_iov.iov_len`. Thus, the source read is also within bounds. **Counterexample test:** * `rsp_iov.iov_len = 100` (total received buffer size) * `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) = 20` (so `min_len = 20`) * If server sends `OutputBufferOffset = 10`, `OutputBufferLength = 15`: * `rsp_len = 15`. `smb2_validate_iov` fails because `buffer_length (15) < min_buf_size (20)`. No `memcpy`. * If server sends `OutputBufferOffset = 90`, `OutputBufferLength = 20`: * `rsp_len = 20`. `smb2_validate_iov` fails because `end_of_buf (90 + 20 = 110)` is `> end_of_smb (100)`. No `memcpy`. * If server sends `OutputBufferOffset = 10`, `OutputBufferLength = 25`: * `rsp_len = 25`. `smb2_validate_iov` passes (10 + 25 = 35 <= 100). * `memcpy` copies `min(25, 20) = 20` bytes from `rsp + 10` to `&tcon->fsAttrInfo`. * Source `rsp + 10` for 20 bytes is within `rsp_iov.iov_len` (10+20=30 <= 100). * Destination `&tcon->fsAttrInfo` receives 20 bytes, which is its exact size. Safe.

Finding #2 — Category E — BUG info_disclosure

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6313
Taint snippetoffset = le16_to_cpu(rsp->OutputBufferOffset);
Tainted varss_info
Pointer derefss_info->Flags line 6328
Sink snippettcon->ss_flags = le32_to_cpu(ss_info->Flags);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Misinterpretation of kernel data, potentially reading header fields as struct data. Could lead to OOB read if `offset` plus internal field offset points past allocated buffer.
Fix: Add a lower-bound check on `offset` to ensure it is at least `sizeof(struct smb2_query_info_rsp)` before deriving the `ss_info` pointer. This ensures `ss_info` points to the actual payload area rather than overlaying the header. Example: `if (offset < sizeof(struct smb2_query_info_rsp)) return -EINVAL;`
CVE pattern: Missing lower-bound check on server-supplied offset

Finding #3 — Category E — BUG info_disclosure

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele16_to_cpu() line 6313
Taint snippetoffset = le16_to_cpu(rsp->OutputBufferOffset);
Tainted varvol_info
Pointer derefvol_info->VolumeSerialNumber line 6334
Sink snippettcon->vol_serial_number = le32_to_cpu(vol_info->VolumeSerialNumber);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Misinterpretation of kernel data, potentially reading header fields as struct data. Could lead to OOB read if `offset` plus internal field offset points past allocated buffer.
Fix: Add a lower-bound check on `offset` to ensure it is at least `sizeof(struct smb2_query_info_rsp)` before deriving the `vol_info` pointer. This ensures `vol_info` points to the actual payload area rather than overlaying the header. Example: `if (offset < sizeof(struct smb2_query_info_rsp)) return -EINVAL;`
CVE pattern: Missing lower-bound check on server-supplied offset

__smb2_plain_req_init() — fs/smb/client/smb2pdu.c FP confidence=high

The core issue is that the static analysis incorrectly identifies `smb2_command` as a server-supplied value. The function `__smb2_plain_req_init` (and its wrappers like `smb2_plain_req_init`, `smb2_ioctl_req_init`) is used by the kernel to *construct* SMB2 requests that it sends to a server. The `smb2_command` argument is always a kernel-defined constant (e.g., `SMB2_READ`, `SMB2_IOCTL`) which represents the type of SMB2 operation the kernel intends to perform. It is not parsed from a network response.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 578
Taint snippetuint16_t com_code = le16_to_cpu(smb2_command);
Tainted varcom_code
Subscript[] line 579
Sink snippetcifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]);
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 `smb2_command` parameter is a kernel-controlled constant, not a server-supplied value. Functions like `smb2_plain_req_init` and `smb2_ioctl_req_init` pass hardcoded `SMB2_*` constants to `__smb2_plain_req_init`. For example, `smb2_plain_req_init` is called with constants like `SMB2_READ` or `SMB2_WRITE`. `smb2_ioctl_req_init` passes `SMB2_IOCTL`. These are internal kernel command codes. The `le16_to_cpu` call is applied to a constant value. The `tcon->stats.smb2_stats.smb2_com_sent` array is defined with a size of `SMB2_MAX_COMMAND + 1` (e.g., `0x19 + 1 = 26` as per `SMB2_MAX_COMMAND` in `fs/cifs/smb2pdu.h`). All kernel-defined `SMB2_*` command codes are within this valid range (0 to 25). Therefore, `com_code` will always be a valid index into the array, making any out-of-bounds access impossible. No counterexample can be constructed because the `smb2_command` value is not attacker-controlled; it's a constant whose range is guaranteed by kernel definitions to be within the array bounds.

decode_compress_ctx() — fs/smb/client/smb2pdu.c FP confidence=high

The function `decode_compress_ctx` receives a context structure derived from server-supplied data. The static analysis flagged an issue where a server-supplied count (`ctxt->CompressionAlgorithmCount`) controls a loop without explicit validation against the total buffer length. However, a closer inspection reveals that the loop is effectively capped and the accesses are safe. The crucial observation is the check `count > ARRAY_SIZE(ctxt->CompressionAlgorithms)`. For flexible array members (like `CompressionAlgorithms[1]`), `ARRAY_SIZE` typically evaluates to `1`. This means any `CompressionAlgorithmCount` greater than `1` will cause an early return, effectively limiting the loop to at most one iteration (when `count` is `1`). When `count` is `1`, the `len < 10` check (and `len < 8 + count * sizeof(__le16)`) ensures that enough buffer space is available to safely access `ctxt->CompressionAlgorithms[0]`. Thus, no out-of-bounds access is possible.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 854
Taint snippetcount = le16_to_cpu(ctxt->CompressionAlgorithmCount);
Tainted varcount
Loopfor_loop line 867
Sink snippetfor (i = 0; i < count; i++) {
Possibly guardedyes (heuristic)
Dismissed: The `count` variable, derived from `ctxt->CompressionAlgorithmCount`, is indeed server-supplied. The loop `for (i = 0; i < count; i++)` uses this value. However, the check on line 855: `if (!count || count > ARRAY_SIZE(ctxt->CompressionAlgorithms) || len < 8 + count * sizeof(__le16))` serves as a sufficient guard. Assuming `ctxt->CompressionAlgorithms` is a flexible array member (or similar construct) where `ARRAY_SIZE` evaluates to `1` (which is common for such declarations), the `count > ARRAY_SIZE(...)` condition effectively prevents `count` from being greater than `1`. - If `count == 0`, `!count` is true, and the function returns (no loop). - If `count == 1`, `count > ARRAY_SIZE(...)` (i.e., `1 > 1`) is false. The check `len < 8 + 1 * sizeof(__le16)` (i.e., `len < 10`) ensures that the `len` (the total length of the context data) is at least `10` bytes. This is reinforced by the explicit `if (len < 10)` check on line 849. The access `ctxt->CompressionAlgorithms[0]` is at offset `8` (assuming `8` bytes for fixed header fields before the flexible array) and requires `2` bytes. With `len >= 10`, `8 + 2 <= 10` is true, making the access safe. The loop executes for `i=0` only. - If `count > 1` (e.g., `count == 2`), `count > ARRAY_SIZE(...)` (i.e., `2 > 1`) is true, and the function returns. The loop is not executed. Therefore, the loop never performs an out-of-bounds read, making this a false positive. The `ARRAY_SIZE` check, though potentially a functional bug (limiting capabilities to only one algorithm), acts as a strong security boundary here.

fill_small_buf() — fs/smb/client/smb2pdu.c FP confidence=high

The `smb2_command` parameter passed to `fill_small_buf` is derived from the `smb2_command` argument of `__smb2_plain_req_init`. This function (`__smb2_plain_req_init`) is a request-initialisation helper, indicated by its name and its role in allocating a `request_buf` that will be filled. The `smb2_command` values (e.g., `SMB2_SET_INFO`, `SMB2_QUERY_INFO`) used in the `switch` statement within `__smb2_plain_req_init` are kernel-defined constants or enum members. Therefore, `smb2_command` is a kernel-controlled value, not server-supplied. The `le16_to_cpu()` call converts a kernel-defined constant from its internal (potentially `__le16`) representation to host CPU order for array indexing. Since the index is a kernel-controlled constant, the array access is not subject to external manipulation, and thus no server-supplied bounds check is necessary. Any out-of-bounds access would indicate a kernel programming error, not an input validation vulnerability against server data.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 535
Taint snippet__u16 parmsize = smb2_req_struct_sizes[le16_to_cpu(smb2_command)];
Tainted varle16_to_cpu(smb2_command)
Subscript[] line 535
Sink snippet__u16 parmsize = smb2_req_struct_sizes[le16_to_cpu(smb2_command)];
Possibly guardedno
Dismissed: The `smb2_command` is an argument to `__smb2_plain_req_init`, which is a request builder. It is instantiated with kernel-defined constants (e.g., `SMB2_SET_INFO`). Therefore, the value `le16_to_cpu(smb2_command)` is a constant determined by the kernel, not by server input. The array access `smb2_req_struct_sizes[...]` uses this kernel-controlled constant as an index. The array `smb2_req_struct_sizes` is expected to be sized appropriately for all valid kernel-defined command values. No runtime bounds check is necessary for server-supplied input, as the input is not server-supplied. Counterexample test: If `smb2_command` (after `le16_to_cpu`) was, for example, 100, and `smb2_req_struct_sizes` only had 50 elements, it would be a kernel bug, not an input validation bug. The fact that the `smb2_command` is kernel-defined means such an out-of-bounds index would be a compile-time or static configuration error, not a runtime vulnerability from malicious input.

parse_posix_ctxt() — fs/smb/client/smb2pdu.c FP confidence=high

The `parse_posix_ctxt` function processes data from a `create_context` structure, which is part of a server-supplied SMB2 response. The caller function, `smb2_parse_contexts`, performs initial validation on the `DataOffset` and `DataLength` fields of the `create_context` to ensure the data region falls within the bounds of the context structure itself. Inside `parse_posix_ctxt`, a minimal `DataLength` check is performed. Further, the helper function `posix_info_sid_size` (which determines the size for `memcpy`) explicitly validates that the entire SID (including its sub-authorities) fits within the provided `beg` to `end` range. This multi-layered validation chain ensures that accesses are within bounds.

Finding #1 — Category B — false positive

CategoryCat B — server value → size/alloc argument
Taint sourcevia le16_to_cpu() line 2399
Taint snippetu8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset);
Tainted varsid_len
Sinkmemcpy() line 2419 (arg 2, role=size)
Sink snippetmemcpy(&posix->owner, sid, sid_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 `sid_len` value is determined by `posix_info_sid_size(sid, end)`. This helper function performs robust bounds checks on the source buffer (`sid` to `end`) to ensure that the entire SID structure can be read without going out of bounds. If the SID data does not fit, `posix_info_sid_size` returns -1, causing `parse_posix_ctxt` to return early. Thus, the `memcpy` is only reached when `sid_len` is valid and within the source buffer. Additionally, `sid_len` (maximum 68 bytes) is less than or equal to `sizeof(struct cifs_sid)` (72 bytes), ensuring no OOB write to the destination struct fields `posix->owner` or `posix->group`. Tested counterexamples with `dlen` less than `3 * sizeof(__le32)` or `sid + sid_len > end` consistently result in an early return from `parse_posix_ctxt` or `posix_info_sid_size` respectively, preventing the `memcpy`.

Finding #2 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 2399
Taint snippetu8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset);
Tainted varsid
Sinkmemcpy() line 2419 (arg 1, role=pointer)
Sink snippetmemcpy(&posix->owner, sid, sid_len);
Possibly guardedno
Dismissed: The pointer `sid` is derived from `beg + 12`, where `beg` is `(u8 *)cc + le16_to_cpu(cc->DataOffset)`. The caller `smb2_parse_contexts` validates `cc->DataOffset` and `cc->DataLength` such that `DataOffset >= sizeof(struct create_context)` (12 bytes) and `DataOffset + DataLength <= cc_len` (the length of the `create_context` block). Inside `parse_posix_ctxt`, a check `dlen < 3 * sizeof(__le32)` (i.e., `dlen < 12`) ensures that `beg` and subsequent accesses up to `beg + 12` are safe. The `sid` pointer starts exactly where these initial 12 bytes end. The `posix_info_sid_size` function, called before `memcpy`, takes `sid` and `end` (derived from `DataLength`) and performs explicit bounds checking (`sid + sid_len <= end`) to ensure the `memcpy`'s source region is entirely within the `create_context`'s data payload. Therefore, the source pointer `sid` for `memcpy` is always within the bounds of the validated server-supplied buffer. Tested counterexamples as described for finding #1. All OOB scenarios are caught by earlier validation.

parse_query_id_ctxt() — fs/smb/client/smb2pdu.c FP confidence=high

The `smb2_parse_contexts` function (the sole caller of `parse_query_id_ctxt`) performs robust bounds checking on the `create_context` structure's fields, including `DataOffset` and `DataLength`, before passing control to `parse_query_id_ctxt`. It ensures that `DataOffset` is not less than the header size of `create_context` and that `DataOffset + DataLength` does not exceed the total `cc_len` of the current context block. Additionally, `parse_query_id_ctxt` itself checks that `DataLength` is sufficient for the `memcpy` operation. These combined checks provide sufficient protection against out-of-bounds access.

Finding #1 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 2382
Taint snippetu16 doff = le16_to_cpu(cc->DataOffset);
Tainted varbeg
Sinkmemcpy() line 2390 (arg 1, role=pointer)
Sink snippetmemcpy(&buf->IndexNumber, beg, sizeof(__le64));
Possibly guardedno
Dismissed: The `beg` pointer is derived from `cc + doff`. `cc` is a pointer into a server-supplied response buffer. `doff` (DataOffset) and `dlen` (DataLength) are server-supplied values read from `cc`. The `memcpy` attempts to read `sizeof(__le64)` bytes from `beg`. Preconditions established by the caller `smb2_parse_contexts` (lines 2477-2479): 1. `doff < sizeof(*cc)`: This checks if the `DataOffset` points *after* the fixed-size header of `struct create_context`. If `doff` is smaller, it's an error (`return -EINVAL`). This acts as a lower-bound check for `doff` relative to the `cc` structure. 2. `check_add_overflow(doff, dlen, &len)`: Ensures `doff + dlen` does not overflow. 3. `len > cc_len`: This check (effectively `doff + dlen > cc_len`) ensures that the entire data block, starting at `cc + doff` with length `dlen`, fits within the bounds of the current `create_context` block (`cc_len` is the length of `cc` itself, which was validated earlier against `rsp_iov->iov_len`). If `doff + dlen` exceeds `cc_len`, it's an error (`return -EINVAL`). This acts as an upper-bound check for the entire data segment. Preconditions established by `parse_query_id_ctxt` itself (line 2386): 4. `dlen < sizeof(__le64)`: This ensures that the advertised `DataLength` is at least the size required for the `memcpy` (8 bytes). If not, the function returns early. Combining these: - From (3), we know `doff + dlen <= cc_len`. - From (4), we know `dlen >= sizeof(__le64)`. - Substituting `sizeof(__le64)` for `dlen` in the first inequality, we get `doff + sizeof(__le64) <= doff + dlen <= cc_len`. - This implies `doff + sizeof(__le64) <= cc_len`. The `memcpy` reads `sizeof(__le64)` bytes starting at `(u8 *)cc + doff`. The maximum address accessed would be `(u8 *)cc + doff + sizeof(__le64) - 1`. Since `doff + sizeof(__le64)` is guaranteed to be less than or equal to `cc_len`, the `memcpy` operation will not read beyond the `cc` block boundary (`(u8 *)cc + cc_len`). Counterexample test: Let `sizeof(__le64) = 8`. Let `sizeof(*cc) = 8` (a realistic minimum for `create_context` header). - If `cc_len = 15`, `doff = 8`, `dlen = 7`: - Caller checks: `doff < sizeof(*cc)` (8 < 8) is false. `len = 8 + 7 = 15`. `len > cc_len` (15 > 15) is false. All pass. - Callee check: `dlen < sizeof(__le64)` (7 < 8) is true. Function returns. No OOB. - If `cc_len = 16`, `doff = 8`, `dlen = 8`: - Caller checks: `doff < sizeof(*cc)` (8 < 8) is false. `len = 8 + 8 = 16`. `len > cc_len` (16 > 16) is false. All pass. - Callee check: `dlen < sizeof(__le64)` (8 < 8) is false. Function proceeds. - `beg = (u8 *)cc + 8`. `memcpy` reads 8 bytes from `beg`. The read range is `cc + 8` to `cc + 8 + 8 - 1 = cc + 15`. This is within `cc_len = 16`. No OOB. - If `cc_len = 10`, `doff = 8`, `dlen = 8`: - Caller checks: `doff < sizeof(*cc)` (8 < 8) is false. `len = 8 + 8 = 16`. `len > cc_len` (16 > 10) is true. Caller returns -EINVAL. No OOB. - If `cc_len = 16`, `doff = 4`, `dlen = 8`: - Caller checks: `doff < sizeof(*cc)` (4 < 8) is true. Caller returns -EINVAL. No OOB. All scenarios where OOB might occur are caught by the combined validation logic.

posix_info_parse() — fs/smb/client/smb2pdu.c BUG confidence=high

The function `posix_info_parse` is designed to parse a single `smb2_posix_info` entry. It receives `beg` (start of the entry) and `end` (end of the overall buffer). There's a conditional block (`if (!end)`) where `end` is derived from `p->NextEntryOffset` or a default `0xFFFF`. If the caller passes `NULL` for `end` and `p->NextEntryOffset` is not validated against the actual received packet length, then `end` itself becomes an untrusted, server-controlled value, potentially leading to OOB reads from the input buffer `beg`. However, the critical issue identified by the scanner, and confirmed by analysis, is an OOB *write* into the `out` structure, which is independent of the `end` pointer's trustworthiness for input buffer reads. The `struct smb2_posix_info_parsed` embeds `struct cifs_sid owner;` and `struct cifs_sid group;`. `struct cifs_sid` uses a flexible array member `SubAuth[0]`, meaning `sizeof(struct cifs_sid)` only covers the fixed header (8 bytes). However, `posix_info_sid_size` calculates the *actual* size of the SID on the wire, which can be up to 68 bytes. `memcpy` operations subsequently attempt to copy this variable length data into the fixed-size `cifs_sid` fields within `out`, leading to OOB writes into the `smb2_posix_info_parsed` structure.

Finding #1 — Category B — BUG oob_write

CategoryCat B — server value → size/alloc argument
Taint sourcevia le32_to_cpu() line 5486
Taint snippetend = beg + le32_to_cpu(p->NextEntryOffset);
Tainted varowner_len
Sinkmemcpy() line 5530 (arg 2, role=size)
Sink snippetmemcpy(&out->owner, owner_sid, owner_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)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap or stack corruption depending on `out` allocation.
Fix: Change `struct smb2_posix_info_parsed` to store `const struct cifs_sid *owner;` and `unsigned int owner_len;` instead of embedding `struct cifs_sid owner;`. This avoids copying variable-length data into a fixed-size struct member. Alternatively, if direct copying is desired, `out->owner` would need to be a dynamically allocated buffer of size `owner_len` before calling `posix_info_parse`.
CVE pattern: Fixed-size buffer for variable-length data

Finding #2 — Category B — BUG oob_write

CategoryCat B — server value → size/alloc argument
Taint sourcevia le32_to_cpu() line 5486
Taint snippetend = beg + le32_to_cpu(p->NextEntryOffset);
Tainted vargroup_len
Sinkmemcpy() line 5531 (arg 2, role=size)
Sink snippetmemcpy(&out->group, group_sid, group_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)
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel panic from heap or stack corruption depending on `out` allocation.
Fix: Change `struct smb2_posix_info_parsed` to store `const struct cifs_sid *group;` and `unsigned int group_len;` instead of embedding `struct cifs_sid group;`. This avoids copying variable-length data into a fixed-size struct member. Alternatively, if direct copying is desired, `out->group` would need to be a dynamically allocated buffer of size `group_len` before calling `posix_info_parse`.
CVE pattern: Fixed-size buffer for variable-length data

Finding #3 — Category A — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele32_to_cpu() line 5486
Taint snippetend = beg + le32_to_cpu(p->NextEntryOffset);
Tainted vargroup_sid
Sinkmemcpy() line 5531 (arg 1, role=pointer)
Sink snippetmemcpy(&out->group, group_sid, group_len);
Possibly guardedno
Dismissed: The `group_sid` pointer is formed by `beg + total_len`. Before `memcpy` uses `group_sid` as its source, `group_len = posix_info_sid_size(group_sid, end)` is called. This `posix_info_sid_size` function explicitly checks `if (beg + total > end) return -1;` (where `beg` here is `group_sid` from the caller's perspective, and `total` is `group_len`). If this check fails, `posix_info_sid_size` returns -1, which `posix_info_parse` then checks (`if (group_len < 0) return -1;` at line 5507) and returns, preventing the `memcpy`. Thus, `group_sid` is guaranteed to be within `[beg, end)` for the duration of `memcpy`, preventing OOB reads from the input buffer. Counterexample test: If `beg` is at 0x1000, `end` is at 0x1050. Assume previous calculations lead to `group_sid = 0x1030`. If `posix_info_sid_size` calculates a `group_len` such that `0x1030 + group_len > 0x1050` (e.g., `group_len = 30`), `posix_info_sid_size` will return -1. This negative return value is checked, causing `posix_info_parse` to return -1, and thus `memcpy` is not reached with an out-of-bounds `group_sid` source pointer.

query_info() — fs/smb/client/smb2pdu.c FP confidence=high

The `query_info` function calls `smb2_validate_and_copy_iov` which in turn calls `smb2_validate_iov`. The `smb2_validate_iov` function is a dedicated validation helper whose purpose is to check the bounds of the provided offset and length against the input buffer (`iov`). As per rule 2 (Validation call chains) and rule 4 (Callee-internal validation), accesses within a validation function (or a function that calls a validation function *before* the sensitive operation) are typically considered part of the validation logic and thus not vulnerable sinks themselves.

Finding #1 — Category A — cross-function via smb2_validate_and_copy_iov() — false positive

CategoryCat A — server offset → pointer → memory op
Taint sourcele16_to_cpu() line 4043
Taint snippetrc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),
Tainted varle16_to_cpu(rsp->OutputBufferOffset)
Call siteline 4043 — passes le16_to_cpu(rsp->OutputBufferOffset) to smb2_validate_and_copy_iov()
Call snippetrc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),
Sink (in callee)memcpy() line 3900 (arg 1, role=pointer)
Sink snippetmemcpy(data, begin_of_buf, minbufsize);
Possibly guardedno
Dismissed: The `le16_to_cpu(rsp->OutputBufferOffset)` value is server-supplied, as `rsp` points to a buffer received from the server via `cifs_send_recv`. The `smb2_validate_and_copy_iov` function takes this `offset` as its first argument. Before performing the `memcpy` operation at line 3900, `smb2_validate_and_copy_iov` explicitly calls `smb2_validate_iov(offset, buffer_length, iov, minbufsize)` at line 3896. This `smb2_validate_iov` function is designed to validate if the `offset` plus the `minbufsize` (the amount to be copied) falls within the bounds of the `iov` buffer (`iov->iov_len`). Counterexample test: Assume `iov->iov_len = 100` (actual received buffer size). Assume server sends `rsp->OutputBufferOffset` which results in `offset = 90` after `le16_to_cpu`. Assume `minbufsize = 20`. Without validation, `memcpy` would attempt to read from `iov->iov_base + 90` for 20 bytes, causing an OOB read (bytes 90-109, going past 99). However, `smb2_validate_iov` is called with `offset=90`, `minbufsize=20`, and `iov->iov_len=100`. It is expected to check if `offset + minbufsize <= iov->iov_len` (i.e., `90 + 20 <= 100`). Since `110 <= 100` is false, `smb2_validate_iov` is expected to return an error, preventing the `memcpy` from being reached. Thus, the access is guarded by the validation helper.

smb2_parse_contexts() — fs/smb/client/smb2pdu.c BUG confidence=high

The primary issue across all findings is the missing lower-bound validation for `rsp->CreateContextsOffset`. This field, parsed as `off`, determines the starting point (`cc`) for the `create_context` structures. While an upper-bound check (`off + rem <= rsp_iov->iov_len`) exists, there is no check to ensure `off` points *after* the fixed-size `smb2_create_rsp` header itself. If `off` is smaller than `sizeof(struct smb2_create_rsp)`, the pointer `cc` will point into the `smb2_create_rsp` header, causing subsequent dereferences of `cc->Next`, `cc->DataOffset`, etc., to misinterpret header fields as context fields. Although the internal checks within the loop (e.g., `len > cc_len`) might catch some invalid patterns, a crafted response can bypass these checks, leading to information disclosure or data corruption during parsing.

Finding #1 — Category F — BUG oob_read

CategoryCat F — server value → loop iteration count
Taint sourcele32_to_cpu() line 2456
Taint snippetrem = le32_to_cpu(rsp->CreateContextsLength);
Tainted varrem
Loopwhile_loop line 2465
Sink snippetwhile (rem >= sizeof(*cc)) {
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic or information disclosure / data corruption
Fix: Add a lower-bound check for `off` (derived from `rsp->CreateContextsOffset`) to ensure it points beyond the `smb2_create_rsp` header. Specifically, after line 2457, add `if (off < sizeof(struct smb2_create_rsp)) return -EINVAL;` assuming `rsp` points to the start of the `smb2_create_rsp` header and contexts must follow it.
CVE pattern: SMB negotiation response offset OOB

Finding #2 — Category E — BUG oob_read

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 2455
Taint snippetoff = le32_to_cpu(rsp->CreateContextsOffset);
Tainted varcc
Pointer derefcc->Next line 2466
Sink snippetoff = le32_to_cpu(cc->Next);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic or information disclosure / data corruption when misinterpreting header fields
Fix: Add a lower-bound check for `off` (derived from `rsp->CreateContextsOffset`) to ensure it points beyond the `smb2_create_rsp` header. Specifically, after line 2457, add `if (off < sizeof(struct smb2_create_rsp)) return -EINVAL;`.
CVE pattern: SMB negotiation response offset OOB

Finding #3 — Category A — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele32_to_cpu() line 2455
Taint snippetoff = le32_to_cpu(rsp->CreateContextsOffset);
Tainted varname
Sinkmemcmp() line 2500 (arg 0, role=pointer)
Sink snippetif (dlen && posix && !memcmp(name, smb3_create_tag_posix, 16))
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic or information disclosure during string comparison with misaligned pointer
Fix: Add a lower-bound check for `off` (derived from `rsp->CreateContextsOffset`) to ensure it points beyond the `smb2_create_rsp` header. Specifically, after line 2457, add `if (off < sizeof(struct smb2_create_rsp)) return -EINVAL;`.
CVE pattern: SMB negotiation response offset OOB

Finding #4 — Category A — cross-function via parse_query_id_ctxt() — BUG oob_read

CategoryCat A — server offset → pointer → memory op
Taint sourcele32_to_cpu() line 2455
Taint snippetoff = le32_to_cpu(rsp->CreateContextsOffset);
Tainted varcc
Call siteline 2496 — passes cc to parse_query_id_ctxt()
Call snippetparse_query_id_ctxt(cc, buf);
Sink (in callee)memcpy() line 2390 (arg 1, role=pointer)
Sink snippetmemcpy(&buf->IndexNumber, beg, sizeof(__le64));
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: kernel panic or information disclosure / data corruption when copying misaligned data
Fix: Add a lower-bound check for `off` (derived from `rsp->CreateContextsOffset`) to ensure it points beyond the `smb2_create_rsp` header. Specifically, after line 2457, add `if (off < sizeof(struct smb2_create_rsp)) return -EINVAL;`.
CVE pattern: SMB negotiation response offset OOB

smb311_decode_neg_context() — fs/smb/client/smb2pdu.c MIXED confidence=high

The function implements robust per-iteration bounds checks within the loop for processing negotiate contexts, ensuring that each context header and its data fit within the remaining buffer. This effectively mitigates issues related to an oversized NegotiateContextCount. However, a critical lower-bound check is missing for the initial NegotiateContextOffset, which can lead to misinterpretation of response header fields as negotiate context data.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 976
Taint snippetunsigned int ctxt_cnt = le16_to_cpu(rsp->NegotiateContextCount);
Tainted varctxt_cnt
Loopfor_loop line 988
Sink snippetfor (i = 0; i < ctxt_cnt; i++) {
Possibly guardedno
Dismissed: The 'ctxt_cnt' (NegotiateContextCount) is server-supplied and controls the loop iteration count. However, the loop body contains sufficient per-iteration bounds checks: 1. Line 991: `if (len_of_ctxts < sizeof(struct smb2_neg_context)) break;` ensures that at least the header of the next context fits. 2. Line 1004: `if (clen > len_of_ctxts) break;` ensures the entire context (header + data) fits. These checks will cause the loop to terminate prematurely if the number of contexts indicated by 'ctxt_cnt' would lead to an out-of-bounds access. Thus, even if 'ctxt_cnt' is very large, no OOB memory access occurs. Tested counterexample: len_of_smb=100, offset=0, ctxt_cnt=0xFFFF. The loop correctly processes contexts until len_of_ctxts becomes insufficient, then breaks before any OOB read.

Finding #2 — Category E — BUG info_disclosure

CategoryCat E — tainted pointer dereference (->field access beyond packet bounds)
Taint sourcele32_to_cpu() line 975
Taint snippetunsigned int offset = le32_to_cpu(rsp->NegotiateContextOffset);
Tainted varpctx
Pointer derefpctx->DataLength line 996
Sink snippet+ le16_to_cpu(pctx->DataLength);
Possibly guardedno
Server-suppliedyes
Check presentyes
Check sufficientno
Symptom: Kernel crash or information leak due to misinterpretation of SMB negotiate response header data as context data. Potentially leads to further OOB reads if misparsed DataLength is used in subsequent operations.
Fix: Add a lower-bound check for `offset` (derived from `rsp->NegotiateContextOffset`) to ensure it points past the fixed header and any variable-length preceding data (like the security blob). For example, ensure `offset` is greater than or equal to `le16_to_cpu(rsp->SecurityBufferOffset) + le16_to_cpu(rsp->SecurityBufferLength)` (after alignment requirements, if any). A simpler, though potentially less precise, initial check could be `if (offset < sizeof(struct smb2_negotiate_rsp))` (where `sizeof(struct smb2_negotiate_rsp)` represents the full fixed header length). Example fix (to be placed after line 981): ```c unsigned int min_offset = sizeof(struct smb2_negotiate_rsp); // A more precise check might involve rsp->SecurityBufferOffset + rsp->SecurityBufferLength // For simplicity, using a minimal header size check here. if (offset < min_offset) { cifs_server_dbg(VFS, "Invalid response: negotiate context offset too small (%u < %u)\n", offset, min_offset); return -EINVAL; } ```
CVE pattern: SMB negotiation response missing lower bound check on context offset

smb2_calc_signature() — fs/smb/client/smb2transport.c FP confidence=high

The function `smb2_calc_signature` is a static helper used to sign outgoing SMB2/SMB3 requests. The `SessionId` (`sid`) used for signing key lookup is derived from the request header, which itself is constructed using information obtained from prior server responses. Thus, `sid` is ultimately server-derived, but used by the client to build a request. The finding is a false positive because it misunderstands the role of the `rc` variable.

Finding #1 — Category H — false positive

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele64_to_cpu() line 220
Taint snippetrc = smb2_get_sign_key(server, sid, key);
Tainted varrc
Truncationline 220: 64 → 32-bit u32
Sink snippetrc = smb2_get_sign_key(server, sid, key);
Possibly guardedno
Dismissed: The static analysis finding claims `rc` (an `int`, typically 32-bit) is a truncation of `sid` (a `__u64`, 64-bit). However, `rc` at line 220 `rc = smb2_get_sign_key(server, sid, key);` is assigned the *return value* of `smb2_get_sign_key`. The `smb2_get_sign_key` function returns an `int` (a status code), not the `sid` value itself. The `sid` is passed as an argument to `smb2_get_sign_key` as a `u64`, meaning it is used in its full 64-bit form within that function. There is no truncation of the 64-bit `sid` to the 32-bit `rc` variable. `rc` correctly stores the integer return code, not a truncated `SessionId`.

smb2_seq_num_into_buf() — fs/smb/client/smb2transport.c FP confidence=high

The finding is a false positive because the 'tainted' value (num, derived from shdr->CreditCharge) is not actually server-supplied. The `smb2_seq_num_into_buf` function is called during the construction of an *outgoing* SMB request (`struct smb_rqst *rqst`). The `shdr` argument points to the header of this outgoing request. Therefore, `shdr->CreditCharge` is a field set by the kernel itself before sending the request, typically via `cpu_to_le16`. The `le16_to_cpu` call is thus reading a locally-controlled value, not a server-controlled one. The loop iteration count is trustworthy and does not lead to an OOB memory access.

Finding #1 — Category F — false positive

CategoryCat F — server value → loop iteration count
Taint sourcele16_to_cpu() line 606
Taint snippetunsigned int i, num = le16_to_cpu(shdr->CreditCharge);
Tainted varnum
Loopfor_loop line 610
Sink snippetfor (i = 1; i < num; i++)
Possibly guardedno
Dismissed: The `shdr` parameter points to a `smb2_hdr` within a `smb_rqst` structure. `smb_rqst` is used to build outgoing SMB requests, not to parse incoming responses. Consequently, `shdr->CreditCharge` is a value constructed by the kernel itself for the request, making it locally-controlled rather than server-supplied. The `le16_to_cpu` function here merely reverses an endian conversion previously applied by the kernel (likely `cpu_to_le16`) when the request header was being built. The loop itself (`for (i = 1; i < num; i++)`) calls `get_next_mid(server)`, which increments an internal counter (`server->CurrentMid`) and does not involve memory operations that could go out of bounds based on the loop count. No counterexample is relevant as the core premise of server-supplied taint is incorrect.

smb3_calc_signature() — fs/smb/client/smb2transport.c FP confidence=high

The static analyzer misidentified the variable 'rc' as the truncated 'SessionId'. 'rc' is the integer return code of the smb3_get_sign_key function, not the SessionId itself. The 64-bit 'SessionId' is correctly passed as a 64-bit argument to smb3_get_sign_key, so no truncation of the SessionId value occurs at this point.

Finding #1 — Category H — false positive

CategoryCat H — server value → narrow integer type (silent truncation)
Taint sourcele64_to_cpu() line 478
Taint snippetrc = smb3_get_sign_key(le64_to_cpu(shdr->SessionId), server, key);
Tainted varrc
Truncationline 478: 64 → 32-bit u32
Sink snippetrc = smb3_get_sign_key(le64_to_cpu(shdr->SessionId), server, key);
Possibly guardedno
Dismissed: The finding incorrectly states that 'rc' is the 32-bit u32 destination for the 64-bit 'SessionId'. In reality, `rc` is an `int` variable holding the return value of `smb3_get_sign_key`. The `le64_to_cpu(shdr->SessionId)` expression, which results in a `u64` value, is passed as the first argument (`u64 session_id`) to `smb3_get_sign_key`. Thus, the 64-bit `SessionId` is not truncated to `rc`. The `SessionId` originates from the `smb2_hdr` which, in the `smb2_verify_signature` call path, would be server-supplied.

__release_mid() — fs/smb/client/transport.c FP confidence=high

The function __release_mid handles the release of SMB Message ID (MID) entries, which are used to track in-flight SMB requests and responses. The taint analysis flagged an array access for statistics tracking using a server-supplied SMB command code. However, a clear bounds check is present before the array access.

Finding #1 — Category C — false positive

CategoryCat C — server value → array subscript
Taint sourcele16_to_cpu() line 45
Taint snippet__u16 smb_cmd = le16_to_cpu(midEntry->command);
Tainted varsmb_cmd
Subscript[] line 69
Sink snippetif (atomic_read(&server->num_cmds[smb_cmd]) == 0) {
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 taint source `midEntry->command` is part of the SMB response header, making it genuinely server-supplied. The `le16_to_cpu()` conversion brings it to host byte order, storing it in `smb_cmd` as an `__u16`. The array accesses at line 69 (and 70, 71, 73, 74, 75, 76, 78, 79, 99) are guarded by the conditional `if (smb_cmd < NUMBER_OF_SMB2_COMMANDS)` at line 68. Since `smb_cmd` is an unsigned 16-bit integer (`__u16`), it cannot be negative, meaning the lower bound (0) is inherently satisfied. The check `smb_cmd < NUMBER_OF_SMB2_COMMANDS` ensures that the index does not exceed the array bounds. For instance, if `NUMBER_OF_SMB2_COMMANDS` is 35, `smb_cmd` must be in the range [0, 34] to pass the check. Any `smb_cmd` value >= 35 (including large unsigned values) will fail the check, preventing the array access. No counterexample exists where an OOB access occurs due to this server-supplied value.