# Bounds Checker Report — 20261005_103815_fs_smb_client

**Date:** 2026-10-05 10:43:24  
**Model:** gemini-2.5-flash  
**Source:** fs/smb/client  
**Files scanned:** 88

**Kernel:** `v7.3-rc5-339-ga9b5292a796a`  
**Branch:** `work/deferred`  
**Local commits** since `origin/master` (2):  
- `a9b5292a796a` smb: client: tighten validate_t2() offset bounds against actual buffer size
- `d40553f32a4e` smb: client: reject lease breaks with reserved NewLeaseState bits set

**Stage 1 findings:** 116 (Cat A: 21, Cat B: 33, Cat C: 7, Cat E: 31, Cat F: 13, Cat G2: 6, Cat H: 5 (+5 retired))  
**Stage 1.7 SMT:** 5 finding(s) retired by proof — excluded from the counts above and from the sections below; see `stage1_7_smt.json`  
**Stage 2 LLM:**  41 real bug(s)  |  75 false positive(s)  |  0 unanalyzed


---

## Contents

### `fs/smb/client/` — 67 functions, 41 real, 75 FP

- [open_cached_dir()](#open-cached-dir--fs-smb-client-cached-dir-c) — `cached_dir.c` — **BUG**
- [build_sec_desc()](#build-sec-desc--fs-smb-client-cifsacl-c) — `cifsacl.c` — **FP**
- [id_mode_to_cifs_acl()](#id-mode-to-cifs-acl--fs-smb-client-cifsacl-c) — `cifsacl.c` — **FP**
- [parse_dacl()](#parse-dacl--fs-smb-client-cifsacl-c) — `cifsacl.c` — **FP**
- [replace_sids_and_copy_aces()](#replace-sids-and-copy-aces--fs-smb-client-cifsacl-c) — `cifsacl.c` — **BUG**
- [set_chmod_dacl()](#set-chmod-dacl--fs-smb-client-cifsacl-c) — `cifsacl.c` — **FP**
- [validate_dacl()](#validate-dacl--fs-smb-client-cifsacl-c) — `cifsacl.c` — **FP**
- [CIFSFindFirst()](#cifsfindfirst--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSFindNext()](#cifsfindnext--fs-smb-client-cifssmb-c) — `cifssmb.c` — **FP**
- [CIFSGetExtAttr()](#cifsgetextattr--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSGetSrvInodeNumber()](#cifsgetsrvinodenumber--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSPOSIXCreate()](#cifsposixcreate--fs-smb-client-cifssmb-c) — `cifssmb.c` — **FP**
- [CIFSSMBPosixLock()](#cifssmbposixlock--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSSMBQAllEAs()](#cifssmbqalleas--fs-smb-client-cifssmb-c) — `cifssmb.c` — **MIXED**
- [CIFSSMBQFSAttributeInfo()](#cifssmbqfsattributeinfo--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSSMBQFSDeviceInfo()](#cifssmbqfsdeviceinfo--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSSMBQFSInfo()](#cifssmbqfsinfo--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSSMBQFSPosixInfo()](#cifssmbqfsposixinfo--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSSMBQFSUnixInfo()](#cifssmbqfsunixinfo--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [CIFSSMBRead()](#cifssmbread--fs-smb-client-cifssmb-c) — `cifssmb.c` — **FP**
- [CIFSSMBUnixQuerySymLink()](#cifssmbunixquerysymlink--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [SMBOldQFSInfo()](#smboldqfsinfo--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [cifs_create_reparse_inode()](#cifs-create-reparse-inode--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [cifs_query_reparse_point()](#cifs-query-reparse-point--fs-smb-client-cifssmb-c) — `cifssmb.c` — **FP**
- [cifs_to_posix_acl()](#cifs-to-posix-acl--fs-smb-client-cifssmb-c) — `cifssmb.c` — **BUG**
- [cifs_dump_full_key()](#cifs-dump-full-key--fs-smb-client-ioctl-c) — `ioctl.c` — **FP**
- [parse_dfs_referrals()](#parse-dfs-referrals--fs-smb-client-misc-c) — `misc.c` — **FP**
- [cnvrtDosUnixTm()](#cnvrtdosunixtm--fs-smb-client-netmisc-c) — `netmisc.c` — **FP**
- [mknod_wsl()](#mknod-wsl--fs-smb-client-reparse-c) — `reparse.c` — **FP**
- [parse_reparse_native_symlink()](#parse-reparse-native-symlink--fs-smb-client-reparse-c) — `reparse.c` — **BUG**
- [parse_reparse_nfs()](#parse-reparse-nfs--fs-smb-client-reparse-c) — `reparse.c` — **BUG**
- [parse_reparse_wsl_symlink()](#parse-reparse-wsl-symlink--fs-smb-client-reparse-c) — `reparse.c` — **FP**
- [is_valid_oplock_break()](#is-valid-oplock-break--fs-smb-client-smb1misc-c) — `smb1misc.c` — **BUG**
- [cifs_query_path_info()](#cifs-query-path-info--fs-smb-client-smb1ops-c) — `smb1ops.c` — **FP**
- [sess_auth_kerberos()](#sess-auth-kerberos--fs-smb-client-smb1session-c) — `smb1session.c` — **FP**
- [sess_auth_rawntlmssp_authenticate()](#sess-auth-rawntlmssp-authenticate--fs-smb-client-smb1session-c) — `smb1session.c` — **FP**
- [coalesce_t2()](#coalesce-t2--fs-smb-client-smb1transport-c) — `smb1transport.c` — **FP**
- [smb2_parse_symlink_response()](#smb2-parse-symlink-response--fs-smb-client-smb2file-c) — `smb2file.c` — **BUG**
- [symlink_data()](#symlink-data--fs-smb-client-smb2file-c) — `smb2file.c` — **FP**
- [check_wsl_eas()](#check-wsl-eas--fs-smb-client-smb2inode-c) — `smb2inode.c` — **FP**
- [parse_posix_sids()](#parse-posix-sids--fs-smb-client-smb2inode-c) — `smb2inode.c` — **FP**
- [reparse_buf_ptr()](#reparse-buf-ptr--fs-smb-client-smb2inode-c) — `smb2inode.c` — **BUG**
- [smb2_compound_op()](#smb2-compound-op--fs-smb-client-smb2inode-c) — `smb2inode.c` — **FP**
- [smb2_check_message()](#smb2-check-message--fs-smb-client-smb2misc-c) — `smb2misc.c` — **FP**
- [crypt_message()](#crypt-message--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [move_smb2_ea_to_cifs()](#move-smb2-ea-to-cifs--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [parse_server_interfaces()](#parse-server-interfaces--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [receive_encrypted_standard()](#receive-encrypted-standard--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [smb2_ioctl_query_info()](#smb2-ioctl-query-info--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [smb2_query_eas()](#smb2-query-eas--fs-smb-client-smb2ops-c) — `smb2ops.c` — **MIXED**
- [smb3_enum_snapshots()](#smb3-enum-snapshots--fs-smb-client-smb2ops-c) — `smb2ops.c` — **BUG**
- [smb3_fiemap()](#smb3-fiemap--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [smb3_simple_fallocate_range()](#smb3-simple-fallocate-range--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [SMB2_QFS_attr()](#smb2-qfs-attr--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **MIXED**
- [__smb2_plain_req_init()](#smb2-plain-req-init--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **FP**
- [decode_compress_ctx()](#decode-compress-ctx--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **BUG**
- [fill_small_buf()](#fill-small-buf--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **FP**
- [parse_posix_ctxt()](#parse-posix-ctxt--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **FP**
- [parse_query_id_ctxt()](#parse-query-id-ctxt--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **FP**
- [posix_info_parse()](#posix-info-parse--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **BUG**
- [query_info()](#query-info--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **FP**
- [smb2_parse_contexts()](#smb2-parse-contexts--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **FP**
- [smb311_decode_neg_context()](#smb311-decode-neg-context--fs-smb-client-smb2pdu-c) — `smb2pdu.c` — **MIXED**
- [smb2_calc_signature()](#smb2-calc-signature--fs-smb-client-smb2transport-c) — `smb2transport.c` — **FP**
- [smb2_seq_num_into_buf()](#smb2-seq-num-into-buf--fs-smb-client-smb2transport-c) — `smb2transport.c` — **FP**
- [smb3_calc_signature()](#smb3-calc-signature--fs-smb-client-smb2transport-c) — `smb2transport.c` — **FP**
- [__release_mid()](#release-mid--fs-smb-client-transport-c) — `transport.c` — **FP**


---

## Summary

| Function | File | Assessment | Conf | Real | FP | Unanalyzed |
|---|---|---|---|---|---|---|
| **`fs/smb/client/`** (67 fn) | | | | **41** | **75** | **0** |
| [open_cached_dir()](#open-cached-dir--fs-smb-client-cached-dir-c) | fs/smb/client/cached_dir.c | BUG | high | 1 | 0 | 0 |
| [build_sec_desc()](#build-sec-desc--fs-smb-client-cifsacl-c) | fs/smb/client/cifsacl.c | FP | high | 0 | 4 | 0 |
| [id_mode_to_cifs_acl()](#id-mode-to-cifs-acl--fs-smb-client-cifsacl-c) | fs/smb/client/cifsacl.c | FP | high | 0 | 3 | 0 |
| [parse_dacl()](#parse-dacl--fs-smb-client-cifsacl-c) | fs/smb/client/cifsacl.c | FP | high | 0 | 3 | 0 |
| [replace_sids_and_copy_aces()](#replace-sids-and-copy-aces--fs-smb-client-cifsacl-c) | fs/smb/client/cifsacl.c | BUG | high | 1 | 0 | 0 |
| [set_chmod_dacl()](#set-chmod-dacl--fs-smb-client-cifsacl-c) | fs/smb/client/cifsacl.c | FP | high | 0 | 1 | 0 |
| [validate_dacl()](#validate-dacl--fs-smb-client-cifsacl-c) | fs/smb/client/cifsacl.c | FP | high | 0 | 1 | 0 |
| [CIFSFindFirst()](#cifsfindfirst--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSFindNext()](#cifsfindnext--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | FP | high | 0 | 1 | 0 |
| [CIFSGetExtAttr()](#cifsgetextattr--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSGetSrvInodeNumber()](#cifsgetsrvinodenumber--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSPOSIXCreate()](#cifsposixcreate--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | FP | high | 0 | 2 | 0 |
| [CIFSSMBPosixLock()](#cifssmbposixlock--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSSMBQAllEAs()](#cifssmbqalleas--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | MIXED | high | 8 | 1 | 0 |
| [CIFSSMBQFSAttributeInfo()](#cifssmbqfsattributeinfo--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSSMBQFSDeviceInfo()](#cifssmbqfsdeviceinfo--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSSMBQFSInfo()](#cifssmbqfsinfo--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSSMBQFSPosixInfo()](#cifssmbqfsposixinfo--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSSMBQFSUnixInfo()](#cifssmbqfsunixinfo--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [CIFSSMBRead()](#cifssmbread--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | FP | high | 0 | 2 | 0 |
| [CIFSSMBUnixQuerySymLink()](#cifssmbunixquerysymlink--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 2 | 0 | 0 |
| [SMBOldQFSInfo()](#smboldqfsinfo--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [cifs_create_reparse_inode()](#cifs-create-reparse-inode--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 2 | 0 | 0 |
| [cifs_query_reparse_point()](#cifs-query-reparse-point--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | FP | high | 0 | 1 | 0 |
| [cifs_to_posix_acl()](#cifs-to-posix-acl--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | BUG | high | 1 | 0 | 0 |
| [cifs_dump_full_key()](#cifs-dump-full-key--fs-smb-client-ioctl-c) | fs/smb/client/ioctl.c | FP | high | 0 | 3 | 0 |
| [parse_dfs_referrals()](#parse-dfs-referrals--fs-smb-client-misc-c) | fs/smb/client/misc.c | FP | high | 0 | 3 | 0 |
| [cnvrtDosUnixTm()](#cnvrtdosunixtm--fs-smb-client-netmisc-c) | fs/smb/client/netmisc.c | FP | high | 0 | 1 | 0 |
| [mknod_wsl()](#mknod-wsl--fs-smb-client-reparse-c) | fs/smb/client/reparse.c | FP | high | 0 | 2 | 0 |
| [parse_reparse_native_symlink()](#parse-reparse-native-symlink--fs-smb-client-reparse-c) | fs/smb/client/reparse.c | BUG | high | 2 | 0 | 0 |
| [parse_reparse_nfs()](#parse-reparse-nfs--fs-smb-client-reparse-c) | fs/smb/client/reparse.c | BUG | high | 1 | 0 | 0 |
| [parse_reparse_wsl_symlink()](#parse-reparse-wsl-symlink--fs-smb-client-reparse-c) | fs/smb/client/reparse.c | FP | high | 0 | 2 | 0 |
| [is_valid_oplock_break()](#is-valid-oplock-break--fs-smb-client-smb1misc-c) | fs/smb/client/smb1misc.c | BUG | high | 1 | 0 | 0 |
| [cifs_query_path_info()](#cifs-query-path-info--fs-smb-client-smb1ops-c) | fs/smb/client/smb1ops.c | FP | high | 0 | 4 | 0 |
| [sess_auth_kerberos()](#sess-auth-kerberos--fs-smb-client-smb1session-c) | fs/smb/client/smb1session.c | FP | high | 0 | 2 | 0 |
| [sess_auth_rawntlmssp_authenticate()](#sess-auth-rawntlmssp-authenticate--fs-smb-client-smb1session-c) | fs/smb/client/smb1session.c | FP | high | 0 | 2 | 0 |
| [coalesce_t2()](#coalesce-t2--fs-smb-client-smb1transport-c) | fs/smb/client/smb1transport.c | FP | high | 0 | 3 | 0 |
| [smb2_parse_symlink_response()](#smb2-parse-symlink-response--fs-smb-client-smb2file-c) | fs/smb/client/smb2file.c | BUG | high | 2 | 0 | 0 |
| [symlink_data()](#symlink-data--fs-smb-client-smb2file-c) | fs/smb/client/smb2file.c | FP | high | 0 | 1 | 0 |
| [check_wsl_eas()](#check-wsl-eas--fs-smb-client-smb2inode-c) | fs/smb/client/smb2inode.c | FP | high | 0 | 2 | 0 |
| [parse_posix_sids()](#parse-posix-sids--fs-smb-client-smb2inode-c) | fs/smb/client/smb2inode.c | FP | high | 0 | 4 | 0 |
| [reparse_buf_ptr()](#reparse-buf-ptr--fs-smb-client-smb2inode-c) | fs/smb/client/smb2inode.c | BUG | high | 1 | 0 | 0 |
| [smb2_compound_op()](#smb2-compound-op--fs-smb-client-smb2inode-c) | fs/smb/client/smb2inode.c | FP | high | 0 | 1 | 0 |
| [smb2_check_message()](#smb2-check-message--fs-smb-client-smb2misc-c) | fs/smb/client/smb2misc.c | FP | high | 0 | 1 | 0 |
| [crypt_message()](#crypt-message--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 0 |
| [move_smb2_ea_to_cifs()](#move-smb2-ea-to-cifs--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 0 |
| [parse_server_interfaces()](#parse-server-interfaces--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 0 |
| [receive_encrypted_standard()](#receive-encrypted-standard--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 0 |
| [smb2_ioctl_query_info()](#smb2-ioctl-query-info--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 2 | 0 |
| [smb2_query_eas()](#smb2-query-eas--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | MIXED | high | 1 | 1 | 0 |
| [smb3_enum_snapshots()](#smb3-enum-snapshots--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | BUG | high | 1 | 0 | 0 |
| [smb3_fiemap()](#smb3-fiemap--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 0 |
| [smb3_simple_fallocate_range()](#smb3-simple-fallocate-range--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 0 |
| [SMB2_QFS_attr()](#smb2-qfs-attr--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | MIXED | high | 2 | 1 | 0 |
| [__smb2_plain_req_init()](#smb2-plain-req-init--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | FP | high | 0 | 1 | 0 |
| [decode_compress_ctx()](#decode-compress-ctx--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | BUG | high | 1 | 0 | 0 |
| [fill_small_buf()](#fill-small-buf--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | FP | high | 0 | 1 | 0 |
| [parse_posix_ctxt()](#parse-posix-ctxt--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | FP | high | 0 | 2 | 0 |
| [parse_query_id_ctxt()](#parse-query-id-ctxt--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | FP | high | 0 | 1 | 0 |
| [posix_info_parse()](#posix-info-parse--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | BUG | high | 3 | 0 | 0 |
| [query_info()](#query-info--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | FP | high | 0 | 1 | 0 |
| [smb2_parse_contexts()](#smb2-parse-contexts--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | FP | high | 0 | 4 | 0 |
| [smb311_decode_neg_context()](#smb311-decode-neg-context--fs-smb-client-smb2pdu-c) | fs/smb/client/smb2pdu.c | MIXED | high | 1 | 1 | 0 |
| [smb2_calc_signature()](#smb2-calc-signature--fs-smb-client-smb2transport-c) | fs/smb/client/smb2transport.c | FP | high | 0 | 1 | 0 |
| [smb2_seq_num_into_buf()](#smb2-seq-num-into-buf--fs-smb-client-smb2transport-c) | fs/smb/client/smb2transport.c | FP | high | 0 | 1 | 0 |
| [smb3_calc_signature()](#smb3-calc-signature--fs-smb-client-smb2transport-c) | fs/smb/client/smb2transport.c | FP | high | 0 | 1 | 0 |
| [__release_mid()](#release-mid--fs-smb-client-transport-c) | fs/smb/client/transport.c | FP | high | 0 | 1 | 0 |


---

## Function Details

### <a name="open-cached-dir--fs-smb-client-cached-dir-c"></a>open_cached_dir() — `fs/smb/client/cached_dir.c`

**Assessment:** BUG  |  **Confidence:** high

> The `smb2_validate_and_copy_iov` helper, via `smb2_validate_iov`, appears to sufficiently validate the upper bound of the `OutputBufferOffset` against the total received buffer length. However, it does not seem to enforce a lower bound for `OutputBufferOffset` relative to the fixed header size of the `smb2_query_info_rsp` structure. Allowing `OutputBufferOffset` to point into the header leads to misinterpretation of data and an out-of-bounds read relative to the expected payload structure.

#### Finding #1 — Category A — cross-function via `smb2_validate_and_copy_iov()` — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 384 |
| Taint snippet | `if (!smb2_validate_and_copy_iov(` |
| Tainted var | `le16_to_cpu(qi_rsp->OutputBufferOffset)` |
| Call site | line 384 — passes `le16_to_cpu(qi_rsp->OutputBufferOffset)` to `smb2_validate_and_copy_iov()` |
| Call snippet | `if (!smb2_validate_and_copy_iov(` |
| Sink (in callee) | `memcpy()` line 3900 (arg 1, role=pointer) |
| Sink snippet | `memcpy(data, begin_of_buf, minbufsize);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Incorrect directory metadata stored in cache due to misinterpretation of network response header as data; potential information disclosure or kernel panic if the malformed data is later used in a sensitive context (e.g., dereferencing a pointer that was actually a header field).

**Fix:** Add a lower-bound check for `OutputBufferOffset` before calling `smb2_validate_and_copy_iov`.

Specifically, at line 380 or before, ensure that `le16_to_cpu(qi_rsp->OutputBufferOffset)` is at least `sizeof(struct smb2_query_info_rsp)` (which is 72 bytes).

```c
	// ... existing code ...

	qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;
	/* SMB2_QUERY_INFO_RSP fixed header is 72 bytes. OutputBufferOffset must point past it. */
	if (le16_to_cpu(qi_rsp->OutputBufferOffset) < sizeof(struct smb2_query_info_rsp)) {
		sp_unlock(&cfids->cfid_list_lock);
		rc = -EINVAL; /* Or -EPROTO */
		goto oshr_free;
	}

	if (le32_to_cpu(qi_rsp->OutputBufferLength) < sizeof(struct smb2_file_all_info)) {
		spin_unlock(&cfids->cfid_list_lock);
		rc = -EINVAL;
		goto oshr_free;
	}
	// ... rest of code ...
```

**CVE pattern:** Missing lower-bound check on struct-internal offset



### <a name="build-sec-desc--fs-smb-client-cifsacl-c"></a>build_sec_desc() — `fs/smb/client/cifsacl.c`

**Assessment:** FP  |  **Confidence:** high

> The function `build_sec_desc` processes a server-supplied security descriptor (`pntsd`) and its length (`secdesclen`). Before the DACL pointer (`dacl_ptr`), derived from `pntsd` and `pntsd->dacloffset`, is used for reading its fields or traversing its ACEs, two layers of validation are applied:
1. `dacl_offset_valid(secdesclen, dacloffset)`: This function checks both lower and upper bounds for `dacloffset`. It ensures `dacloffset` is at least `sizeof(struct smb_ntsd)` (to be after the header) and that `dacloffset + sizeof(struct smb_acl)` fits within the overall `secdesclen` buffer.
2. `validate_dacl(dacl_ptr, end_of_acl)`: This function performs a comprehensive byte-level validation of the `smb_acl` structure (passed as `pdacl`) itself. It checks `pdacl->size`, `pdacl->num_aces`, and iterates through each embedded `smb_ace`, validating its size (`pace->size`) and internal fields like `pace->sid.num_subauth`. Crucially, it verifies that each ACE, including its variable-length SID, fits within the declared `dacl_size` and the overall `secdesclen` boundary. Any malformed or out-of-bounds structure will cause `validate_dacl` to return an error.

These validation steps ensure that all subsequent accesses to fields of `dacl_ptr` and any derived ACE pointers (`pntace`) using their internal length fields are guaranteed to be within the bounds of the `pntsd` buffer up to `secdesclen`. The functions `set_chmod_dacl` and `replace_sids_and_copy_aces` effectively re-traverse an already validated ACL structure.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 1448 |
| Taint snippet | `dacloffset = le32_to_cpu(pntsd->dacloffset);` |
| Tainted var | `dacl_ptr` |
| Pointer deref | `dacl_ptr->revision` line 1478 |
| Sink snippet | `dacloffset ? dacl_ptr->revision : cpu_to_le16(ACL_REVISION);` |
| Possibly guarded | no |

*Dismissed:* The `dacloffset` value is validated by `dacl_offset_valid(secdesclen, dacloffset)` which ensures it's within the `pntsd` buffer and allows space for `sizeof(struct smb_acl)`. Subsequently, `validate_dacl(dacl_ptr, end_of_acl)` is called, which performs a thorough validation of the entire `smb_acl` structure, including its header fields like `revision`. The access `dacl_ptr->revision` is therefore guaranteed to be in bounds. Counterexample test: If `dacloffset` were such that `dacl_ptr->revision` would be OOB, either `dacl_offset_valid` or `validate_dacl` would have returned an error, preventing this code path. E.g., if `dacloffset < sizeof(struct smb_ntsd)`, `dacl_offset_valid` would fail. If `dacloffset > secdesclen - sizeof(struct smb_acl)`, `dacl_offset_valid` would fail. If `dacl_ptr` itself was malformed, `validate_dacl` would fail. No counterexample found that bypasses these checks.


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

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 1448 |
| Taint snippet | `dacloffset = le32_to_cpu(pntsd->dacloffset);` |
| Tainted var | `dacl_ptr` |
| Call site | line 1456 — passes `dacl_ptr` to `validate_dacl()` |
| Call snippet | `rc = validate_dacl(dacl_ptr, end_of_acl);` |
| Pointer deref | `dacl_ptr->` line 900 |
| Sink snippet | `pace->sid.num_subauth == 0 ||` |
| Possibly guarded | no |

*Dismissed:* The sink is inside `validate_dacl()`, which is a dedicated validation function. Accesses within `validate_dacl()` (such as `pace->sid.num_subauth` or `le16_to_cpu(pace->size)`) are part of its validation logic. The function explicitly checks for `end_of_dacl - acl_base < ace_hdr_size` and bounds `pace->sid.num_subauth` (`> SID_MAX_SUB_AUTHORITIES`), and validates `pace->size` against remaining buffer size (`end_of_dacl - acl_base < ace_size`). If any of these checks fail, the function returns an error, preventing OOB access. Therefore, this is a false positive as the flagged accesses are guarded by the validation itself. Counterexample test: Any values for `pace->sid.num_subauth` or `pace->size` that would cause an OOB read would be caught by the explicit checks in lines 899, 907, or 914 within `validate_dacl`.


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

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 1448 |
| Taint snippet | `dacloffset = le32_to_cpu(pntsd->dacloffset);` |
| Tainted var | `dacl_ptr` |
| Call site | line 1483 — passes `dacl_ptr` to `set_chmod_dacl()` |
| Call snippet | `rc = set_chmod_dacl(dacl_ptr, ndacl_ptr, owner_sid_ptr, group_sid_ptr,` |
| Pointer deref | `dacl_ptr->` line 1287 |
| Sink snippet | `if (!new_aces_set && (pntace->flags & INHERITED_ACE)) {` |
| Possibly guarded | no |

*Dismissed:* The `dacl_ptr` (as `pdacl`) passed to `set_chmod_dacl` has already been thoroughly validated by `dacl_offset_valid()` and `validate_dacl()` in the calling function (`build_sec_desc`). The `validate_dacl` function ensures that `pdacl->num_aces` and `pntace->size` (used to advance `pntace`) are consistent with the overall `dacl_size` and `secdesclen`, and that the ACEs themselves are well-formed and fit within the buffer. The loop in `set_chmod_dacl` iterates using the validated `src_num_aces` and advances `pntace` based on `le16_to_cpu(pntace->size)`. Since `validate_dacl` already guarantees the safety of this traversal, accesses to `pntace->flags`, `pntace->sid`, and `pntace->size` are safe. Counterexample test: If `validate_dacl` (which is called prior to `set_chmod_dacl`) returns 0, it means the `smb_acl` structure and all its ACEs are properly bounded. Any `pntace->size` that would lead to OOB during traversal would have been detected by `validate_dacl`.


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

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 1448 |
| Taint snippet | `dacloffset = le32_to_cpu(pntsd->dacloffset);` |
| Tainted var | `dacl_ptr` |
| Call site | line 1562 — passes `dacl_ptr` to `replace_sids_and_copy_aces()` |
| Call snippet | `rc = replace_sids_and_copy_aces(dacl_ptr, ndacl_ptr,` |
| Pointer deref | `dacl_ptr->` line 1231 |
| Sink snippet | `if (pnownersid && compare_sids(&pntace->sid, pownersid) == 0) {` |
| Possibly guarded | no |

*Dismissed:* Similar to Finding #3, the `dacl_ptr` (as `pdacl`) passed to `replace_sids_and_copy_aces` has been fully validated by `dacl_offset_valid()` and `validate_dacl()` in the calling function (`build_sec_desc`). The `validate_dacl` function ensures the integrity of the `smb_acl` structure, including `pdacl->num_aces` and the sizes of individual ACEs (`pntace->size`). The loop in `replace_sids_and_copy_aces` traverses the `pdacl` based on these validated values. Therefore, accesses to `pntace->sid` are safe and within bounds. Counterexample test: If `validate_dacl` passes, it guarantees that traversing the ACL by reading `num_aces` and advancing by `ace->size` will remain within bounds. No counterexample found.



### <a name="id-mode-to-cifs-acl--fs-smb-client-cifsacl-c"></a>id_mode_to_cifs_acl() — `fs/smb/client/cifsacl.c`

**Assessment:** FP  |  **Confidence:** high

> The function employs a robust multi-stage validation strategy for the server-supplied security descriptor (pntsd) and its embedded DACL. First, the dacloffset is checked against the overall buffer size (secdesclen) using `dacl_offset_valid` to ensure the DACL header fits within the received data. Second, the `validate_dacl` function is then called on the derived `dacl_ptr` and the end-of-buffer pointer (`pntsd + secdesclen`). This `validate_dacl` function performs a thorough internal validation of the DACL's size, number of ACEs, and iterates through each ACE, performing bounds checks on its header and SID length. This layered validation effectively guards against the reported issues.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 1838 |
| Taint snippet | `dacloffset = le32_to_cpu(pntsd->dacloffset);` |
| Tainted var | `dacl_ptr` |
| Pointer deref | `dacl_ptr->num_aces` line 1859 |
| Sink snippet | `le16_to_cpu(dacl_ptr->num_aces) * sizeof(struct smb_ace);` |
| Possibly guarded | no |

*Dismissed:* The `dacloffset` (taint source) is validated by `dacl_offset_valid(secdesclen, dacloffset)` at line 1840. This function checks that `dacloffset >= sizeof(struct smb_ntsd)` (lower bound) and `dacloffset <= secdesclen - sizeof(struct smb_acl)` (upper bound). This ensures that the pointer `dacl_ptr` (derived from `pntsd + dacloffset`) points to a valid `struct smb_acl` header completely contained within the `pntsd` buffer. Immediately after this, `validate_dacl(dacl_ptr, (char *)pntsd + secdesclen)` is called. The sink `dacl_ptr->num_aces` at line 1859 is accessed *after* `validate_dacl` has already successfully returned (meaning it found no errors). `validate_dacl` explicitly reads `le16_to_cpu(pdacl->num_aces)` (where `pdacl` is `dacl_ptr`) at line 874 and uses it in subsequent bounds checks. Therefore, the access at line 1859 is fully validated and safe. Counterexample test: if `dacloffset` were such that `dacl_ptr->num_aces` would be OOB, `dacl_offset_valid` or `validate_dacl` would have returned an error, preventing execution from reaching line 1859.


#### Finding #2 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 1858 |
| Taint snippet | `nsecdesclen += sizeof(struct smb_acl) +` |
| Tainted var | `nsecdesclen` |
| Sink | `kzalloc()` line 1870 (arg 0, role=size) |
| Sink snippet | `pnntsd = kzalloc(nsecdesclen, GFP_KERNEL);` |
| Possibly guarded | no |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The tainted value `le16_to_cpu(dacl_ptr->num_aces)` is used in calculating `nsecdesclen`. While `num_aces` is server-supplied, it is bounded by the validation performed by `validate_dacl`. Specifically, `validate_dacl` at lines 881-883 performs the check `num_aces > (dacl_size - sizeof(struct smb_acl)) / min_ace_size`. Since `dacl_size` is itself bounded by `secdesclen` (the total length of the received buffer), this effectively bounds `num_aces` to be proportional to `secdesclen`. The calculation `le16_to_cpu(dacl_ptr->num_aces) * sizeof(struct smb_ace)` will therefore be proportional to `secdesclen`. For a typical maximum `secdesclen` of 64KB, the maximum `num_aces` is roughly 4096. This results in an allocation size for `nsecdesclen` (approximately 65KB + fixed overhead) that is proportional to the input buffer size and well within `u32` limits, preventing integer overflow and excessive allocation. Counterexample test: If `secdesclen=65536` and `dacl_size=65516`, `num_aces` is bounded at ~4094. `nsecdesclen` would be ~65KB, which is a reasonable and bounded allocation, not an overflow or an arbitrary size.


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

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 1838 |
| Taint snippet | `dacloffset = le32_to_cpu(pntsd->dacloffset);` |
| Tainted var | `dacl_ptr` |
| Call site | line 1847 — passes `dacl_ptr` to `validate_dacl()` |
| Call snippet | `rc = validate_dacl(dacl_ptr, (char *)pntsd + secdesclen);` |
| Pointer deref | `dacl_ptr->` line 900 |
| Sink snippet | `pace->sid.num_subauth == 0 ||` |
| Possibly guarded | no |

*Dismissed:* The sink `pace->sid.num_subauth` (and others) is located inside `validate_dacl`. As per false positive pattern #2 and #4, `validate_dacl` is itself a validation function whose purpose is to check the integrity and bounds of the DACL structure. Accesses within such a function, especially when accompanied by explicit bounds checks, are part of the validation logic and not vulnerable sinks. Line 899-901 directly checks `if (end_of_dacl - acl_base < ace_hdr_size)` before accessing `pace->sid.num_subauth`, ensuring that the access is within bounds of the `end_of_dacl` buffer. Additionally, the value of `pace->sid.num_subauth` is checked for sanity (`== 0 || > SID_MAX_SUB_AUTHORITIES`). Counterexample test: If `end_of_dacl - acl_base` were less than `ace_hdr_size` (12 bytes), the `if` condition at line 899 would be true, and the function would return `-EINVAL`, preventing the OOB read. Thus, the access is properly guarded.



### <a name="parse-dacl--fs-smb-client-cifsacl-c"></a>parse_dacl() — `fs/smb/client/cifsacl.c`

**Assessment:** FP  |  **Confidence:** high

> The `parse_dacl` function is protected by a call to `validate_dacl(pdacl, end_of_acl)` at line 942. The `validate_dacl` function's postcondition is critical here: 'On return 0, the entire DACL buffer starting at pdacl is confirmed to fit within [pdacl, end_of_acl): the DACL header fits, dacl_size is consistent, and 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 strong guarantee implies that all fields related to ACE sizing, counts, and internal structure (`num_aces`, `pace->size`, `pace->sid.num_subauth`) have been thoroughly validated by `validate_dacl` to prevent out-of-bounds accesses during subsequent parsing and processing. Any code path after a successful `validate_dacl` call can safely assume these values are consistent with the buffer bounds.

#### Finding #1 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 957 |
| Taint snippet | `num_aces = le16_to_cpu(pdacl->num_aces);` |
| Tainted var | `num_aces` |
| Loop | `for_loop` line 965 |
| Sink snippet | `for (i = 0; i < num_aces; ++i) {` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The taint source `num_aces = le16_to_cpu(pdacl->num_aces);` is indeed server-supplied. However, the `validate_dacl` function is called directly before this line. Its postcondition explicitly states that 'every ACE entry ... lies within the declared DACL bounds without exceeding end_of_acl.' This means `validate_dacl` must have iterated through all `num_aces` and checked the bounds of each ACE's `size` field, ensuring that the total length of all ACEs (as traversed by `acl_base + acl_size`) does not exceed `end_of_acl`. Therefore, if `validate_dacl` returns success, the loop `for (i = 0; i < num_aces; ++i)` and the pointer arithmetic `ppace[i] = (struct smb_ace *) (acl_base + acl_size)` are protected. No counterexample exists where `validate_dacl` returns successfully but an OOB occurs within this loop, because such a scenario would violate the validator's postcondition. Example test: If `num_aces` was excessively large or an `ace->size` field was malicious, `validate_dacl` would have returned non-zero, preventing execution of this loop.


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

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 957 |
| Taint snippet | `num_aces = le16_to_cpu(pdacl->num_aces);` |
| Tainted var | `ppace` |
| Call site | line 969 — passes `ppace` to `dump_ace()` |
| Call snippet | `dump_ace(ppace[i],` |
| Loop | `for_loop` line 839 |
| Sink snippet | `for (i = 0; i < num_subauth; ++i) {` |
| Possibly guarded | no |

*Dismissed:* The tainted variable `ppace` (representing `ppace[i]`) is derived from server-supplied `num_aces` and ACE `size` fields. The sink is within `dump_ace`, specifically the loop `for (i = 0; i < num_subauth; ++i)` accessing `pace->sid.sub_auth[i]`. As discussed for finding #1, `validate_dacl` guarantees that `ppace[i]` points to a valid ACE within `end_of_acl`. Furthermore, the `validate_dacl` postcondition explicitly covers the 'full sub-authority array' of each ACE. This means `pace->sid.num_subauth` has been validated to ensure that all accesses to `pace->sid.sub_auth[i]` within the bounds of `num_subauth` will be within the allocated ACE memory and will not exceed `end_of_acl`. The `dump_ace` function itself also contains checks for `pace->size` and `end_of_acl`. Therefore, this is a false positive due to the comprehensive validation by `validate_dacl`. No counterexample can bypass `validate_dacl` and cause an OOB read here. Example test: If `pace->sid.num_subauth` was maliciously large, `validate_dacl` would have failed.


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

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 957 |
| Taint snippet | `num_aces = le16_to_cpu(pdacl->num_aces);` |
| Tainted var | `ppace` |
| Call site | line 974 — passes `ppace` to `compare_sids()` |
| Call snippet | `(compare_sids(&(ppace[i]->sid),` |
| Loop | `for_loop` line 209 |
| Sink snippet | `for (i = 0; i < num_subauth; ++i) {` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* Similar to finding #2, the `ppace[i]->sid` structure is derived from server-supplied data, and the sink is `compare_sids` accessing `ctsid->sub_auth[i]` (which is `ppace[i]->sid.sub_auth[i]`). The `validate_dacl` function's postcondition directly addresses this: it guarantees that the 'full sub-authority array' of every ACE entry is valid and within bounds. This means `ppace[i]->sid.num_subauth` has been validated, ensuring that any access within its range will not cause an OOB read. Therefore, this is a false positive. No counterexample can bypass `validate_dacl` and cause an OOB read within `compare_sids`. Example test: If `ppace[i]->sid.num_subauth` was maliciously large, `validate_dacl` would have failed before `compare_sids` was called.



### <a name="replace-sids-and-copy-aces--fs-smb-client-cifsacl-c"></a>replace_sids_and_copy_aces() — `fs/smb/client/cifsacl.c`

**Assessment:** BUG  |  **Confidence:** high

> The function iterates over ACEs in a server-supplied ACL structure. The iteration count (`src_num_aces`) is derived directly from a server-supplied field (`pdacl->num_aces`). The offset for accessing individual ACEs (`size`) is a `u16` and can overflow given that `pdacl->size` is a `u32`. Furthermore, `size` is incremented by server-supplied ACE lengths (`pntace->size`) without validation against the total allocated buffer for the security descriptor or the explicit length of the DACL itself (`pdacl->size`).

The `validate_dacl` function in the caller (`build_sec_desc`) might perform some validation, but its source is not provided, so its postconditions cannot be verified. Per prompt instructions, the absence of the `validate_dacl` source means its protection cannot be assumed for this specific issue. Without such a robust prior validation that covers *all* ACE sub-elements and their cumulative size, the loop's accesses are vulnerable.

#### Finding #1 — Category F — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 1221 |
| Taint snippet | `src_num_aces = le16_to_cpu(pdacl->num_aces);` |
| Tainted var | `src_num_aces` |
| Loop | `for_loop` line 1227 |
| Sink snippet | `for (i = 0; i < src_num_aces; ++i) {` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic from heap-buffer-overflow, KASAN report, or information disclosure due to reading arbitrary kernel memory.

**Fix:** 1. Change the `size` variable (line 1210) from `u16` to `u32` or `size_t` to prevent integer overflow, as the total DACL size (`pdacl->size`) is `u32`.
2. Pass the effective end pointer of the DACL buffer (e.g., `(char *)pdacl + le32_to_cpu(pdacl->size)`) or the overall security descriptor buffer end (`end_of_acl`) into `replace_sids_and_copy_aces`.
3. Inside the loop (before line 1228), add explicit bounds checks:
   ```c
   char *dacl_end = (char *)pdacl + le32_to_cpu(pdacl->size); // Assuming pdacl->size is validated by validate_dacl
   if (acl_base + size < acl_base || acl_base + size + sizeof(struct smb_ace) > dacl_end) {
       cifs_dbg(VFS, "ACL ACE offset or header size out of bounds\n");
       return -EINVAL;
   }
   pntace = (struct smb_ace *) (acl_base + size);
   // ... read pntace->size ...
   u16 current_ace_len = le16_to_cpu(pntace->size);
   if (current_ace_len == 0 || acl_base + size + current_ace_len > dacl_end) {
       cifs_dbg(VFS, "ACL ACE invalid length or out of bounds\n");
       return -EINVAL;
   }
   // ... rest of the loop ...
   size += current_ace_len;
   ```
   The `pdacl->size` itself must be validated against the `secdesclen` by `validate_dacl` before this function is called. If `validate_dacl` guarantees the total DACL length, then that can be used as the boundary.

**CVE pattern:** SMB negotiation response arbitrary offset/length OOB



### <a name="set-chmod-dacl--fs-smb-client-cifsacl-c"></a>set_chmod_dacl() — `fs/smb/client/cifsacl.c`

**Assessment:** FP  |  **Confidence:** high

> The function `set_chmod_dacl` processes a `struct smb_acl` (`pdacl`) which is derived from a larger `struct smb_ntsd` (`pntsd`). Before `set_chmod_dacl` is called, its single caller `build_sec_desc` performs two key validation steps: `dacl_offset_valid` to ensure the DACL offset is within the overall security descriptor buffer, and `validate_dacl` on the `dacl_ptr` (which is `pdacl`) against `end_of_acl`. It is a common and robust pattern for such `validate_*` functions to perform a full traversal of the data structure (as described in pattern 5b), ensuring that all nested elements, including `num_aces` and individual ACE sizes, are consistent and within the allocated buffer. Assuming `validate_dacl` performs this comprehensive validation, the `src_num_aces` loop iteration count and the subsequent `pntace` pointer advancements and dereferences are protected by this prior validation. `set_chmod_dacl` is a static function, and its only call site shows this validation occurring beforehand, meaning `set_chmod_dacl` inherits these guarantees.

#### Finding #1 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 1281 |
| Taint snippet | `src_num_aces = le16_to_cpu(pdacl->num_aces);` |
| Tainted var | `src_num_aces` |
| Loop | `for_loop` line 1284 |
| Sink snippet | `for (i = 0; i < src_num_aces; ++i) {` |
| Possibly guarded | no |

*Dismissed:* The `src_num_aces` variable is derived from `pdacl->num_aces` (line 1281), which is read from a server-supplied `smb_acl` structure. This `pdacl` is passed to `set_chmod_dacl`. The `build_sec_desc` caller performs `rc = validate_dacl(dacl_ptr, end_of_acl);` (line 1456) before calling `set_chmod_dacl`. As per guideline 5b (Full-traversal validation), `validate_dacl` is expected to perform a full traversal validation. This means it verifies that `dacl_ptr->num_aces` (which becomes `src_num_aces`) is consistent with `dacl_ptr->size`, and that all individual ACEs (accessed via `acl_base + size` in the loop) with their respective `pntace->size` fields fit within the bounds indicated by `dacl_ptr->size` and `end_of_acl`. If `validate_dacl` ensures this (which is the typical behavior for a function named `validate_dacl` that receives the buffer and its end pointer), then the loop in `set_chmod_dacl` iterates over already-validated data, and the `size` pointer advancements and subsequent dereferences of `pntace->flags`, `pntace->sid`, and `pntace->size` are safe. Therefore, the loop iteration count and internal accesses are sufficiently protected by the prior `validate_dacl` call. Counterexample test: If `validate_dacl` were *not* performing a full traversal, a malicious `pdacl` could have `pdacl->num_aces = 5` and `pdacl->size` correctly reflecting the size of `sizeof(smb_acl) + 1*sizeof(smb_ace)`. However, the *first* ACE's `pntace->size` could be crafted to be very large (e.g., 1000). If `validate_dacl` only checked the total `pdacl->size` and `pdacl->num_aces` without summing individual ACE sizes, then the `set_chmod_dacl` loop, after processing the first ACE, would update `size` to `sizeof(smb_acl) + 1000`. The subsequent iteration would then attempt to dereference `pntace` far out of bounds (e.g., `acl_base + 1000`) before it reaches `src_num_aces`. However, a proper `validate_dacl` would sum the `pntace->size` values and compare this sum against `pdacl->size`, returning an error if inconsistent, thereby preventing this counterexample.



### <a name="validate-dacl--fs-smb-client-cifsacl-c"></a>validate_dacl() — `fs/smb/client/cifsacl.c`

**Assessment:** FP  |  **Confidence:** high

> The `validate_dacl` function implements robust per-iteration bounds checking within its loop. Although `num_aces` is server-supplied and controls the loop iteration count, the body of the loop validates the size of each ACE before advancing the pointer, effectively limiting the actual traversal length to the validated buffer size `dacl_size` and subsequently `end_of_dacl`. The pre-loop check at 881-884 also provides a coarse-grained validation for `num_aces` against the overall `dacl_size` based on a minimum ACE size. These combined checks are sufficient.

#### Finding #1 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 874 |
| Taint snippet | `num_aces = le16_to_cpu(pdacl->num_aces);` |
| Tainted var | `num_aces` |
| Loop | `for_loop` line 890 |
| Sink snippet | `for (i = 0; i < num_aces; ++i) {` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `num_aces` value (server-supplied) dictates the number of iterations. However, before entering the loop, `num_aces` is checked against `dacl_size` (which is itself validated against `end_of_acl`) using a minimum ACE size at line 881. This prevents excessively large `num_aces` values from causing issues if the `dacl_size` is small.

Inside the loop, the pointer `acl_base` is advanced based on `ace_size`. The crucial points are:
1. `ace_size` is initially `sizeof(struct smb_acl)`. `acl_base` starts at `pdacl`.
2. `pace = (struct smb_ace *)(acl_base + ace_size)`: `pace` is calculated, pointing to the *next* ACE.
3. `acl_base = (char *)pace`: `acl_base` is updated to the start of the *current* ACE being processed.
4. `if (end_of_dacl - acl_base < ace_hdr_size)` (line 899): Checks if the fixed header of the current ACE fits within the remaining buffer.
5. `ace_size = ace_hdr_size + sizeof(__le32) * pace->sid.num_subauth;` (line 906): Calculates the expected minimum size of the current ACE based on a server-supplied `num_subauth` field.
6. `if (end_of_dacl - acl_base < ace_size || le16_to_cpu(pace->size) < ace_size)` (line 907): Checks if the *calculated* minimum ACE size fits AND if the *reported* ACE size (`pace->size`) is not less than this minimum.
7. `ace_size = le16_to_cpu(pace->size);` (line 913): `ace_size` is updated to the full server-supplied `pace->size`.
8. `if (end_of_dacl - acl_base < ace_size)` (line 914): Checks if the *reported* full ACE size fits within the remaining buffer. This check is crucial, as the `ace_size` from this point will be used to advance `acl_base` in the *next* iteration. If this check passes, it guarantees that `acl_base + ace_size` will not exceed `end_of_dacl`.

Counterexample test: Let `pdacl` be a buffer of `100` bytes. `dacl_size` is `100`. `end_of_dacl` points to `pdacl + 100`. Assume `sizeof(struct smb_acl)` is `20`. If `num_aces` from `pdacl->num_aces` is `0xFFFF`. The check at line 881: `0xFFFF > (100 - 20) / min_ace_size` would likely trigger an `-EINVAL` if `min_ace_size` is reasonable (e.g., `80 / 16 = 5`). If `dacl_size` was also very large (e.g., `0xFFFFF`), allowing `num_aces` to be large, the per-iteration checks would take over. If `pace->sid.num_subauth` is huge, the check at 907 (`end_of_dacl - acl_base < ace_size`) would return `-EINVAL`. If `pace->size` is huge, the check at 914 (`end_of_dacl - acl_base < ace_size`) would return `-EINVAL`. In all scenarios, OOB access is prevented by these layered checks. Thus, no counterexample leads to an OOB access.



### <a name="cifsfindfirst--fs-smb-client-cifssmb-c"></a>CIFSFindFirst() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function processes a server-supplied SMB Transaction2 response. The `validate_t2` helper is called, but a detailed examination of its common implementation reveals it does not sufficiently validate `ParameterOffset` in combination with the expected struct size. Specifically, it primarily checks `TotalParameterCount` (not `ParameterCount`) and minimum `ParameterOffset`, but lacks a comprehensive check that `ParameterOffset + sizeof(target_struct)` remains within the actual received buffer length. The usage of `(char *)&pSMBr->hdr.Protocol` as a base for `ParameterOffset` is also unusual for SMB offsets, which are typically relative to the start of the SMB message. However, the finding is about the safety of the access given the code as written.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 4586 |
| Taint snippet | `parms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol +` |
| Tainted var | `parms` |
| Pointer deref | `parms->EndofSearch` line 4588 |
| Sink snippet | `psrch_inf->endOfSearch = !!parms->EndofSearch;` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** kernel panic from heap corruption (e.g., KASAN report) or undefined behavior if memory is mapped but invalid.

**Fix:** Add an explicit bounds check for the `ParameterOffset` and the expected size of `T2_FFIRST_RSP_PARMS` before casting and dereferencing `parms`. The check should ensure that the calculated `parms` address, plus `sizeof(T2_FFIRST_RSP_PARMS)`, does not exceed the total `bytes_returned` from `SendReceive`. Additionally, a lower-bound check should ensure `parms` does not point into the `smb_t2_rsp` header itself.

```c
	unsigned int param_offset_val = le16_to_cpu(pSMBr->t2.ParameterOffset);
	char *parms_calculated_addr = (char *)&pSMBr->hdr.Protocol + param_offset_val;

	// Check if the parameter struct starts before the end of the transaction2 response header
	// (SMB_HDR_SIZE + fixed part of smb_com_transaction2_rsp) is a reasonable lower bound for parameters
	// The offsetof(smb_hdr, Protocol) (4 bytes) needs to be factored in for the base pointer.
	// Assuming pSMBr->t2.SubCommand is the last fixed field before variable data.
	char *min_valid_param_start = (char *)&(pSMBr->t2.SubCommand) + sizeof(pSMBr->t2.SubCommand);

	if (parms_calculated_addr < min_valid_param_start ||
	    (parms_calculated_addr + sizeof(T2_FFIRST_RSP_PARMS)) > ((char *)pSMBr + bytes_returned)) {
		cifs_dbg(VFS, "malformed T2 response parameters: offset %u, expected size %zu, actual length %u\n",
			 param_offset_val, sizeof(T2_FFIRST_RSP_PARMS), bytes_returned);
		cifs_buf_release(pSMB);
		return -EINVAL;
	}
	parms = (T2_FFIRST_RSP_PARMS *)parms_calculated_addr;
```

**CVE pattern:** SMB negotiation response OOB read



### <a name="cifsfindnext--fs-smb-client-cifssmb-c"></a>CIFSFindNext() — `fs/smb/client/cifssmb.c`

**Assessment:** FP  |  **Confidence:** high

> The function uses `validate_t2` to perform bounds checking on the server response. This validator is called before parsing the `ParameterOffset` field and explicitly receives `sizeof(T2_FNEXT_RSP_PARMS)` as an argument, which matches the static analysis's guidance for a false positive.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 4696 |
| Taint snippet | `response_data = (char *)&pSMBr->hdr.Protocol +` |
| Tainted var | `parms` |
| Pointer deref | `parms->EndofSearch` line 4710 |
| Sink snippet | `psrch_inf->endOfSearch = !!parms->EndofSearch;` |
| Possibly guarded | no |

*Dismissed:* The `pSMBr->t2.ParameterOffset` field is read from the server-supplied `TRANSACTION2_FNEXT_RSP` buffer. This makes the pointer `parms` derived from it tainted.
However, the call to `validate_t2((struct smb_t2_rsp *)pSMBr, sizeof(T2_FNEXT_RSP_PARMS), 0)` at line 4689 occurs before `parms` is dereferenced. The prompt explicitly states that `validate_t2` is a validator that, if called with `sizeof(*parms)`, would establish safety for subsequent struct accesses. The second argument `sizeof(T2_FNEXT_RSP_PARMS)` ensures that the expected parameter structure fits within the received buffer at the offset specified by `ParameterOffset` (which is part of the `smb_t2_rsp` header validated by `validate_t2`). Thus, accessing `parms->EndofSearch` (and `parms->SearchCount`, `parms->LastNameOffset`) after `validate_t2` returns success (0) is considered safe.

Counterexample test:
Assume `bytes_returned` (total response size) is `sizeof(SMB_HDR) + sizeof(smb_t2_rsp_hdr) + 20` bytes.
Assume `pSMBr->t2.ParameterOffset = cpu_to_le16(10)`. (Relative to `&pSMBr->hdr.Protocol`)
`sizeof(T2_FNEXT_RSP_PARMS)` is 24 bytes.
`offsetof(T2_FNEXT_RSP_PARMS, EndofSearch)` is 20 bytes.

Without `validate_t2`, `response_data` would point to `(char *)&pSMBr->hdr.Protocol + 10`.
The access `parms->EndofSearch` would attempt to read at `(char *)&pSMBr->hdr.Protocol + 10 + 20 = (char *)&pSMBr->hdr.Protocol + 30`.
The total valid length of the response data (relative to `&pSMBr->hdr.Protocol`) is `bytes_returned - offsetof(TRANSACTION2_FNEXT_RSP, hdr.Protocol)`. Let's assume `offsetof(TRANSACTION2_FNEXT_RSP, hdr.Protocol)` is 4 bytes. So, total data is `sizeof(smb_t2_rsp_hdr) + 20 - 4`.
If `smb_t2_rsp_hdr` is 18 bytes, then data is `18 + 20 - 4 = 34` bytes. In this case, `30 < 34`, so it would be in bounds.

However, if `bytes_returned - offsetof(TRANSACTION2_FNEXT_RSP, hdr.Protocol)` was, for example, 25 bytes, then `30` would be OOB. The purpose of `validate_t2` is to prevent such scenarios by checking `ParameterOffset + sizeof(T2_FNEXT_RSP_PARMS) <= total_response_data_length`. Given the explicit guidance, we assume `validate_t2` covers this case.



### <a name="cifsgetextattr--fs-smb-client-cifssmb-c"></a>CIFSGetExtAttr() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function processes an SMB Transaction2 Query File Information response. The `validate_t2` call is explicitly noted as potentially insufficient (`/* BB also check enough total bytes returned */`). The subsequent check `count != 16` only validates the *claimed* data length, not that the `DataOffset` combined with this length and the base pointer is within the received buffer. The counterexample confirms an OOB read. Additionally, the base pointer for `DataOffset` calculation (`&pSMBr->hdr.Protocol`) seems inconsistent with typical SMB protocol interpretations where `DataOffset` is relative to the start of the `smb_hdr` (`pSMBr`). This secondary issue (misaligned base pointer) could lead to misinterpretation of data even if bounds were correctly checked, but the primary OOB remains.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 3775 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `pfinfo` |
| Pointer deref | `pfinfo->mode` line 3787 |
| Sink snippet | `*pExtAttrBits = le64_to_cpu(pfinfo->mode);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (due to reading unmapped memory), KASAN report, or silent data corruption.

**Fix:** A robust bounds check is required before deriving `pfinfo` and dereferencing it. The `data_offset` is relative to `&pSMBr->hdr.Protocol` in the current code, and the data length is `count` (which is 16). The total response length is `bytes_returned`. The access `pfinfo->mode` and `pfinfo->mask` involves reading 16 bytes starting from `&pSMBr->hdr.Protocol + data_offset`. Therefore, the following check is needed:
```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
			__u16 count = le16_to_cpu(pSMBr->t2.DataCount);
			struct file_chattr_info *pfinfo;

			if (count != sizeof(struct file_chattr_info)) {
				cifs_dbg(FYI, "Invalid size ret in GetExtAttr, expected %zu got %d\n",
					 sizeof(struct file_chattr_info), count);
				rc = smb_EIO2(smb_eio_trace_getextattr_inv_size, count, sizeof(struct file_chattr_info));
				goto GetExtAttrOut;
			}

			// Ensure data_offset + count does not exceed the received buffer bounds
			// Base for data_offset is `&pSMBr->hdr.Protocol`.
			// The end of the buffer is `(char *)pSMBr + bytes_returned`.
			// The access starts at `(char *)&pSMBr->hdr.Protocol + data_offset`
			// and ends at `(char *)&pSMBr->hdr.Protocol + data_offset + count`.
			// Thus, `offsetof(struct smb_hdr, Protocol) + data_offset + count` must be <= `bytes_returned`.
			if (offsetof(struct smb_hdr, Protocol) + data_offset + count > bytes_returned ||
			    offsetof(struct smb_hdr, Protocol) + data_offset < offsetof(struct smb_hdr, Protocol)) { // overflow or underflow check
				cifs_dbg(FYI, "SMB: ExtAttr data out of response buffer bounds: offset=%u, count=%u, total_len=%u\n",
					 data_offset, count, bytes_returned);
				rc = smb_EIO2(smb_eio_trace_getextattr_data_oob, data_offset, bytes_returned);
				goto GetExtAttrOut;
			}

			pfinfo = (struct file_chattr_info *)
				 (data_offset + (char *) &pSMBr->hdr.Protocol);
```
It might also be necessary to confirm the exact base for `DataOffset` (i.e., `pSMBr` or `&pSMBr->hdr.Protocol`) based on SMB specification, and adjust the `pfinfo` calculation and bounds check accordingly.

**CVE pattern:** SMB_Transaction2_DataOffset_OOB_Read



### <a name="cifsgetsrvinodenumber--fs-smb-client-cifssmb-c"></a>CIFSGetSrvInodeNumber() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function parses a TRANSACTION2_QPI_RSP server response. The DataOffset and DataCount fields from this response are used to construct a pointer into the response buffer and access a struct field. While a minimum size check (`count < 8`) is present for the data length, there is no corresponding check to ensure that the server-supplied DataOffset, combined with the expected data size, does not point past the end of the received buffer. The `validate_t2` call in this context validates the *parameter* portion of the response (minimum `sizeof(struct file_internal_info)` bytes), not the *data* portion where `DataOffset` and `DataCount` apply. This leaves an exploitable out-of-bounds read vulnerability.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 4841 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `pfinfo` |
| Pointer deref | `pfinfo->UniqueId` line 4853 |
| Sink snippet | `*inode_number = le64_to_cpu(pfinfo->UniqueId);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (due to invalid memory access), KASAN report, or general system instability if the server-supplied DataOffset is sufficiently large to cause an out-of-bounds read when accessing `pfinfo->UniqueId`.

**Fix:** Before line 4852 (the pointer derivation), add a check to ensure `data_offset + sizeof(struct file_internal_info)` does not exceed the actual length of the received response buffer relative to the base address used for the offset. The effective base for the offset is `&pSMBr->hdr.Protocol`. The total valid length of the response is `bytes_returned`. The check should be:

```c
			if (((char *)&pSMBr->hdr.Protocol - (char *)pSMBr) + data_offset + sizeof(struct file_internal_info) > bytes_returned) {
				cifs_dbg(FYI, "Invalid data offset or count in QryIntrnlInf\n");
				rc = smb_EIO2(smb_eio_trace_getsrvinonum_data_oob, data_offset, count);
				goto GetInodeNumOut;
			}
```

Additionally, consider tightening the `count` check to `if (count != sizeof(struct file_internal_info))` since `file_internal_info` is a fixed-size struct for `UniqueId`.

**CVE pattern:** SMB DataOffset OOB



### <a name="cifsposixcreate--fs-smb-client-cifssmb-c"></a>CIFSPOSIXCreate() — `fs/smb/client/cifssmb.c`

**Assessment:** FP  |  **Confidence:** high

> The CIFSPOSIXCreate function constructs an SMB Transaction2 request and then processes the server's Transaction2 response. The primary validation for server-supplied offsets and counts within the Transaction2 response header (specifically pSMBr->t2.DataOffset and pSMBr->t2.DataCount) is performed by the `validate_t2` helper function at line 1176. This helper is called before any use of the tainted DataOffset field and is expected to establish that the provided DataOffset and DataCount (given the minimum expected length) are safe to use within the received buffer. An additional check using get_bcc() is also present before the memcpy, providing further assurance.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 1186 |
| Taint snippet | `psx_rsp = (OPEN_PSX_RSP *)` |
| Tainted var | `psx_rsp` |
| Pointer deref | `psx_rsp->OplockFlags` line 1189 |
| Sink snippet | `*pOplock = le16_to_cpu(psx_rsp->OplockFlags);` |
| Possibly guarded | no |

*Dismissed:* The pointer `psx_rsp` is derived from `le16_to_cpu(pSMBr->t2.DataOffset)`, which is a server-supplied value from the Transaction2 response. However, the `validate_t2` function (line 1176) is called *before* `psx_rsp` is calculated. The prompt explicitly states that 'a helper that validates offset+len fits within a buffer makes subsequent struct pointer accesses at that offset safe'. `validate_t2` is called with `pSMBr` and `sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO)` as the minimum expected data length. If `validate_t2` functions as described (ensuring that `DataOffset + DataCount` is within the total `bytes_returned` and `DataCount` is at least the `min_data_len`), then `le16_to_cpu(pSMBr->t2.DataOffset) + sizeof(OPEN_PSX_RSP)` will be within the received buffer bounds. Therefore, accessing `psx_rsp->OplockFlags` and other fields within the `OPEN_PSX_RSP` structure is protected. A counterexample would require `validate_t2` to pass while `DataOffset + sizeof(OPEN_PSX_RSP)` exceeds `bytes_returned` (e.g., `bytes_returned = 100`, `DataOffset = 90`, `sizeof(OPEN_PSX_RSP) = 20`), which contradicts the assumed purpose and postcondition of `validate_t2` as a bounds validator.


#### Finding #2 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 1186 |
| Taint snippet | `psx_rsp = (OPEN_PSX_RSP *)` |
| Tainted var | `psx_rsp` |
| Sink | `memcpy()` line 1207 (arg 1, role=pointer) |
| Sink snippet | `memcpy(pRetData,` |
| Possibly guarded | no |

*Dismissed:* The `memcpy` source is `(char *)psx_rsp + sizeof(OPEN_PSX_RSP)` and it copies `sizeof(*pRetData)` (which is `sizeof(FILE_UNIX_BASIC_INFO)`) bytes. As discussed for finding #1, the `validate_t2` call at line 1176 is crucial. It is called with `sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO)` as the expected minimum data length. Assuming `validate_t2` correctly checks that `DataOffset + DataCount` is within the total received buffer (`bytes_returned`) and that `DataCount` is at least the specified minimum length, then the region starting at `psx_rsp + sizeof(OPEN_PSX_RSP)` of size `sizeof(FILE_UNIX_BASIC_INFO)` is guaranteed to be within bounds. An additional explicit check at line 1201 (`get_bcc(&pSMBr->hdr) < sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO)`) further validates the overall message byte count before the memcpy. Therefore, the memory copy is adequately protected.



### <a name="cifssmbposixlock--fs-smb-client-cifssmb-c"></a>CIFSSMBPosixLock() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function parses a server-supplied Transaction2 response for POSIX lock information. It uses DataOffset and DataCount from the response to locate and interpret a `struct cifs_posix_lock`. While several checks are present (validate_t2, get_bcc, data_count vs sizeof), none of them sufficiently validate the server-supplied DataOffset against the actual length of the received network buffer. This allows a malicious server to provide an out-of-bounds DataOffset, leading to an OOB read.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 2439 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `parm_data` |
| Pointer deref | `parm_data->lock_type` line 2448 |
| Sink snippet | `if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic due to out-of-bounds read, BUG: KASAN: slab-out-of-bounds in CIFSSMBPosixLock

**Fix:** Before deriving `parm_data` at line 2446, explicitly validate `data_offset + sizeof(struct cifs_posix_lock)` against the actual received buffer length. The `data_offset` is relative to `&pSMBr->hdr.Protocol`. The total valid length from that point is `actual_received_len - offsetof(struct smb_hdr, Protocol)`. Additionally, `data_offset` must be greater than or equal to `sizeof(struct smb_t2_rsp)` to prevent it from pointing into the fixed header of the Transaction2 response.

Example fix (insert before line 2446):
```c
		__u32 actual_resp_len;
		if (waitFlag) {
			actual_resp_len = bytes_returned;
		} else {
			actual_resp_len = rsp_iov.iov_len;
		}

		// DataOffset is relative to pSMBr->hdr.Protocol. 
		// So, total available length for data payload is actual_resp_len - offsetof(struct smb_hdr, Protocol)
		if (data_offset < sizeof(struct smb_t2_rsp) ||
		    data_offset + sizeof(struct cifs_posix_lock) > (actual_resp_len - offsetof(struct smb_hdr, Protocol))) {
			cifs_dbg(VFS, "posix lock data offset %u, data_count %u, total_resp_len %u invalid\n",
				 data_offset, data_count, actual_resp_len);
			rc = smb_EIO2(smb_eio_trace_lock_data_oob, data_offset, actual_resp_len);
			goto plk_err_exit;
		}
```

**CVE pattern:** CVE-YYYY-NNNN style DataOffset OOB



### <a name="cifssmbqalleas--fs-smb-client-cifssmb-c"></a>CIFSSMBQAllEAs() — `fs/smb/client/cifssmb.c`

**Assessment:** MIXED  |  **Confidence:** high

> The primary issue in this function is the insufficient validation of the server-supplied 'DataOffset' field (from pSMBr->t2.DataOffset) before it's used to derive the base pointer 'ea_response_data' and subsequent pointers like 'temp_fea' and 'temp_ptr'. While there are checks for 'list_len' and the sizes of individual EA entries against the overall SMB message boundary (end_of_smb) and destination buffer sizes (buf_size), these checks occur *after* the base pointer has already been established using the unvalidated 'DataOffset'. If 'DataOffset' is malicious and points 'ea_response_data' outside the received SMB buffer, then any dereference through 'ea_response_data', 'temp_fea', or 'temp_ptr' will result in an out-of-bounds read, regardless of subsequent length checks. The comments in the code ('BB we need to improve the validity checking...', 'BB check if start of smb + data_offset > &bcc+ bcc') explicitly indicate this known deficiency.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `ea_response_data` |
| Pointer deref | `ea_response_data->list_len` line 6305 |
| Sink snippet | `list_len = le32_to_cpu(ea_response_data->list_len);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Before using `data_offset` to construct `ea_response_data`, validate that `data_offset` is at least `offsetof(struct smb_com_transaction2_qpi_rsp, t2.DataOffset)` (or similar minimum header size) and that `data_offset + sizeof(struct fealist)` does not exceed the total received SMB message size (`bytes_returned` from `SendReceive`). This should happen before line 6303.

**CVE pattern:** SMB DataOffset OOB


#### Finding #2 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `ea_response_data` |
| Pointer deref | `ea_response_data->list` line 6327 |
| Sink snippet | `temp_fea = &ea_response_data->list;` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Before using `data_offset` to construct `ea_response_data`, validate that `data_offset` is at least `offsetof(struct smb_com_transaction2_qpi_rsp, t2.DataOffset)` (or similar minimum header size) and that `data_offset + sizeof(struct fealist)` does not exceed the total received SMB message size (`bytes_returned` from `SendReceive`). This should happen before line 6303.

**CVE pattern:** SMB DataOffset OOB


#### Finding #3 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le32_to_cpu()` line 6305 |
| Taint snippet | `list_len = le32_to_cpu(ea_response_data->list_len);` |
| Tainted var | `list_len` |
| Loop | `while_loop` line 6329 |
| Sink snippet | `while (list_len > 0) {` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `list_len` variable, while server-supplied, is checked at line 6316: `if ((char *)ea_response_data + list_len > end_of_smb)`. This ensures that the total length indicated by `list_len` does not exceed the actual received buffer. Although `ea_response_data` itself might be an OOB pointer (as per findings 1, 2, 4), the `list_len` variable itself is correctly bounded against the effective end of the SMB message. The loop then subtracts from this already-bounded `list_len`, and checks `if (list_len < 0)` ensure internal consistency. The vulnerability lies in the base pointer `ea_response_data` being potentially OOB, not in `list_len`'s control over iteration after its initial validation.


#### Finding #4 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `temp_fea` |
| Pointer deref | `temp_fea->name_len` line 6342 |
| Sink snippet | `name_len = temp_fea->name_len;` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Before using `data_offset` to construct `ea_response_data` (lines 6303-6304), validate that `data_offset` is at least `offsetof(struct smb_com_transaction2_qpi_rsp, t2.DataOffset)` (or similar minimum header size) and that `data_offset + sizeof(struct fealist)` does not exceed the total received SMB message size (`bytes_returned` from `SendReceive`). Without this, `temp_fea` can point OOB, leading to OOB reads for `name_len` and `value_len`. 
Counterexample: Assume `bytes_returned` from `SendReceive` is 100. If `pSMBr->t2.DataOffset` is crafted to be `99`, then `ea_response_data` points to `&pSMBr->hdr.Protocol + 99`. The `fealist` structure starts with `list_len` (4 bytes). `ea_response_data->list` is immediately after `list_len`. So `temp_fea` points to `&pSMBr->hdr.Protocol + 99 + 4 = &pSMBr->hdr.Protocol + 103`. The `end_of_smb` check at 6316 validates `list_len` relative to this `ea_response_data` pointer, but if `ea_response_data` is already OOB, subsequent dereferences via `temp_fea` will be OOB. Reading `temp_fea->name_len` (which is at `offsetof(struct fea, attribute_name_length)` from `temp_fea`) will read OOB.

**CVE pattern:** SMB DataOffset OOB


#### Finding #5 — Category B — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `name_len` |
| Sink | `memcmp()` line 6353 (arg 2, role=size) |
| Sink snippet | `memcmp(ea_name, temp_ptr, name_len) == 0) {` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Fix lies in properly validating the base pointer `ea_response_data` (see finding #1, #2, #4). Even if `name_len` is internally consistent with `list_len`, if `temp_ptr` (the source buffer for `memcmp`) is itself OOB due to an unvalidated `data_offset`, the `memcmp` will OOB read. 
Counterexample: Same as finding #4. If `temp_ptr` is OOB, `memcmp(ea_name, temp_ptr, name_len)` reads OOB. This specific `name_len` (size arg) is bounded by `list_len` (line 6344), but this doesn't protect the source pointer `temp_ptr` if it's already OOB.

**CVE pattern:** SMB DataOffset OOB


#### Finding #6 — Category A — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `temp_ptr` |
| Sink | `memcmp()` line 6353 (arg 1, role=pointer) |
| Sink snippet | `memcmp(ea_name, temp_ptr, name_len) == 0) {` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Fix lies in properly validating the base pointer `ea_response_data` (see finding #1, #2, #4). If `temp_ptr` is OOB due to an unvalidated `data_offset`, `memcmp` will OOB read. 
Counterexample: Same as finding #4. If `temp_ptr` is OOB, `memcmp(ea_name, temp_ptr, name_len)` reads OOB.

**CVE pattern:** SMB DataOffset OOB


#### Finding #7 — Category B — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 6343 |
| Taint snippet | `value_len = le16_to_cpu(temp_fea->value_len);` |
| Tainted var | `value_len` |
| Sink | `memcpy()` line 6362 (arg 2, role=size) |
| Sink snippet | `memcpy(EAData, temp_ptr, value_len);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Fix lies in properly validating the base pointer `ea_response_data` (see finding #1, #2, #4). While `value_len` is validated against the destination buffer `buf_size` (line 6358) and against the remaining `list_len` for the source (line 6344), the source pointer `temp_ptr` for `memcpy` is still derived from an unvalidated `data_offset`. If `temp_ptr` is OOB, `memcpy` will perform an OOB read. 
Counterexample: Same as finding #4. If `temp_ptr` is OOB, `memcpy(EAData, temp_ptr, value_len)` reads OOB.

**CVE pattern:** SMB DataOffset OOB


#### Finding #8 — Category A — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `temp_ptr` |
| Sink | `memcpy()` line 6362 (arg 1, role=pointer) |
| Sink snippet | `memcpy(EAData, temp_ptr, value_len);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Fix lies in properly validating the base pointer `ea_response_data` (see finding #1, #2, #4). If `temp_ptr` is OOB due to an unvalidated `data_offset`, `memcpy` will OOB read. 
Counterexample: Same as finding #4. If `temp_ptr` is OOB, `memcpy(EAData, temp_ptr, value_len)` or `memcpy(EAData, temp_ptr, name_len)` reads OOB.

**CVE pattern:** SMB DataOffset OOB


#### Finding #9 — Category B — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 6301 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `name_len` |
| Sink | `memcpy()` line 6371 (arg 2, role=size) |
| Sink snippet | `memcpy(EAData, temp_ptr, name_len);` |
| Possibly guarded | no |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** kernel panic or information disclosure from reading arbitrary kernel memory

**Fix:** Fix lies in properly validating the base pointer `ea_response_data` (see finding #1, #2, #4). While `name_len` is validated against the destination buffer `buf_size` (line 6368) and against the remaining `list_len` for the source (line 6344), the source pointer `temp_ptr` for `memcpy` is still derived from an unvalidated `data_offset`. If `temp_ptr` is OOB, `memcpy` will perform an OOB read. 
Counterexample: Same as finding #4. If `temp_ptr` is OOB, `memcpy(EAData, temp_ptr, name_len)` reads OOB.

**CVE pattern:** SMB DataOffset OOB



### <a name="cifssmbqfsattributeinfo--fs-smb-client-cifssmb-c"></a>CIFSSMBQFSAttributeInfo() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function receives server-supplied data and extracts a `DataOffset` from it. While there are some validation calls (`validate_t2` and `get_bcc`), they do not sufficiently guard against an out-of-bounds read when using the `DataOffset` to calculate a pointer for a subsequent `memcpy`. The code itself contains a comment `/* BB also check if enough bytes returned */` at line 5225, indicating that the developers were aware of a potential missing bounds check for the data returned in the response. The `validate_t2` call does not appear to validate the server-supplied `DataOffset` with respect to the actual `bytes_returned` length, nor does `get_bcc` provide this specific guarantee.

#### Finding #1 — Category A — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 5230 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Sink | `memcpy()` line 5235 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&tcon->fsAttrInfo, response_data,` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or crash from reading invalid memory, or potential information disclosure.

**Fix:** Add an explicit bounds check before the `memcpy` to ensure that the calculated `response_data` pointer plus the size of `FILE_SYSTEM_ATTRIBUTE_INFO` does not exceed the actual `bytes_returned` buffer size. The `DataOffset` should be checked against `bytes_returned - (offset_of_Protocol_field_in_pSMBr) - sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)`.

**CVE pattern:** SMB DataOffset OOB read



### <a name="cifssmbqfsdeviceinfo--fs-smb-client-cifssmb-c"></a>CIFSSMBQFSDeviceInfo() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function receives a server response and extracts an offset (DataOffset) to locate data within that response. While there are checks for the overall message length and the reported payload ByteCount, there is no explicit validation of the extracted DataOffset itself against the received buffer's boundaries. This allows a malicious server to provide an out-of-bounds DataOffset, leading to an OOB read during a subsequent memcpy operation.

#### Finding #1 — Category A — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 5305 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Sink | `memcpy()` line 5310 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&tcon->fsDevInfo, response_data,` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** kernel panic from heap corruption, BUG: KASAN: slab-out-of-bounds Read, or potential information disclosure.

**Fix:** Before using `data_offset` to construct `response_data`, add explicit bounds checks:
1. Ensure `data_offset` is not too small (e.g., points past the fixed headers of the SMB and Transaction2 response).
2. Ensure `data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO)` does not exceed the total actual bytes received (`bytes_returned`).

Example fix:
```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);

			// Ensure data_offset is within the received buffer and points past fixed headers.
			// DataOffset is relative to the start of the SMB header (pSMBr).
			// A reasonable lower bound would be the size of the combined SMB and T2 headers.
			if (data_offset < (sizeof(struct smb_hdr) + offsetof(struct smb_t2_rsp, SetupCount)) || // Points past fixed headers before variable data
			    (unsigned long)data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > bytes_returned) {
				cifs_dbg(VFS, "Bad DataOffset or data size. Offset: %u, Size: %zu, Bytes Rcvd: %d\n",
					 data_offset, sizeof(FILE_SYSTEM_DEVICE_INFO), bytes_returned);
				rc = smb_EIO2(smb_eio_trace_qfsdevinfo_bad_offset, data_offset,
					      sizeof(FILE_SYSTEM_DEVICE_INFO));
				goto cifs_buf_release; // Assuming cifs_buf_release is the cleanup label
			}

			response_data =
			    (FILE_SYSTEM_DEVICE_INFO *) \
				(((char *) &pSMBr->hdr.Protocol) + data_offset);
			memcpy(&tcon->fsDevInfo, response_data,
			       sizeof(FILE_SYSTEM_DEVICE_INFO));
```
Note: The exact lower bound for `data_offset` might need further refinement based on precise `smb_t2_rsp` structure and where the variable data is *expected* to start. Using `offsetof(struct smb_t2_rsp, SetupCount)` implies the data cannot overlap with the `t2` struct's metadata fields. The `bytes_returned` variable correctly represents the actual received buffer size.

**CVE pattern:** CVE-YYYY-NNNN style DataOffset OOB



### <a name="cifssmbqfsinfo--fs-smb-client-cifssmb-c"></a>CIFSSMBQFSInfo() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The static analysis finding is a real bug caused by an incorrect base pointer calculation for a server-supplied offset. The `DataOffset` field in SMB Transaction2 responses is defined as an offset from the beginning of the `smb_hdr`. The `validate_t2` function (which is `cifs_validate_t2_rsp` in current kernels) correctly validates that `pSMBr->t2.DataOffset + pSMBr->t2.DataCount` fits within the `bytes_returned` total message length. However, the code then constructs the `response_data` pointer using `((char *) &pSMBr->hdr.Protocol) + data_offset`. This incorrectly adds `offsetof(struct smb_hdr, Protocol)` to the `data_offset`. As `offsetof(struct smb_hdr, Protocol)` is typically a positive value (e.g., 4 bytes), this shifts the calculated `response_data` pointer further into the buffer than intended and validated. If the server-supplied `DataOffset` and `DataCount` cause the data block to end exactly at the `bytes_returned` boundary (a valid scenario per `validate_t2`), the additional offset from `&pSMBr->hdr.Protocol` will cause `response_data` to point `offsetof(struct smb_hdr, Protocol)` bytes beyond the end of the received buffer, leading to an Out-of-Bounds Read when dereferenced.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 5139 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Pointer deref | `response_data->BytesPerSector` line 5146 |
| Sink snippet | `le32_to_cpu(response_data->BytesPerSector) *` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., KASAN report: slab-out-of-bounds read), information disclosure from reading adjacent kernel memory, or silent data corruption.

**Fix:** Correct the calculation of the `response_data` pointer to use the correct base address for `DataOffset`, which is the start of the SMB header. Change line 5143 from:
`response_data = (FILE_SYSTEM_SIZE_INFO *) (((char *) &pSMBr->hdr.Protocol) + data_offset);`
to:
`response_data = (FILE_SYSTEM_SIZE_INFO *) (((char *) pSMBr) + data_offset);`
This ensures that the pointer calculation aligns with the `DataOffset` definition and the `validate_t2` check.

**CVE pattern:** SMB transaction2 response OOB read due to incorrect pointer arithmetic with server-supplied offset



### <a name="cifssmbqfsposixinfo--fs-smb-client-cifssmb-c"></a>CIFSSMBQFSPosixInfo() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function `CIFSSMBQFSPosixInfo` processes a server-supplied Transaction2 response. The `validate_t2` function is called to validate the response's structure, including the data portion. However, the subsequent pointer arithmetic for `response_data` incorrectly uses `&pSMBr->hdr.Protocol` as a base, adding an extra offset (typically 4 bytes) to `pSMBr->t2.DataOffset`, which is generally defined as an offset from the start of the SMB header (`pSMBr`). This mismatch between the base assumed by the validation (likely `pSMBr`) and the base used for pointer construction (`pSMBr + 4`) can lead to an out-of-bounds read.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 5526 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Pointer deref | `response_data->BlockSize` line 5532 |
| Sink snippet | `le32_to_cpu(response_data->BlockSize);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from out-of-bounds read or data corruption

**Fix:** The `DataOffset` field in SMB Transaction2 responses is typically an offset from the beginning of the SMB header (`pSMBr`). The current code calculates `response_data` using `((char *) &pSMBr->hdr.Protocol) + data_offset`. Since `&pSMBr->hdr.Protocol` is typically `pSMBr + 4` (offset of the Protocol field within the SMB header), this adds an unnecessary 4-byte offset. The `response_data` pointer should be derived directly from the start of the SMB header (`pSMBr`) plus `data_offset` to match the standard interpretation and the likely behavior of `validate_t2`:
`response_data = (FILE_SYSTEM_POSIX_INFO *) (((char *) pSMBr) + data_offset);`

**CVE pattern:** SMB Transaction2 response parsing OOB



### <a name="cifssmbqfsunixinfo--fs-smb-client-cifssmb-c"></a>CIFSSMBQFSUnixInfo() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function receives an SMB Transaction2 Query File System Information response. The server-supplied DataOffset field is used to calculate the start of the response data (FILE_SYSTEM_UNIX_INFO). While some validation of the overall response size (via `validate_t2` and `get_bcc`) is performed, there is no explicit check that the `DataOffset` value, combined with the size of the expected data (`sizeof(FILE_SYSTEM_UNIX_INFO)`), remains within the bounds of the actually received data block. This allows a malicious server to specify an out-of-bounds `DataOffset`, leading to an OOB read during the subsequent `memcpy` operation.

#### Finding #1 — Category A — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 5377 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Sink | `memcpy()` line 5382 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&tcon->fsUnixInfo, response_data,` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (KASAN: slab-out-of-bounds Read) or information disclosure if sensitive kernel data is read.

**Fix:** Add a bounds check before using `data_offset` to derive `response_data`. The check should ensure that `data_offset` is greater than or equal to the minimum expected offset for the data block (i.e., after the fixed Transaction2 response header) and that `data_offset + sizeof(FILE_SYSTEM_UNIX_INFO)` does not exceed the `ByteCount` field (`bcc`) which defines the actual length of the parameter/data block following the SMB header. 

Specifically, after line 5377:
```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
			unsigned int bcc = get_bcc(&pSMBr->hdr);
			// Calculate the minimal valid data_offset relative to &pSMBr->hdr.Protocol.
			// This should point past the fixed Transaction2 response header.
			// (char *)&pSMBr->t2.Data is a common marker for the start of variable data in T2 responses.
			unsigned int min_data_offset_from_protocol_base = (char *)&pSMBr->t2.Data - (char *)&pSMBr->hdr.Protocol;

			if (data_offset < min_data_offset_from_protocol_base ||
			    data_offset + sizeof(FILE_SYSTEM_UNIX_INFO) > bcc) {
				cifs_dbg(VFS, "1124: DataOffset %u or data size %zu out of bounds (BCC %u, min_offset %u)\n",
					 data_offset, sizeof(FILE_SYSTEM_UNIX_INFO), bcc, min_data_offset_from_protocol_base);
				rc = -EINVAL;
				goto out;
			}

			response_data =
			    (FILE_SYSTEM_UNIX_INFO
			     *) (((char *) &pSMBr->hdr.Protocol) +
				 data_offset);
```

**CVE pattern:** SMB Transaction2 DataOffset OOB Read



### <a name="cifssmbread--fs-smb-client-cifssmb-c"></a>CIFSSMBRead() — `fs/smb/client/cifssmb.c`

**Assessment:** FP  |  **Confidence:** high

> The CIFSSMBRead function performs comprehensive validation of server-supplied data_length and data_offset fields before using them in the memcpy operation. Multiple checks ensure both the lower and upper bounds of the data region within the received buffer, and that the data_length does not exceed the maximum allowed size or the caller's requested length. Therefore, both findings are false positives.

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 1779 |
| Taint snippet | `unsigned int data_length = le16_to_cpu(pSMBr->DataLengthHigh);` |
| Tainted var | `data_length` |
| Sink | `memcpy()` line 1808 (arg 2, role=size) |
| Sink snippet | `memcpy(*buf, pReadData, data_length);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The `data_length` is derived from server-supplied `pSMBr->DataLengthHigh` and `pSMBr->DataLength`. It is checked against multiple conditions:
1.  `data_length > CIFSMaxBufSize` (line 1786): Prevents excessively large values.
2.  `data_length > count` (line 1787): Ensures the returned data does not exceed the `io_parms->length` requested by the caller, which the destination buffer `*buf` is expected to accommodate.
3.  `(size_t)data_offset + data_length > rsp_iov.iov_len` (line 1794): Ensures the entire data region (starting at `data_offset` and spanning `data_length` bytes) fits within the actual received network buffer (`rsp_iov.iov_len`).

Counterexample test:
-   `rsp_iov.iov_len = 100`, `sizeof(*pSMBr) = 32`, `CIFSMaxBufSize = 65536`, `count = 50`.
-   **Test 1 (data_length > count):** Set `pSMBr->DataLength` such that `data_length = 51`. Line 1787 `(51 > 50)` is true. The `if` branch is taken, `rc` is set to EIO, and `memcpy` is not reached.
-   **Test 2 (data_offset + data_length > rsp_iov.iov_len):** Set `data_offset = 80`, `pSMBr->DataLength` such that `data_length = 30`. Line 1787 passes (`30 <= 50`). Line 1794 `(80 + 30 = 110 > 100)` is true. The `else if` branch is taken, `rc` is set to EIO, and `memcpy` is not reached.

All critical bounds for `data_length` (against source buffer, destination buffer, and global maximum) are checked prior to the `memcpy` sink.


#### Finding #2 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 1780 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->DataOffset);` |
| Tainted var | `pReadData` |
| Sink | `memcpy()` line 1808 (arg 1, role=pointer) |
| Sink snippet | `memcpy(*buf, pReadData, data_length);` |
| Possibly guarded | no |

*Dismissed:* The `data_offset` is derived from server-supplied `pSMBr->DataOffset`. The pointer `pReadData` is calculated using this `data_offset`.

The critical bounds check is at line 1793:
`data_offset < sizeof(*pSMBr) || (size_t)data_offset + data_length > rsp_iov.iov_len`

1.  `data_offset < sizeof(*pSMBr)`: This checks the lower bound. `sizeof(*pSMBr)` is the size of the fixed `READ_RSP` header. `data_offset` must be at least this value to point *past* the header into the actual data payload. If it's less, it means the server is trying to make us read from within the fixed header fields, which is not the expected data area.
2.  `(size_t)data_offset + data_length > rsp_iov.iov_len`: This checks the upper bound, ensuring that the starting point `pReadData` plus the `data_length` does not exceed the total received buffer length `rsp_iov.iov_len`.

Counterexample test:
-   `rsp_iov.iov_len = 100`, `sizeof(*pSMBr) = 32`, `data_length = 10` (assuming `data_length` passed prior checks).
-   **Test 1 (data_offset < sizeof(*pSMBr)):** Set `data_offset = 30`. Line 1793 `(30 < 32)` is true. The `else if` branch is taken, `rc` is set to EIO, and `memcpy` is not reached.
-   **Test 2 (data_offset + data_length > rsp_iov.iov_len):** Set `data_offset = 95`. Line 1793 `(95 < 32)` is false. But `(95 + 10 = 105 > 100)` is true. The `else if` branch is taken, `rc` is set to EIO, and `memcpy` is not reached.

Both the lower and upper bounds of `data_offset` are adequately checked, making this a false positive.



### <a name="cifssmbunixquerysymlink--fs-smb-client-cifssmb-c"></a>CIFSSMBUnixQuerySymLink() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> Both findings stem from a lack of sufficient bounds checking on server-supplied `DataOffset` and `DataCount` fields within the `TRANSACTION2_QPI_RSP` structure (`pSMBr`). The `validate_t2` function call appears insufficient for this purpose, and the comment `/* BB also check enough total bytes returned */` strongly suggests a known missing check. Without proper validation, an attacker can provide malicious `DataOffset` and/or `DataCount` values, leading to Out-of-Bounds reads in `cifs_strndup_from_utf16` when it attempts to interpret the string data. This OOB read can lead to a kernel panic.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 3009 |
| Taint snippet | `data_start = ((char *) &pSMBr->hdr.Protocol) +` |
| Tainted var | `data_start` |
| Call site | line 3018 — 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 snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (dereferencing `data_start` outside allocated buffer) or KASAN slab-out-of-bounds report in `cifs_utf16_bytes`.

**Fix:** Before calling `cifs_strndup_from_utf16`, validate `pSMBr->t2.DataOffset` and `pSMBr->t2.DataCount` against the actual received buffer length (`bytes_returned`). Specifically, ensure that `offsetof(struct smb_hdr, Protocol) + le16_to_cpu(pSMBr->t2.DataOffset)` is a valid offset within `pSMBr`, and that `offsetof(struct smb_hdr, Protocol) + le16_to_cpu(pSMBr->t2.DataOffset) + le16_to_cpu(pSMBr->t2.DataCount)` does not exceed `bytes_returned` (the actual size of the received `pSMBr` buffer).

**CVE pattern:** SMB transaction response DataOffset OOB


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 3007 |
| Taint snippet | `u16 count = le16_to_cpu(pSMBr->t2.DataCount);` |
| Tainted var | `count` |
| Call site | line 3018 — 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 snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (reading beyond received buffer length) or KASAN slab-out-of-bounds report in `cifs_utf16_bytes`.

**Fix:** Before calling `cifs_strndup_from_utf16`, validate `pSMBr->t2.DataOffset` and `pSMBr->t2.DataCount` against the actual received buffer length (`bytes_returned`). Specifically, ensure that `offsetof(struct smb_hdr, Protocol) + le16_to_cpu(pSMBr->t2.DataOffset)` is a valid offset within `pSMBr`, and that `offsetof(struct smb_hdr, Protocol) + le16_to_cpu(pSMBr->t2.DataOffset) + le16_to_cpu(pSMBr->t2.DataCount)` does not exceed `bytes_returned` (the actual size of the received `pSMBr` buffer).

**CVE pattern:** SMB transaction response DataCount OOB



### <a name="smboldqfsinfo--fs-smb-client-cifssmb-c"></a>SMBOldQFSInfo() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The function receives an SMB Transaction2 Query File System Information response. It extracts a 'DataOffset' from the server-supplied response and uses it to calculate a pointer into the received buffer to parse filesystem allocation information. While some general validation exists for the overall SMB response length and minimum header size, there is no explicit validation of the extracted 'DataOffset' to ensure that the resulting pointer, plus the size of the expected data structure, remains within the bounds of the actual received buffer. Furthermore, there's no lower-bound check to prevent 'DataOffset' from pointing into the fixed header portion of the SMB message.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 5049 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Pointer deref | `response_data->BytesPerSector` line 5056 |
| Sink snippet | `le16_to_cpu(response_data->BytesPerSector) *` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., page fault, KASAN report) due to out-of-bounds memory read, or incorrect filesystem statistics due to misinterpretation of kernel memory as `FILE_SYSTEM_ALLOC_INFO` structure fields.

**Fix:** Before creating `response_data`, add explicit bounds checks for `data_offset`. The `data_offset` is relative to `&pSMBr->hdr.Protocol`, so the effective offset from the start of `pSMBr` is `4 + data_offset`. This effective offset must be greater than or equal to the size of the fixed part of the `TRANSACTION2_QFSI_RSP` header (to prevent reading into the header itself) and `effective_offset + sizeof(FILE_SYSTEM_ALLOC_INFO)` must be less than or equal to `bytes_returned` (the total size of the received buffer).

```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
			char *base = (char *)pSMBr;
			unsigned int effective_data_offset = 4 + data_offset; /* Adjust for &pSMBr->hdr.Protocol */
			size_t min_data_offset = offsetof(TRANSACTION2_QFSI_RSP, SetupCount) + 2; /* min offset after fixed fields */

			if (effective_data_offset < min_data_offset ||
			    effective_data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO) > bytes_returned) {
				cifs_dbg(VFS, "SMB: Invalid DataOffset %u or insufficient data length %zu in QFSInfo response (expected %zu, total %u)\n",
					 data_offset, sizeof(FILE_SYSTEM_ALLOC_INFO), bytes_returned);
				rc = -EINVAL;
			} else {
				response_data = (FILE_SYSTEM_ALLOC_INFO *)(base + effective_data_offset);
				/* ... rest of the parsing ... */
			}
```

**CVE pattern:** SMB Transaction2 DataOffset OOB



### <a name="cifs-create-reparse-inode--fs-smb-client-cifssmb-c"></a>cifs_create_reparse_inode() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The `cifs_create_reparse_inode` function processes extended attributes (`xattr_iov`) which are assumed to originate from user-supplied data. It iterates through these attributes using a server/user-controlled `next_entry_offset` and copies their values using a server/user-controlled `ea_value_length`. In both cases, there are no sufficient bounds checks against the `xattr_iov->iov_len` buffer. This leads to potential out-of-bounds reads when traversing the `ea` structures or when copying the `ea_value` data.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 3226 |
| Taint snippet | `ea = (struct smb2_file_full_ea_info *)((u8 *)ea +` |
| Tainted var | `ea` |
| Pointer deref | `ea->next_entry_offset` line 3227 |
| Sink snippet | `le32_to_cpu(ea->next_entry_offset));` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic, KASAN report, system instability due to reading past the end of the `xattr_iov` buffer.

**Fix:** Before advancing the `ea` pointer with `le32_to_cpu(ea->next_entry_offset)`, ensure that the `ea` pointer, plus `offsetof(struct smb2_file_full_ea_info, next_entry_offset)`, plus `sizeof(u32)` (for the field itself) does not exceed `xattr_iov->iov_base + xattr_iov->iov_len`. After advancing `ea` by `le32_to_cpu(ea->next_entry_offset)`, the newly calculated `ea` pointer plus at least the minimum size of `struct smb2_file_full_ea_info` must be checked against `xattr_iov->iov_base + xattr_iov->iov_len` to ensure the next header is fully contained. Additionally, `next_entry_offset` should be checked for a reasonable minimum value (e.g., `sizeof(struct smb2_file_full_ea_info)` or alignment requirements) to prevent overlapping entries.

**CVE pattern:** SMB_loop_advance_OOB


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 3214 |
| Taint snippet | `rc = CIFSSMBSetEA(xid,` |
| Tainted var | `le16_to_cpu(ea->ea_value_length)` |
| Call site | line 3214 — passes `le16_to_cpu(ea->ea_value_length)` to `CIFSSMBSetEA()` |
| Call snippet | `rc = CIFSSMBSetEA(xid,` |
| Sink (in callee) | `memcpy()` line 6490 (arg 2, role=size) |
| Sink snippet | `memcpy(parm_data->list.name + name_len + 1,` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic, KASAN report, system instability due to `memcpy` reading past the end of the `xattr_iov` buffer.

**Fix:** Before calling `CIFSSMBSetEA`, `cifs_create_reparse_inode` must validate that the `ea_value` (source for `memcpy`) and its `ea_value_len` fit entirely within the `xattr_iov` buffer. The check should ensure that `(u8 *)ea + offsetof(struct smb2_file_full_ea_info, ea_data) + ea->ea_name_length + 1 + ea_value_len` does not exceed `xattr_iov->iov_base + xattr_iov->iov_len`.

**CVE pattern:** SMB_memcpy_size_OOB



### <a name="cifs-query-reparse-point--fs-smb-client-cifssmb-c"></a>cifs_query_reparse_point() — `fs/smb/client/cifssmb.c`

**Assessment:** FP  |  **Confidence:** high

> The function performs a crucial bounds check before casting the pointer `start` to `struct reparse_data_buffer *buf` and accessing its fields. The check `(size_t)(end - start) < sizeof(*buf)` (lines 3131-3132) ensures that the area pointed to by `start` has enough bytes for the entire `struct reparse_data_buffer`. If this condition were true, the function would jump to `error`. Therefore, upon reaching line 3142, it is guaranteed that `buf` points to a valid memory region at least `sizeof(struct reparse_data_buffer)` bytes long, making the access `buf->ReparseDataLength` safe.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 3102 |
| Taint snippet | `data_offset = le32_to_cpu(io_rsp->DataOffset);` |
| Tainted var | `buf` |
| Pointer deref | `buf->ReparseDataLength` line 3142 |
| Sink snippet | `data_count < le16_to_cpu(buf->ReparseDataLength) + len) {` |
| Possibly guarded | no |

*Dismissed:* The `data_offset` is extracted from `io_rsp->DataOffset`, which is received from the network in `SendReceive`. Thus, it is server-supplied.

However, a sufficient bounds check exists at lines 3131-3132:
`if (start >= end || (size_t)(end - start) < sizeof(*buf)) { ... goto error; }`

Here, `start` is derived using the `data_offset`, and `end` marks the end of the received data area. The condition `(size_t)(end - start) < sizeof(*buf)` directly checks if the remaining buffer from `start` is smaller than the size of `struct reparse_data_buffer`. If this condition is true, the function returns an error, preventing an OOB read.

If the check passes, it guarantees that `(size_t)(end - start) >= sizeof(*buf)`. This means that `start + sizeof(*buf)` is less than or equal to `end`. Therefore, when `buf` is assigned `(struct reparse_data_buffer *)start` at line 3139, and `buf->ReparseDataLength` is accessed at line 3142, the access is guaranteed to be within the bounds of the received buffer. `ReparseDataLength` is a field *within* `struct reparse_data_buffer`, so if the whole struct fits, the field access is safe.

Counterexample test:
Let `sizeof(struct reparse_data_buffer)` be 20 bytes.
Let `end - ((__u8 *)&io_rsp->hdr.Protocol)` be the total available bytes after the protocol header.
Let `data_offset` be such that `start` is `(__u8 *)&io_rsp->hdr.Protocol + data_offset`.

If `end - start` (the available bytes from `start`) is 19 bytes (i.e., less than `sizeof(*buf)`),
then `(size_t)(end - start) < sizeof(*buf)` evaluates to `true`.
This triggers the `goto error;` at line 3133, preventing the `buf` casting and subsequent dereference.

If `end - start` is 20 bytes (i.e., exactly `sizeof(*buf)`),
then `(size_t)(end - start) < sizeof(*buf)` evaluates to `false`.
The code proceeds, `buf` is cast, and `buf->ReparseDataLength` is read, which is safe as `sizeof(*buf)` bytes are available.

The check is sufficient, and no counterexample for an OOB read at `buf->ReparseDataLength` is possible due to this specific validation.



### <a name="cifs-to-posix-acl--fs-smb-client-cifssmb-c"></a>cifs_to_posix_acl() — `fs/smb/client/cifssmb.c`

**Assessment:** BUG  |  **Confidence:** high

> The `cifs_to_posix_acl` function contains logic to validate the total size of ACL entries against `size_of_data_area`. However, `size_of_data_area` is directly derived from a server-supplied field (`pSMBr->t2.DataCount`) by the caller (`cifs_do_get_acl`) without sufficient validation against the actual received buffer length (`bytes_returned`). This violates the 'Tainted trust boundary' principle, making the internal bounds check insufficient to prevent an OOB read if the server provides an inflated `DataCount` value.

#### Finding #1 — Category C — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 3409 |
| Taint snippet | `count = le16_to_cpu(cifs_acl->access_entry_count);` |
| Tainted var | `count` |
| Subscript | `[]` line 3413 |
| Sink snippet | `pACE = &cifs_acl->ace_array[count];` |
| Possibly guarded | no |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (KASAN: slab-out-of-bounds read) when processing a crafted SMB POSIX ACL response due to reading past the end of the received network buffer.

**Fix:** In `cifs_do_get_acl`, the `size_of_data_area` argument passed to `cifs_to_posix_acl` should represent the actual number of bytes available in the `src` buffer, not just the server-declared `DataCount`. This requires validating `pSMBr->t2.DataCount` against the actual received byte count. Specifically, `size_of_data_area` should be `bytes_returned - le16_to_cpu(pSMBr->t2.DataOffset)` (after ensuring `pSMBr->t2.DataOffset` is itself within bounds and doesn't cause underflow). A `min` check should be applied: `size_of_data_area = min_t(unsigned int, le16_to_cpu(pSMBr->t2.DataCount), bytes_returned - le16_to_cpu(pSMBr->t2.DataOffset));` ensuring `bytes_returned >= le16_to_cpu(pSMBr->t2.DataOffset)`.

**CVE pattern:** Tainted trust boundary: unvalidated server-supplied length field leads to OOB access



### <a name="cifs-dump-full-key--fs-smb-client-ioctl-c"></a>cifs_dump_full_key() — `fs/smb/client/ioctl.c`

**Assessment:** FP  |  **Confidence:** high

> The `cifs_dump_full_key` function copies a fixed-size header (`sizeof(struct smb3_full_key_debug_info)`) and then a variable number of keys to a user-provided buffer. The lengths of these keys (`out.session_key_length`, `out.server_in_key_length`, `out.server_out_key_length`) are determined by kernel constants or internal kernel state derived from the negotiated cipher type, not directly from user input. The total size required for the initial header and all keys is calculated and explicitly checked against the user-provided buffer size (`out.in_size`) at line 417. This check ensures that the entire operation, including the initial `copy_to_user` of the struct and the subsequent `copy_to_user` calls for the keys, will not write past the end of the user's allocated buffer. The `data` member of `smb3_full_key_debug_info` is a flexible array member (`u8 data[]`), meaning `in->data` points immediately after the fixed header of the user-provided buffer, making the size calculation correct.

#### Finding #1 — Category G2 — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat G2 — unvalidated size argument to copy_from/to_user |
| Taint source | `copy_to_user()` line 434 |
| Taint snippet | `if (copy_to_user(end, ses->auth_key.response, out.session_key_length)) {` |
| Tainted var | `out.session_key_length` |
| Unvalidated size | `copy_to_user()` arg 2 line 434 — size `out.session_key_length` |
| Sink snippet | `if (copy_to_user(end, ses->auth_key.response, out.session_key_length)) {` |
| Possibly guarded | no |

*Dismissed:* The `out.session_key_length` is derived from kernel constants (`CIFS_SESS_KEY_SIZE`) or `ses->auth_key.len`. `ses->auth_key.len` is an internal kernel value populated during session establishment, not directly user-supplied in this `ioctl` context. Thus, the length itself is kernel-controlled. The total amount of data to be copied (which includes this length) is checked against the user-provided buffer size (`out.in_size`) at line 417: `if (out.in_size < sizeof(out) + out.session_key_length + out.server_in_key_length + out.server_out_key_length)`. This ensures that the user buffer is large enough for the entire output, preventing an OOB write. No counterexample found: if `out.in_size` is less than the required total length, the function returns -ENOBUFS. Otherwise, the `copy_to_user` is safe.


#### Finding #2 — Category G2 — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat G2 — unvalidated size argument to copy_from/to_user |
| Taint source | `copy_to_user()` line 440 |
| Taint snippet | `if (copy_to_user(end, ses->smb3encryptionkey, out.server_in_key_length)) {` |
| Tainted var | `out.server_in_key_length` |
| Unvalidated size | `copy_to_user()` arg 2 line 440 — size `out.server_in_key_length` |
| Sink snippet | `if (copy_to_user(end, ses->smb3encryptionkey, out.server_in_key_length)) {` |
| Possibly guarded | no |

*Dismissed:* The `out.server_in_key_length` is assigned a kernel constant (`SMB3_GCM128_CRYPTKEY_SIZE` or `SMB3_GCM256_CRYPTKEY_SIZE`) based on the negotiated cipher type, not directly user-supplied. The total amount of data to be copied (which includes this length) is checked against the user-provided buffer size (`out.in_size`) at line 417: `if (out.in_size < sizeof(out) + out.session_key_length + out.server_in_key_length + out.server_out_key_length)`. This ensures that the user buffer is large enough for the entire output, preventing an OOB write. No counterexample found: if `out.in_size` is less than the required total length, the function returns -ENOBUFS. Otherwise, the `copy_to_user` is safe.


#### Finding #3 — Category G2 — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat G2 — unvalidated size argument to copy_from/to_user |
| Taint source | `copy_to_user()` line 446 |
| Taint snippet | `if (copy_to_user(end, ses->smb3decryptionkey, out.server_out_key_length)) {` |
| Tainted var | `out.server_out_key_length` |
| Unvalidated size | `copy_to_user()` arg 2 line 446 — size `out.server_out_key_length` |
| Sink snippet | `if (copy_to_user(end, ses->smb3decryptionkey, out.server_out_key_length)) {` |
| Possibly guarded | no |

*Dismissed:* The `out.server_out_key_length` is assigned a kernel constant (`SMB3_GCM128_CRYPTKEY_SIZE` or `SMB3_GCM256_CRYPTKEY_SIZE`) based on the negotiated cipher type, not directly user-supplied. The total amount of data to be copied (which includes this length) is checked against the user-provided buffer size (`out.in_size`) at line 417: `if (out.in_size < sizeof(out) + out.session_key_length + out.server_in_key_length + out.server_out_key_length)`. This ensures that the user buffer is large enough for the entire output, preventing an OOB write. No counterexample found: if `out.in_size` is less than the required total length, the function returns -ENOBUFS. Otherwise, the `copy_to_user` is safe.



### <a name="parse-dfs-referrals--fs-smb-client-misc-c"></a>parse_dfs_referrals() — `fs/smb/client/misc.c`

**Assessment:** FP  |  **Confidence:** high

> The `parse_dfs_referrals` function exhibits robust input validation. It performs checks for the overall response size, the number of referrals, and critically, for the offsets and lengths of variable-length strings within the response. The `data_end` pointer is correctly established as the upper bound of the received buffer. Offset fields (like `DfsPathOffset` and `NetworkAddressOffset`) are validated with both lower and upper bounds relative to the current `ref` pointer and the `data_end` of the overall response. The `max_len` for string operations is then precisely calculated based on these validated bounds. Functions like `cifs_utf16_bytes` and `cifs_strndup_from_utf16` correctly utilize these bounds to perform safe string parsing and allocation, making the reported findings false positives.

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

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 758 |
| Taint snippet | `path_consumed = le16_to_cpu(rsp->PathConsumed);` |
| Tainted var | `path_consumed` |
| Call site | line 775 — passes `path_consumed` to `cifs_utf16_bytes()` |
| Call snippet | `node->path_consumed = cifs_utf16_bytes(tmp, path_consumed,` |
| Loop | `for_loop` line 299 |
| Sink snippet | `for (i = 0; i < maxwords; i++) {` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `path_consumed` value is server-supplied (`le16_to_cpu(rsp->PathConsumed)`). However, it is immediately guarded at line 763: `if (path_consumed > search_name_utf16_len)`. The `search_name_utf16_len` is derived from a locally-controlled `searchName` string and represents the size of a `kmalloc`ed buffer (`tmp`) at line 768. This check ensures that `path_consumed` cannot exceed the size of this local buffer. The `cifs_utf16_bytes` function (callee) receives `path_consumed` as `maxbytes` and calculates `maxwords = maxbytes / 2`. The loop `for (i = 0; i < maxwords; i++)` then accesses `from[i]`. Since `path_consumed` is capped by `search_name_utf16_len` (the size of `tmp` in bytes), `maxwords` will be capped by `search_name_utf16_len / 2`, which is the number of `__le16` elements in `tmp`. Thus, all accesses `from[i]` within `cifs_utf16_bytes` will be strictly within the bounds of the `tmp` buffer. 

Counterexample test: Let `searchName = 'A'`, `search_name_len = 1`. `search_name_utf16_len = 1 * 2 + 2 = 4` bytes. `tmp` is allocated for 4 bytes. If `rsp->PathConsumed` is, say, 10, the check `if (10 > 4)` at line 763 triggers, and the function returns -EINVAL. If `rsp->PathConsumed` is 4, then `path_consumed = 4`. `cifs_utf16_bytes(tmp, 4, ...)` is called. Inside, `maxbytes = 4`, `maxwords = 2`. The loop runs for `i = 0, 1`. `get_unaligned_le16(&from[0])` and `get_unaligned_le16(&from[1])` are valid reads from a 4-byte buffer (2 `__le16` elements). No OOB possible.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 799 |
| Taint snippet | `temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);` |
| Tainted var | `temp` |
| Call site | line 801 — passes `temp` to `cifs_strndup_from_utf16()` |
| Call snippet | `node->path_name = cifs_strndup_from_utf16(temp, max_len,` |
| Sink (in callee) | `kmalloc()` line 341 (arg 0, role=size) |
| Sink snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | no |

*Dismissed:* The `temp` pointer is derived from `(char *)ref + le16_to_cpu(ref->DfsPathOffset)`. The `ref` pointer is part of the server-supplied response. `DfsPathOffset` is also server-supplied. However, line 791 performs a comprehensive bounds check on `DfsPathOffset`: `if (le16_to_cpu(ref->DfsPathOffset) < sizeof(*ref) || le16_to_cpu(ref->DfsPathOffset) > data_end - (char *)ref)`. This ensures that `temp` points to a valid location within the `rsp` buffer, strictly after the fixed header (`sizeof(*ref)`) and strictly before or at `data_end`. The `max_len` variable is then calculated as `data_end - temp` (line 800), which accurately reflects the remaining valid bytes in the buffer from `temp` onwards. When `cifs_strndup_from_utf16` calls `cifs_utf16_bytes` with `temp` (as `src`) and `max_len` (as `maxbytes`), `cifs_utf16_bytes` internally limits its reads to `maxbytes/2` words, preventing any OOB accesses. The `kmalloc` then uses `len`, which is the *actual* converted string length discovered within `max_len` boundaries, not the raw `max_len` value. Thus, the allocation size is safe. 

Counterexample test: Assume `rsp_size = 100`, `ref` starts at `rsp+16`, `sizeof(*ref) = 20`. `data_end = rsp+100`. The check at 791 forces `DfsPathOffset` to be in `[20, 84]`. If `DfsPathOffset = 84`, `temp` points to `rsp+16+84 = rsp+100`. `max_len = data_end - temp = 0`. `cifs_strndup_from_utf16(rsp+100, 0, ...)` will call `cifs_utf16_bytes(rsp+100, 0, ...)`. `maxbytes=0`, `maxwords=0`. The loop `for (i=0; i<0; i++)` does not run. `len` will be 0. `kmalloc(0)` is safe. If `DfsPathOffset = 20`, `temp` points to `rsp+36`. `max_len = 100-36 = 64`. `cifs_utf16_bytes(rsp+36, 64, ...)` will read up to 32 `__le16` words from `rsp+36`, remaining safely within `rsp_size`. No OOB possible.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 799 |
| Taint snippet | `temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);` |
| Tainted var | `max_len` |
| Call site | line 801 — passes `max_len` to `cifs_strndup_from_utf16()` |
| Call snippet | `node->path_name = cifs_strndup_from_utf16(temp, max_len,` |
| Sink (in callee) | `kmalloc()` line 341 (arg 0, role=size) |
| Sink snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | no |

*Dismissed:* Similar to finding #2, `max_len` is derived from server-supplied `DfsPathOffset` and `rsp_size`. However, `DfsPathOffset` is strictly validated at line 791, and `max_len` is calculated as `data_end - temp` (line 800), ensuring it represents the exact remaining bytes in the buffer. `cifs_strndup_from_utf16` passes `max_len` as `maxlen` to `cifs_utf16_bytes`. Inside `cifs_utf16_bytes`, `maxlen` (`maxbytes`) is used to derive `maxwords = maxbytes / 2`, which bounds the loop iterating through the UTF-16 string. The `len` value returned by `cifs_utf16_bytes` and used for `kmalloc` is the actual converted length of the string, which is guaranteed to be less than or equal to `max_len`. Therefore, `kmalloc` will always be called with a safe, derived length. 

Counterexample test: Same as Finding #2. The `max_len` value is a safe upper bound for the string data. The `cifs_utf16_bytes` function calculates the true string length within this bound, and `kmalloc` allocates for that true length. This correctly prevents both OOB reads during string parsing and undersized/oversized allocations based on a potentially malicious `max_len` value.



### <a name="cnvrtdosunixtm--fs-smb-client-netmisc-c"></a>cnvrtDosUnixTm() — `fs/smb/client/netmisc.c`

**Assessment:** FP  |  **Confidence:** high

> The function `cnvrtDosUnixTm` takes server-supplied date and time values. The `SMB_DATE` structure allows `Month` to be represented by 4 bits, meaning it can hold values from 0 to 15. However, there is explicit validation and clamping logic for `month` before it is used as an array index. The `clamp` function ensures the `month` value is between 1 and 12, and then it is decremented by 1, correctly mapping it to a 0-11 range for array indexing.

#### Finding #1 — Category C — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 164 |
| Taint snippet | `u16 date = le16_to_cpu(le_date);` |
| Tainted var | `month` |
| Subscript | `[]` line 187 |
| Sink snippet | `days = day + total_days_of_prev_months[month];` |
| Possibly guarded | no |

*Dismissed:* The `month` value is extracted from `sd->Month` (line 179). This value, being a 4-bit field, can theoretically be from 0 to 15. However, lines 181-184 perform validation and clamping:
`if (day < 1 || day > 31 || month < 1 || month > 12)` (line 181)
`month = clamp(month, 1, 12);` (line 184)
This `clamp` operation ensures that `month` will be in the range [1, 12].
Subsequently, `month -= 1;` (line 186) is performed, which transforms the range [1, 12] into [0, 11].
The sink `total_days_of_prev_months[month]` (line 187) will then access the array with an index guaranteed to be between 0 and 11, which is safe for a 12-element array (assuming `total_days_of_prev_months` is such an array, e.g., for months 0-11).

**Counterexample test:**
*   If `sd->Month` is 0: `month` becomes 0. `clamp(0, 1, 12)` makes `month` 1. `month - 1` makes `month` 0. `total_days_of_prev_months[0]` is safe.
*   If `sd->Month` is 15 (max 4-bit value): `month` becomes 15. `clamp(15, 1, 12)` makes `month` 12. `month - 1` makes `month` 11. `total_days_of_prev_months[11]` is safe.
*   If `sd->Month` is 7: `month` becomes 7. `clamp(7, 1, 12)` makes `month` 7. `month - 1` makes `month` 6. `total_days_of_prev_months[6]` is safe.
In all cases, the index is correctly constrained to be within [0, 11].



### <a name="mknod-wsl--fs-smb-client-reparse-c"></a>mknod_wsl() — `fs/smb/client/reparse.c`

**Assessment:** FP  |  **Confidence:** high

> The `mknod_wsl` function is responsible for constructing data structures that represent a reparse point (symlink or device) for the Windows Subsystem for Linux (WSL) feature. These structures (`buf` and `xattr_iov`) are *built locally* by helper functions (`wsl_set_reparse_buf`, `wsl_set_xattrs`) using kernel-controlled parameters like `mode`, `symname`, and `dev`. They are not parsed from a server response. The `le32_to_cpu()` calls found in the findings are therefore operating on values that the kernel itself previously set (presumably with `cpu_to_le32()` in the helper functions) and are merely converting them back to host byte order for internal use. As such, these values are not server-supplied, and the findings are false positives.

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le32_to_cpu()` line 713 |
| Taint snippet | `len = le32_to_cpu(cc->ctx.DataLength);` |
| Tainted var | `len` |
| Sink | `memcpy()` line 714 (arg 2, role=size) |
| Sink snippet | `memcpy(data.wsl.eas, &cc->ea, len);` |
| Possibly guarded | no |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The `len` variable is derived from `cc->ctx.DataLength` via `le32_to_cpu()`. `cc` is `xattr_iov.iov_base`, which is populated by `wsl_set_xattrs()`. `wsl_set_xattrs()` is a helper function that *constructs* the extended attribute data for a new node, not parses it from a server response. Therefore, `cc->ctx.DataLength` is a value set by the kernel itself (likely with `cpu_to_le32()` internally) and is locally controlled. The `le32_to_cpu()` call is merely converting a kernel-defined, kernel-written value back to host byte order. The `memcpy()` will be safe as `wsl_set_xattrs()` is responsible for ensuring `DataLength` correctly reflects the size of the data it placed into `&cc->ea`. This is a false positive based on rule 1.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le32_to_cpu()` line 706 |
| Taint snippet | `data = (struct cifs_open_info_data) {` |
| Tainted var | `data` |
| Call site | line 725 — passes `data` to `cifs_free_open_info()` |
| Call snippet | `cifs_free_open_info(&data);` |
| Sink (in callee) | `memset()` line 490 (arg 2, role=size) |
| Sink snippet | `memset(data, 0, sizeof(*data));` |
| Possibly guarded | no |

*Dismissed:* The `data` variable is a `struct cifs_open_info_data` initialized locally. The taint is flagged on a field within `data` (`data.reparse.tag`) which is derived from `buf->ReparseTag` via `le32_to_cpu()`. Similar to finding #1, `buf` is populated by `wsl_set_reparse_buf()`, which *constructs* a reparse buffer for a new node. Thus, `buf->ReparseTag` is a kernel-controlled value, not server-supplied (rule 1). 

The sink is `memset(data, 0, sizeof(*data))`. The `sizeof(*data)` expression is a compile-time constant representing the size of the `struct cifs_open_info_data`. The value of any field *within* `data` (including the supposedly tainted `reparse.tag`) does not affect `sizeof(*data)`. Therefore, the `memset` operation is inherently safe with respect to size, as it clears exactly the memory occupied by the `data` structure. This is a false positive because the size argument to `memset` is a fixed constant, and the data itself is kernel-controlled.



### <a name="parse-reparse-native-symlink--fs-smb-client-reparse-c"></a>parse_reparse_native_symlink() — `fs/smb/client/reparse.c`

**Assessment:** BUG  |  **Confidence:** high

> The `parse_reparse_native_symlink` function takes `sym` (a pointer to `reparse_symlink_data_buffer`, which is actually a `reparse_data_buffer` offset by 8 bytes) and `plen` (the length of `sym` from its starting point). It extracts `offs` (SubstituteNameOffset) and `len` (SubstituteNameLength) from `sym`. The check `if (offs + 20 > plen || offs + len + 20 > plen)` verifies that the string starting at `sym->PathBuffer + offs` and with a length of `len` fits within `plen`. Specifically, it appears to enforce that `12 + offs + len <= plen - 8`, where `12` is the size of the fixed header of `reparse_symlink_data_buffer` before `PathBuffer`. This check is sufficiently strict for the `len` value itself. However, the subsequent call to `smb2_parse_native_symlink` uses `strlen()` on the buffer derived from `sym->PathBuffer + offs`. This `strlen()` call does not respect the `len` boundary that was passed to `smb2_parse_native_symlink` (which is the tainted `len` from `sym->SubstituteNameLength`). If the server supplies a string that is not null-terminated within the `len` bytes, `strlen()` will read past this intended boundary, leading to an Out-of-Bounds Read. While the `plen - 8` check provides some buffer, if the null terminator is not found within the full `plen` bytes, `strlen()` will read past the end of the `sym` buffer, leading to a crash or information disclosure. The result of `strlen()` (which can be excessively large) is then used for `kmalloc` size and `memcpy` length, leading to potential undersized allocations and further OOB reads.

#### Finding #1 — Category B — cross-function via `smb2_parse_native_symlink()` — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 1024 |
| Taint snippet | `offs = le16_to_cpu(sym->SubstituteNameOffset);` |
| Tainted var | `offs` |
| Call site | line 1032 — passes `offs` to `smb2_parse_native_symlink()` |
| Call snippet | `return smb2_parse_native_symlink(&data->symlink_target,` |
| Sink (in callee) | `kmalloc()` line 949 (arg 0, role=size_mul_overflow) |
| Sink snippet | `linux_target = kmalloc(symlinkroot_len + 1 + abs_path_len, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., KASAN report for stack-buffer-overflow or heap-buffer-overflow) during `strlen` or `memcpy`, or silent memory corruption (undersized allocation).

**Fix:** In `smb2_parse_native_symlink()`, replace `strlen(abs_path)` with `strnlen(abs_path, len)` when calculating `abs_path_len`. Similarly, replace `strlen(smb_target)` with `strnlen(smb_target, len)` when calculating `smb_target_len`. The `len` parameter already passed to `smb2_parse_native_symlink()` defines the maximum valid length of the `buf` (or `abs_path`/`smb_target`) argument.

**CVE pattern:** Unbounded strlen on network data


#### Finding #2 — Category B — cross-function via `smb2_parse_native_symlink()` — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 1025 |
| Taint snippet | `len = le16_to_cpu(sym->SubstituteNameLength);` |
| Tainted var | `len` |
| Call site | line 1032 — passes `len` to `smb2_parse_native_symlink()` |
| Call snippet | `return smb2_parse_native_symlink(&data->symlink_target,` |
| Sink (in callee) | `kmalloc()` line 949 (arg 0, role=size_mul_overflow) |
| Sink snippet | `linux_target = kmalloc(symlinkroot_len + 1 + abs_path_len, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., KASAN report for stack-buffer-overflow or heap-buffer-overflow) during `strlen` or `memcpy`, or silent memory corruption (undersized allocation).

**Fix:** In `smb2_parse_native_symlink()`, replace `strlen(abs_path)` with `strnlen(abs_path, len)` when calculating `abs_path_len`. Similarly, replace `strlen(smb_target)` with `strnlen(smb_target, len)` when calculating `smb_target_len`. The `len` parameter already passed to `smb2_parse_native_symlink()` defines the maximum valid length of the `buf` (or `abs_path`/`smb_target`) argument.

**CVE pattern:** Unbounded strlen on network data



### <a name="parse-reparse-nfs--fs-smb-client-reparse-c"></a>parse_reparse_nfs() — `fs/smb/client/reparse.c`

**Assessment:** BUG  |  **Confidence:** high

> The `parse_reparse_nfs` function processes server-supplied reparse point data. The `ReparseDataLength` field, read into `len`, specifies the length of the data following the initial reparse point header fields (`ReparseTag` and `ReparseDataLength`). While `parse_reparse_nfs` performs a lower bound check on `len` (line 759) to ensure the `InodeType` field is present, it *lacks an upper bound check* against the actual allocated buffer size (`plen`) provided by its caller, `parse_reparse_point`. This allows a malicious server to specify an arbitrarily large `ReparseDataLength`, causing subsequent operations (like `UniStrnlen` or `cifs_utf16_bytes` within `cifs_strndup_from_utf16`) to read past the end of the received network buffer.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 758 |
| Taint snippet | `len = le16_to_cpu(buf->ReparseDataLength);` |
| Tainted var | `len` |
| Call site | line 781 — passes `len` to `cifs_strndup_from_utf16()` |
| Call snippet | `data->symlink_target = cifs_strndup_from_utf16(buf->DataBuffer,` |
| Sink (in callee) | `kmalloc()` line 341 (arg 0, role=size) |
| Sink snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or crash due to reading unmapped memory, or reading arbitrary kernel data from an out-of-bounds location, potentially leading to information disclosure or further exploits.

**Fix:** Add an upper bound check in `parse_reparse_point` before calling `parse_reparse_nfs`. The `le16_to_cpu(buf->ReparseDataLength)` value (which is `len` in `parse_reparse_nfs`) must be validated against `plen - sizeof(ReparseTag) - sizeof(ReparseDataLength)`. Specifically, in `parse_reparse_point`, before the call to `parse_reparse_nfs` at line 1109, add:
```c
	u32 reparse_data_len = le16_to_cpu(buf->ReparseDataLength);
	const u32 header_size = sizeof(buf->ReparseTag) + sizeof(buf->ReparseDataLength);
	if (plen < header_size || reparse_data_len > plen - header_size) {
		cifs_dbg(VFS, "srv returned malformed reparse data: len %u too large for plen %u\n",
			 reparse_data_len, plen);
		return -EINVAL;
	}
```
This ensures that `len` within `parse_reparse_nfs` (after the initial `sizeof(buf->InodeType)` subtraction) cannot cause an out-of-bounds access when used as the `maxlen` argument to `cifs_strndup_from_utf16`.

**CVE pattern:** SMB/CIFS reparse point OOB read due to missing length validation against received buffer size.



### <a name="parse-reparse-wsl-symlink--fs-smb-client-reparse-c"></a>parse_reparse_wsl_symlink() — `fs/smb/client/reparse.c`

**Assessment:** FP  |  **Confidence:** high

> The `parse_reparse_wsl_symlink` function processes server-supplied reparse point data. It correctly calculates the length of the UTF-8 symlink target (`symname_utf8_len`) by subtracting a fixed header offset from the total `ReparseDataLength`. This `ReparseDataLength` is a `__le16`, limiting `symname_utf8_len` to a maximum of `0xFFFF - data_offset` (approx 65KB). Subsequent multiplications and conversions, while using this tainted length, remain well within `size_t` limits and do not lead to integer overflows or undersized allocations, assuming standard NLS behavior for string conversions.

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

| Field | Value |
|---|---|
| Category | Cat B — integer overflow: symname_utf8_len * 2 |
| Taint source | `le16_to_cpu()` line 1044 |
| Taint snippet | `int len = le16_to_cpu(buf->ReparseDataLength);` |
| Tainted var | `symname_utf8_len` |
| Overflow expr | `symname_utf8_len * 2` |
| Safe fix | `kmalloc_array()` or `check_mul_overflow()` |
| Sink | `kzalloc()` line 1077 (arg 0, role=size_mul_overflow) |
| Sink snippet | `symname_utf16 = kzalloc(symname_utf8_len * 2, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The taint source `buf->ReparseDataLength` is a `__le16`, so its maximum value after `le16_to_cpu()` is 65535. The `data_offset` is a constant value (offsetof(Target) from buf's start). In `struct reparse_wsl_symlink_data_buffer`, `Target` is a flexible array member, so `data_offset` would be the sum of sizes of `ReparseTag`, `ReparseDataLength`, `Reserved`, and `Version` fields, which is `4 + 2 + 2 + 4 = 12` bytes. Thus, `symname_utf8_len` (calculated as `len - data_offset`) has a maximum value of `65535 - 12 = 65523`. The multiplication `symname_utf8_len * 2` therefore yields at most `65523 * 2 = 131046`. This value fits comfortably within a `size_t` on common architectures (which is typically `unsigned long`, 64-bit), so no integer overflow occurs during the `kzalloc` call. The check `if (len <= data_offset)` at line 1050 ensures `symname_utf8_len` is non-negative, providing a lower bound. The string content check `strnlen` at line 1070 is for null bytes, not relevant to the allocation size calculation itself. No counterexample causing an overflow could be constructed as the maximum input value is too small to overflow `size_t` when multiplied by 2.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 1044 |
| Taint snippet | `int len = le16_to_cpu(buf->ReparseDataLength);` |
| Tainted var | `symname_utf16_len` |
| Call site | line 1089 — passes `symname_utf16_len` to `cifs_strndup_from_utf16()` |
| Call snippet | `data->symlink_target = cifs_strndup_from_utf16((u8 *)symname_utf16,` |
| Sink (in callee) | `kmalloc()` line 341 (arg 0, role=size) |
| Sink snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `symname_utf16_len` is derived from `symname_utf8_len`, which has a maximum value of 65523. After `utf8s_to_utf16s` and multiplication by 2 (line 1087), `symname_utf16_len` represents the byte length of the UTF-16 string, with a maximum value of approximately `65523 * 2 = 131046`. This value is passed as `maxlen` to `cifs_strndup_from_utf16`. Inside `cifs_strndup_from_utf16`, `maxlen` is used as a byte limit for `cifs_utf16_bytes` when reading from the `src` (which is `symname_utf16`). The `symname_utf16` buffer was previously allocated via `kzalloc(symname_utf8_len * 2, GFP_KERNEL)`, which means its allocated size is at least `symname_utf16_len`. Therefore, reading `maxlen` bytes from `symname_utf16` is guaranteed to be in-bounds. The `kmalloc` call in `cifs_strndup_from_utf16` uses `len = cifs_utf16_bytes(...) + nls_nullsize(...)`. This `len` is calculated by `cifs_utf16_bytes` based on the actual string content and the NLS table, representing the exact bytes needed for the converted string. Assuming `cifs_utf16_bytes` and `nls_nullsize` are correct (they are fundamental kernel NLS helpers), this `len` is the correct size for the `kmalloc` allocation. Even with NLS expansion, the maximum possible `len` (e.g., 65523 UTF-16 chars * 4 bytes/char + null terminator) would be around 262KB, which fits `size_t`. Thus, there is no undersized allocation or OOB read.



### <a name="is-valid-oplock-break--fs-smb-client-smb1misc-c"></a>is_valid_oplock_break() — `fs/smb/client/smb1misc.c`

**Assessment:** BUG  |  **Confidence:** high

> The function processes a server-supplied SMB_COM_NT_TRANSACT response which contains a DataOffset field. This offset is used to derive a pointer to a `file_notify_information` structure. The existing bounds checks are insufficient to prevent out-of-bounds reads and misinterpretation of message data, primarily due to a missing lower-bound check for DataOffset and an insufficient upper-bound check for the variable-length FileName field.

#### Finding #1 — Category E — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 87 |
| Taint snippet | `data_offset = le32_to_cpu(pSMBr->DataOffset);` |
| Tainted var | `pnotify` |
| Pointer deref | `pnotify->FileName` line 98 |
| Sink snippet | `pnotify->FileName, pnotify->Action);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from heap corruption (if OOB read hits unmapped memory), KASAN warning (slab-out-of-bounds read), or information disclosure (misinterpretation of SMB header fields, or printing arbitrary kernel memory).

**Fix:** 1. Add a lower-bound check for `data_offset` to ensure it points after the fixed header of `smb_com_transaction_change_notify_rsp`. The fixed header size is `sizeof(struct smb_hdr) + 1 + (2*4)` (for WordCount, ParameterOffset, ParameterCount, DataOffset, DataCount), which sums to 41 bytes. So, `if (data_offset < 41) return true;`.
2. Before using `pnotify->FileNameLength`, validate the fixed part of `file_notify_information` and then validate the `FileNameLength` against the remaining buffer size. Specifically:
   `u32 fixed_fni_size = offsetof(struct file_notify_information, FileName);`
   `if (data_offset + fixed_fni_size > len) { cifs_dbg(FYI, "Invalid data_offset/len for fixed FNI part"); return true; }`
   `pnotify = (struct file_notify_information *)((char *)buf + data_offset);`
   `u32 filename_len = le32_to_cpu(pnotify->FileNameLength);`
   `if (data_offset + fixed_fni_size + filename_len > len || filename_len > (len - (data_offset + fixed_fni_size))) { cifs_dbg(FYI, "Invalid filename_len"); return true; }`
3. Use `cifs_dbg_nt_err` or `pr_warn_once` with `%.*s` format specifier when printing `pnotify->FileName` to limit the printed length to `filename_len`, e.g., `cifs_dbg(FYI, "dnotify on %.*s Action: 0x%x\n", filename_len, pnotify->FileName, pnotify->Action);` to prevent OOB reads if the string is not null-terminated within `filename_len`.
Note: `pSMBr->DataOffset` is `__u16`, but `le32_to_cpu` is used. This implies `DataOffset` might be 4 bytes in some contexts or a type mismatch. Assuming `DataOffset` is actually `__le16`, then `le16_to_cpu` should be used. Given the problem description implies `DataOffset` is the taint source, we assume it's read as intended, even if the cast to `__le32` might be incorrect for `pSMBr->DataOffset` depending on the `smb_com_transaction_change_notify_rsp` definition.

**CVE pattern:** CVE-XXXX-NNNN style DataOffset OOB (missing lower bound, insufficient variable-length data check)



### <a name="cifs-query-path-info--fs-smb-client-smb1ops-c"></a>cifs_query_path_info() — `fs/smb/client/smb1ops.c`

**Assessment:** FP  |  **Confidence:** high

> The function `cifs_query_path_info` receives a `struct cifs_open_info_data *data` argument. Its only call site, `smb_set_file_info`, initializes this structure as `struct cifs_open_info_data query_data = {};`. This zero-initializes all fields of `query_data`, including `query_data.wsl.eas` (an `unsigned char` array). 

Inside `cifs_query_path_info`, the pointer `ea` is initialized to `(struct smb2_file_full_ea_info *)data->wsl.eas`. Consequently, when `ea->next_entry_offset` (lines 659, 705) and `ea->ea_value_length` (lines 661, 707) are read, they are guaranteed to be zero due to the zero-initialization of `data->wsl.eas`.

The `do-while` loops (lines 658-660 and 703-706) therefore terminate immediately as `next` is 0. More importantly, the `if` conditions `if (le16_to_cpu(ea->ea_value_length))` (lines 661 and 707) will always evaluate to false, causing the code blocks containing the flagged tainted operations (lines 662-666 and 708-712) to be unreachable. 

Thus, the tainted pointer arithmetic and dereferences are in dead code paths. All findings are false positives.

Additionally, a minor type inconsistency was noted: `ea_value_length` in `struct smb2_file_full_ea_info` is `__le32`, but the code uses `le16_to_cpu` and `cpu_to_le16` with it (e.g., lines 661, 675). While not a bug here due to unreachability, this could lead to issues if the code path were active and the upper 16 bits of the `__le32` field were non-zero.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 665 |
| Taint snippet | `ea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));` |
| Tainted var | `ea` |
| Pointer deref | `ea->ea_data` line 669 |
| Sink snippet | `&ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1],` |
| Possibly guarded | no |

*Dismissed:* The taint source `le32_to_cpu(ea->next_entry_offset)` at line 665 is within an `if` block (`if (le16_to_cpu(ea->ea_value_length))`). The `ea` pointer is derived from `data->wsl.eas`, which is zero-initialized by the caller. Therefore, `ea->ea_value_length` is 0 when read at line 661, causing the `if` condition to be false and this code path to be unreachable. The taint source is not server-supplied as the initial value of `ea->next_entry_offset` comes from a local zero-initialized buffer.


#### Finding #2 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le32_to_cpu()` line 665 |
| Taint snippet | `ea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));` |
| Tainted var | `ea` |
| Sink | `memcpy()` line 676 (arg 0, role=pointer) |
| Sink snippet | `memcpy(&ea->ea_data[0], SMB2_WSL_XATTR_MODE, SMB2_WSL_XATTR_NAME_LEN + 1);` |
| Possibly guarded | no |

*Dismissed:* The taint source `le32_to_cpu(ea->next_entry_offset)` at line 665 is within an `if` block (`if (le16_to_cpu(ea->ea_value_length))`). The `ea` pointer is derived from `data->wsl.eas`, which is zero-initialized by the caller. Therefore, `ea->ea_value_length` is 0 when read at line 661, causing the `if` condition to be false and this code path to be unreachable. The taint source is not server-supplied as the initial value of `ea->next_entry_offset` comes from a local zero-initialized buffer.


#### Finding #3 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 711 |
| Taint snippet | `ea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));` |
| Tainted var | `ea` |
| Pointer deref | `ea->ea_data` line 715 |
| Sink snippet | `&ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1],` |
| Possibly guarded | no |

*Dismissed:* The taint source `le32_to_cpu(ea->next_entry_offset)` at line 711 is within an `if` block (`if (le16_to_cpu(ea->ea_value_length))`). The `ea` pointer is derived from `data->wsl.eas`, which is zero-initialized by the caller. Therefore, `ea->ea_value_length` is 0 when read at line 707, causing the `if` condition to be false and this code path to be unreachable. The taint source is not server-supplied as the initial value of `ea->next_entry_offset` comes from a local zero-initialized buffer.


#### Finding #4 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le32_to_cpu()` line 711 |
| Taint snippet | `ea = (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset));` |
| Tainted var | `ea` |
| Sink | `memcpy()` line 722 (arg 0, role=pointer) |
| Sink snippet | `memcpy(&ea->ea_data[0], SMB2_WSL_XATTR_DEV, SMB2_WSL_XATTR_NAME_LEN + 1);` |
| Possibly guarded | no |

*Dismissed:* The taint source `le32_to_cpu(ea->next_entry_offset)` at line 711 is within an `if` block (`if (le16_to_cpu(ea->ea_value_length))`). The `ea` pointer is derived from `data->wsl.eas`, which is zero-initialized by the caller. Therefore, `ea->ea_value_length` is 0 when read at line 707, causing the `if` condition to be false and this code path to be unreachable. The taint source is not server-supplied as the initial value of `ea->next_entry_offset` comes from a local zero-initialized buffer.



### <a name="sess-auth-kerberos--fs-smb-client-smb1session-c"></a>sess_auth_kerberos() — `fs/smb/client/smb1session.c`

**Assessment:** FP  |  **Confidence:** high

> The `decode_ascii_ssetup` function is designed to parse null-terminated ASCII strings within a given bounded buffer (`bleft`). It correctly uses `strnlen` with `bleft` as the maximum length. The subsequent check `if (len >= bleft) return;` is crucial and effectively handles cases where a null terminator is not found within the expected boundary or `bleft` is zero. The `kmalloc(len + 1)` and `memcpy(..., len)` operations are then performed based on this safely determined `len`, ensuring no out-of-bounds access from the source buffer and that the allocated destination buffer is sufficient for the string plus its null terminator. The maximum `__u16` values for `len` (65535) are too small to cause `size_t` integer overflow with `len + 1`.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 627 |
| Taint snippet | `blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);` |
| Tainted var | `bcc_ptr` |
| Call site | line 649 — passes `bcc_ptr` to `decode_ascii_ssetup()` |
| Call snippet | `decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,` |
| Sink (in callee) | `kmalloc()` line 270 (arg 0, role=size_mul_overflow) |
| Sink snippet | `ses->serverOS = kmalloc(len + 1, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `bcc_ptr` is an offset into the server-supplied SMB buffer, and `bytes_remaining` (passed as `bleft`) is the length of valid data remaining from that pointer. In `decode_ascii_ssetup()`, `len = strnlen(bcc_ptr, bleft);` correctly determines the length of the string within the `bleft` boundary. The check `if (len >= bleft) return;` handles cases where the string is not null-terminated within `bleft` bytes or if `bleft` is zero. If the function proceeds, `len` is guaranteed to be less than `bleft`. Therefore, `kmalloc(len + 1)` (at line 270) will allocate at most `bleft` bytes, and `memcpy(ses->serverOS, bcc_ptr, len)` (at line 272) will copy `len` bytes from `bcc_ptr`, which is safe because `len < bleft`. The null termination `ses->serverOS[len] = 0;` (at line 273) is also safe within the `len + 1` sized allocated buffer. The `size_mul_overflow` concern for `len + 1` is negligible as `len` is `__u16` max (65535), so `65536` will not overflow `size_t`.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 627 |
| Taint snippet | `blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);` |
| Tainted var | `bytes_remaining` |
| Call site | line 649 — passes `bytes_remaining` to `decode_ascii_ssetup()` |
| Call snippet | `decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,` |
| Sink (in callee) | `kmalloc()` line 270 (arg 0, role=size_mul_overflow) |
| Sink snippet | `ses->serverOS = kmalloc(len + 1, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* This finding targets `bytes_remaining` (passed as `bleft`) as the tainted variable, leading to the same `kmalloc` sink at line 270 in `decode_ascii_ssetup()`. The analysis is identical to Finding #1. The `bleft` parameter correctly serves as the `maxlen` argument for `strnlen`, bounding the `len` value. The subsequent `if (len >= bleft)` check ensures that `len` is always less than `bleft` when execution continues to the `kmalloc` and `memcpy` calls. Thus, all flagged sinks (`kmalloc` size, `memcpy` size, `memcpy` pointer, array subscript for null termination) are sufficiently guarded by the validation logic within `decode_ascii_ssetup()`.



### <a name="sess-auth-rawntlmssp-authenticate--fs-smb-client-smb1session-c"></a>sess_auth_rawntlmssp_authenticate() — `fs/smb/client/smb1session.c`

**Assessment:** FP  |  **Confidence:** high

> The function `sess_auth_rawntlmssp_authenticate` receives an SMB response from the server. It extracts `bytes_remaining` (total variable data length) and `blob_len` (security blob length) from this response. A critical bounds check at line 880 (`if (blob_len > bytes_remaining)`) ensures that the server-supplied security blob length does not exceed the available variable data area. If it does, the function returns. Assuming this check passes, the `bcc_ptr` and `bytes_remaining` are correctly adjusted to point to the start of the string data and represent its remaining length.

The `decode_ascii_ssetup` function, which is the sink for both findings, then proceeds to parse null-terminated strings from this `bcc_ptr` with the provided `bleft` (remaining bytes). It uses `strnlen(bcc_ptr, bleft)` which correctly limits the string length to `bleft`. The subsequent guard `if (len >= bleft)` ensures that if `strnlen` consumes all `bleft` bytes without finding a null terminator, or finds it exactly at `bleft`, the function returns early. This prevents `kmalloc(len + 1)` and `memcpy(..., len)` from potentially exceeding the `bleft` buffer because if execution proceeds past the guard, `len` is guaranteed to be *strictly less than* `bleft`, meaning `len + 1` will be at most `bleft`.

All uses of `len` (derived from `strnlen`) for `kmalloc` size, `memcpy` size, and array indexing (`ses->serverOS[len] = 0`) are thus correctly bounded by `bleft`. No integer overflow or out-of-bounds access can occur here.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 879 |
| Taint snippet | `blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);` |
| Tainted var | `bcc_ptr` |
| Call site | line 902 — passes `bcc_ptr` to `decode_ascii_ssetup()` |
| Call snippet | `decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,` |
| Sink (in callee) | `kmalloc()` line 270 (arg 0, role=size_mul_overflow) |
| Sink snippet | `ses->serverOS = kmalloc(len + 1, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The taint source `le16_to_cpu(pSMB->resp.SecurityBlobLength)` (line 879) is indeed server-supplied. The `bcc_ptr` passed to `decode_ascii_ssetup` is derived from `pByteArea(smb_buf)` which points into the server response buffer, and is advanced by `blob_len`. The `bytes_remaining` argument is the actual remaining size of the buffer after consuming the security blob. The `kmalloc` size (`len + 1`) is derived from `len = strnlen(bcc_ptr, bleft)`. The `if (len >= bleft)` guard (line 265 in `decode_ascii_ssetup`) ensures that if `strnlen` scanned the entire `bleft` bytes without a null terminator, or if the null terminator is exactly at `bleft`, the function returns early. If the guard is not triggered, it means `len < bleft`, and therefore `len + 1 <= bleft`. This makes the `kmalloc(len + 1)` allocation and subsequent `memcpy` and null termination safe within the `bleft` bounds. No integer overflow for `len + 1` as `bleft` is `__u16`, thus `len + 1` would be at most `65536`, which fits `size_t` and is a valid `kmalloc` size.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 879 |
| Taint snippet | `blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);` |
| Tainted var | `bytes_remaining` |
| Call site | line 902 — passes `bytes_remaining` to `decode_ascii_ssetup()` |
| Call snippet | `decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,` |
| Sink (in callee) | `kmalloc()` line 270 (arg 0, role=size_mul_overflow) |
| Sink snippet | `ses->serverOS = kmalloc(len + 1, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The taint source `le16_to_cpu(pSMB->resp.SecurityBlobLength)` (line 879) affects `bytes_remaining`. The `bytes_remaining` variable is derived from `get_bcc(smb_buf)` (server-supplied total variable data length) and then reduced by the server-supplied `blob_len`. The check `if (blob_len > bytes_remaining)` at line 880 in `sess_auth_rawntlmssp_authenticate` ensures that `bytes_remaining` passed to `decode_ascii_ssetup` is a valid, non-negative remaining length for the buffer. Within `decode_ascii_ssetup`, the `bleft` parameter (which is this `bytes_remaining`) is used as the limit for `strnlen(bcc_ptr, bleft)`. The guard `if (len >= bleft)` at line 265 ensures that `len` will always be less than `bleft` if execution proceeds to `kmalloc`, thus `len + 1 <= bleft`. This makes the `kmalloc(len + 1)` allocation and subsequent `memcpy` and null termination safe within the `bleft` bounds. No integer overflow for `len + 1` as `bleft` is `__u16`, thus `len + 1` would be at most `65536`, which fits `size_t` and is a valid `kmalloc` size.



### <a name="coalesce-t2--fs-smb-client-smb1transport-c"></a>coalesce_t2() — `fs/smb/client/smb1transport.c`

**Assessment:** FP  |  **Confidence:** high

> The function `coalesce_t2` explicitly addresses the server-supplied nature of `DataOffset` fields (line 385) and implements comprehensive bounds checks before performing the `memcpy` operation. Both the source and destination pointers, along with the transfer length, are validated against their respective buffer boundaries. The checks include both lower bounds (ensuring pointers are past the fixed header) and upper bounds (ensuring data plus length doesn't exceed the total allocated buffer size).

Specifically:
- `total_in_src` (length) is checked in conjunction with `data_area_of_tgt` against `CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` (destination buffer limit) and with `data_area_of_src` against `smbCalcSize()` (source buffer limit).
- `data_area_of_tgt` (destination pointer) is validated to be greater than `target_hdr + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (lower bound) and, when added with `total_in_src`, less than `target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` (upper bound).
- `data_area_of_src` (source pointer) is validated to be greater than `second_buf + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (lower bound) and, when added with `total_in_src`, less than `second_buf + smbCalcSize((struct smb_hdr *)second_buf)` (upper bound).

These checks, performed directly before the `memcpy`, prevent out-of-bounds reads from the source buffer and out-of-bounds writes to the destination buffer.

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `get_unaligned_le16()` line 370 |
| Taint snippet | `total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);` |
| Tainted var | `total_in_src` |
| Sink | `memcpy()` line 435 (arg 2, role=size) |
| Sink snippet | `memcpy(data_area_of_tgt, data_area_of_src, total_in_src);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `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 is extracted from `pSMBs->t2_rsp.DataCount`, which is part of a server-supplied buffer. It is used as the size argument for `memcpy`.

Bounds checks for both the source and destination buffers, incorporating `total_in_src`, are present and sufficient:
- For the destination (`data_area_of_tgt`): `data_area_of_tgt + total_in_src > (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` (line 390) prevents OOB writes.
- For the source (`data_area_of_src`): `data_area_of_src + total_in_src > second_buf + smbCalcSize((struct smb_hdr *)second_buf)` (line 397) prevents OOB reads.

Counterexample test:
If `total_in_src` is very large (e.g., `USHRT_MAX = 65535`), and either `data_area_of_tgt` or `data_area_of_src` is such that the sum `pointer + total_in_src` exceeds the respective buffer's allocated size, the checks at lines 390-391 or 397-398 will trigger, causing an early return with `-EPROTO`. For instance, if `target_hdr` represents a 4KB buffer and `data_area_of_tgt` is at its very beginning (after header fields) and `total_in_src` is 5KB, `0x... + 5KB > 0x... + 4KB` would evaluate true, correctly preventing the `memcpy`.


#### Finding #2 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `get_unaligned_le16()` line 375 |
| Taint snippet | `data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +` |
| Tainted var | `data_area_of_tgt` |
| Sink | `memcpy()` line 435 (arg 0, role=pointer) |
| Sink snippet | `memcpy(data_area_of_tgt, data_area_of_src, total_in_src);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `data_area_of_tgt` pointer is derived from `pSMBt->t2_rsp.DataOffset`, which is part of a server-supplied buffer. This pointer is used as the destination for `memcpy`.

Bounds checks for `data_area_of_tgt` are present and sufficient:
- Lower bound: `data_area_of_tgt < (char *)target_hdr + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (line 388) ensures `DataOffset` does not point into the fixed header portion of the target buffer.
- Upper bound: `data_area_of_tgt + total_in_src > (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` (line 390) ensures the copy operation does not write past the end of the target buffer. Note that `total_in_src` is included in this upper bound check, covering the full extent of the write.

Counterexample test:
If `pSMBt->t2_rsp.DataOffset` leads to `data_area_of_tgt` being, for example, `target_hdr + 10` (i.e., pointing into the fixed `smb_hdr` part), the lower bound check `data_area_of_tgt < (char *)target_hdr + sizeof(struct smb_t2_rsp) + sizeof(__le16)` would evaluate to true (e.g., `target_hdr + 10 < target_hdr + 32`), correctly leading to an error. If `data_area_of_tgt` (after `total_in_tgt` addition) is near the end of the buffer (e.g., `target_hdr + 4000` for a 4096-byte buffer) and `total_in_src` is `100`, the upper bound check `target_hdr + 4000 + 100 > target_hdr + 4096` would be true, preventing the OOB write.


#### Finding #3 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `get_unaligned_le16()` line 378 |
| Taint snippet | `data_area_of_src = (char *)&pSMBs->hdr.Protocol +` |
| Tainted var | `data_area_of_src` |
| Sink | `memcpy()` line 435 (arg 1, role=pointer) |
| Sink snippet | `memcpy(data_area_of_tgt, data_area_of_src, total_in_src);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `data_area_of_src` pointer is derived from `pSMBs->t2_rsp.DataOffset`, which is part of a server-supplied buffer. This pointer is used as the source for `memcpy`.

Bounds checks for `data_area_of_src` are present and sufficient:
- Lower bound: `data_area_of_src < second_buf + sizeof(struct smb_t2_rsp) + sizeof(__le16)` (line 395) ensures `DataOffset` does not point into the fixed header portion of the source buffer.
- Upper bound: `data_area_of_src + total_in_src > second_buf + smbCalcSize((struct smb_hdr *)second_buf)` (line 397) ensures the copy operation does not read past the end of the source buffer. Note that `total_in_src` is included in this upper bound check, covering the full extent of the read.

Counterexample test:
Similar to finding #2. If `pSMBs->t2_rsp.DataOffset` leads to `data_area_of_src` being, for example, `second_buf + 10`, the lower bound check `second_buf + 10 < second_buf + sizeof(struct smb_t2_rsp) + sizeof(__le16)` would evaluate to true, correctly leading to an error. If `data_area_of_src` is near the end of `second_buf` and `total_in_src` would cause it to read past the end (e.g., `second_buf + smbCalcSize(second_buf) - 10 + 20 > second_buf + smbCalcSize(second_buf)`), the upper bound check would be true, preventing the OOB read.



### <a name="smb2-parse-symlink-response--fs-smb-client-smb2file-c"></a>smb2_parse_symlink_response() — `fs/smb/client/smb2file.c`

**Assessment:** BUG  |  **Confidence:** high

> The `smb2_parse_symlink_response` function performs basic bounds checking for the total extent of the substitute and print names (`sub_offs + sub_len`, `print_offs + print_len`) against the total received buffer length (`iov->iov_len`). However, the `smb2_parse_native_symlink` callee receives these name data pointers and their lengths (`buf`, `len`) but fails to use the provided length parameter to bound string operations like `strlen` and `strstarts`. This allows a malicious server to send non-null-terminated strings, causing OOB reads during string length calculations and subsequent integer overflows in allocation sizes, leading to undersized allocations and potential OOB writes during string copies.

#### Finding #1 — Category B — cross-function via `smb2_parse_native_symlink()` — **BUG** (oob_read, integer_overflow, undersized_alloc, oob_write)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 148 |
| Taint snippet | `sub_offs = le16_to_cpu(sym->SubstituteNameOffset);` |
| Tainted var | `sub_offs` |
| Call site | line 158 — passes `sub_offs` to `smb2_parse_native_symlink()` |
| Call snippet | `return smb2_parse_native_symlink(path,` |
| Sink (in callee) | `kmalloc()` line 949 (arg 0, role=size_mul_overflow) |
| Sink snippet | `linux_target = kmalloc(symlinkroot_len + 1 + abs_path_len, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from OOB read (e.g., KASAN report during `strlen`/`strstarts`), or heap corruption / system instability (from undersized allocation followed by `memcpy` OOB write).

**Fix:** In `smb2_parse_native_symlink`, replace `strlen(abs_path)` with `strnlen(abs_path, remaining_len)` where `remaining_len` is calculated as `len - (abs_path - buf)`. All accesses to `abs_path` should be bounded by this remaining length. Additionally, replace `strstarts` with length-aware versions (e.g., `strnstarts` or custom comparison functions) to prevent OOB reads. The `len` parameter should consistently represent the maximum valid length for string operations on `buf` and its derived pointers.

**CVE pattern:** strlen without strnlen on server-supplied data, leading to OOB read and subsequent allocation/memcpy issues.


#### Finding #2 — Category B — cross-function via `smb2_parse_native_symlink()` — **BUG** (oob_read, integer_overflow, undersized_alloc, oob_write)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 147 |
| Taint snippet | `sub_len = le16_to_cpu(sym->SubstituteNameLength);` |
| Tainted var | `sub_len` |
| Call site | line 158 — passes `sub_len` to `smb2_parse_native_symlink()` |
| Call snippet | `return smb2_parse_native_symlink(path,` |
| Sink (in callee) | `kmalloc()` line 949 (arg 0, role=size_mul_overflow) |
| Sink snippet | `linux_target = kmalloc(symlinkroot_len + 1 + abs_path_len, GFP_KERNEL);` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from OOB read (e.g., KASAN report during `strlen`/`strstarts`), or heap corruption / system instability (from undersized allocation followed by `memcpy` OOB write).

**Fix:** In `smb2_parse_native_symlink`, replace `strlen(abs_path)` with `strnlen(abs_path, remaining_len)` where `remaining_len` is calculated as `len - (abs_path - buf)`. All accesses to `abs_path` should be bounded by this remaining length. Additionally, replace `strstarts` with length-aware versions (e.g., `strnstarts` or custom comparison functions) to prevent OOB reads. The `len` parameter should consistently represent the maximum valid length for string operations on `buf` and its derived pointers. This also applies to `strlen(smb_target)` at reparse.c:968 in a different branch.

**CVE pattern:** strlen without strnlen on server-supplied data, leading to OOB read and subsequent allocation/memcpy issues.



### <a name="symlink-data--fs-smb-client-smb2file-c"></a>symlink_data() — `fs/smb/client/smb2file.c`

**Assessment:** FP  |  **Confidence:** high

> The `symlink_data` function processes a server-supplied `kvec` buffer, which is expected to contain an `smb2_err_rsp` and potentially multiple `smb2_error_context_rsp` entries, one of which might be an `smb2_symlink_err_rsp`. The function performs multiple validation checks: initial length checks based on `ErrorContextCount` and `ByteCount`, and a loop that iterates through error contexts. Each iteration of the loop includes checks to ensure the current context's header fits within the buffer and that its variable-length data portion (defined by `ErrorDataLength`) also fits before advancing the pointer to the next context. A final validation checks the identified `smb2_symlink_err_rsp` against the buffer end and for correct tag values.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 64 |
| Taint snippet | `len = le32_to_cpu(p->ErrorDataLength);` |
| Tainted var | `p` |
| Pointer deref | `p->ErrorContextData` line 71 |
| Sink snippet | `p = (struct smb2_error_context_rsp *)(p->ErrorContextData + len);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The finding flags `p->ErrorContextData` on line 71, which is part of advancing the `p` pointer within a loop: `p = (struct smb2_error_context_rsp *)(p->ErrorContextData + len);`. 

1.  **Safety of `p->ErrorContextData` access:** The `while` loop guard `((u8 *)p + sizeof(*p) <= end)` on line 56 ensures that the fixed-size header of the `smb2_error_context_rsp` struct (which includes `ErrorId`, `ErrorDataLength`, and the implicit start of `ErrorContextData` as a flexible array member) is fully contained within the buffer defined by `end`. Thus, accessing `p->ErrorContextData` to get its address is safe, as `p` itself points to a valid struct header within bounds. This access merely calculates an address, it does not dereference `len` bytes from that address.
2.  **Safety of `+ len` and next `p` calculation:** The `len` variable, derived from `p->ErrorDataLength`, is validated against the remaining buffer size on lines 65 and 68: `if (len > end - ((u8 *)p + sizeof(*p)))`. This check ensures that `len` bytes of data, starting from `p->ErrorContextData` (which is conceptually `(u8 *)p + sizeof(*p)`), will not go beyond `end`. Therefore, the calculation `p->ErrorContextData + len` (which represents `(u8 *)p + sizeof(*p) + len`) correctly results in an address that is within or exactly at `end`, making the resulting pointer `p` for the next iteration safe in terms of its upper bound. The next iteration's `while` loop condition will then re-validate the new `p`'s header against `end`.

**Counterexample Test:**
- Assume `iov->iov_len = 76` bytes (total buffer size for `iov`).
- Let `sizeof(struct smb2_err_rsp)` be 64 bytes.
- `err` points to `iov->iov_base`.
- `end = (u8 *)err + 76`.
- `p` is initialized to `(struct smb2_error_context_rsp *)err->ErrorData`, assuming `err->ErrorData` starts at `(u8 *)err + 64`.
- Let `sizeof(struct smb2_error_context_rsp)` be 12 bytes (fixed header size without the flexible array member).
- **Loop guard (line 56):** `((u8 *)p + sizeof(*p) <= end)` evaluates to `(u8 *)err + 64 + 12 <= (u8 *)err + 76` -> `(u8 *)err + 76 <= (u8 *)err + 76`. This is `true`, so the loop is entered.
- **Access `p->ErrorContextData` (line 71):** This access is safe because `p`'s header (`sizeof(*p)`) is guaranteed to be within bounds by the loop guard.
- **Taint source `len = le32_to_cpu(p->ErrorDataLength);` (line 64):** Let server-supplied `p->ErrorDataLength = 0`.
- `len` becomes `0`.
- **Check (line 65):** `len > end - ((u8 *)p + sizeof(*p)))` evaluates to `0 > (76 - (64 + 12))` -> `0 > (76 - 76)` -> `0 > 0`. This is `false`.
- `len = ALIGN(len, 8);` (`len` remains `0`).
- **Check (line 68):** `len > end - ((u8 *)p + sizeof(*p)))` evaluates to `0 > 0`. This is `false`.
- **Pointer advance (line 71):** `p = (struct smb2_error_context_rsp *)(p->ErrorContextData + len);` computes `p = (struct smb2_error_context_rsp *)((u8 *)p + 12 + 0)`, which effectively sets `p` to `(u8 *)err + 76`.
- **Next loop iteration:** The condition `((u8 *)p + sizeof(*p) <= end)` evaluates to `(u8 *)err + 76 + 12 <= (u8 *)err + 76` -> `(u8 *)err + 88 <= (u8 *)err + 76`. This is `false`, and the loop terminates gracefully without any OOB access. The checks are sufficient.



### <a name="check-wsl-eas--fs-smb-client-smb2inode-c"></a>check_wsl_eas() — `fs/smb/client/smb2inode.c`

**Assessment:** FP  |  **Confidence:** high

> The `check_wsl_eas` function iterates through Extented Attribute (EA) entries within a server-supplied buffer. It performs robust bounds checking at multiple levels:
1. It validates the total declared EA block length (`outlen`) against the actual received buffer length (`rsp_iov->iov_len`) at line 139 (`ea_end > iov_end`). This ensures the entire sequence of EAs is within the buffer.
2. Inside the loop, before accessing any fields of the current `ea` entry, it checks if there's enough space for at least one full `smb2_file_full_ea_info` header (`sizeof(*ea)`) within the remaining declared EA block (`ea_end`) at line 143 (`(u8 *)ea > ea_end - sizeof(*ea)`). This ensures `ea->ea_name_length`, `ea->ea_value_length`, and `ea->next_entry_offset` can be safely read.
3. A further check at line 149 (`(u8 *)ea->ea_data + nlen + 1 + vlen > ea_end`) explicitly validates that the combined length of the EA name (`nlen`) and EA value (`vlen`), plus a padding/separator byte (`+ 1`), fits within the `ea_end` boundary. This check directly protects the `strncmp` operations that use `nlen`.

These combined checks provide sufficient protection for all flagged accesses.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 135 |
| Taint snippet | `ea = (void *)((u8 *)rsp_iov->iov_base +` |
| Tainted var | `ea` |
| Pointer deref | `ea->ea_name_length` line 146 |
| Sink snippet | `nlen = ea->ea_name_length;` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The pointer `ea` is derived from `rsp_iov->iov_base` and `rsp->OutputBufferOffset`, both of which are part of the server-supplied response. Therefore, `ea` is tainted.

However, there are sufficient bounds checks in place:
1. Line 139: `if (ea_end > iov_end)` ensures that the total EA data block, starting from `ea` and of `outlen` bytes, fits within the actual received `rsp_iov->iov_len` buffer.
2. Line 143: `if ((u8 *)ea > ea_end - sizeof(*ea))` ensures that the current `ea` pointer is sufficiently far from `ea_end` to read a full `smb2_file_full_ea_info` structure header. This guarantees that `ea->ea_name_length`, `ea->ea_value_length`, and `ea->next_entry_offset` can be safely accessed.

Counterexample test:
Assume `rsp_iov->iov_base = 0x1000`, `rsp_iov->iov_len = 0x100` (256 bytes total buffer).
Assume `rsp->OutputBufferOffset = 0x50` (server-supplied), so `ea = 0x1050`.
Assume `rsp->OutputBufferLength = 0x10` (server-supplied, 16 bytes), so `outlen = 0x10`.
`ea_end = 0x1050 + 0x10 = 0x1060`.
Line 139 check: `0x1060 > 0x1100` is false, so it passes.
`sizeof(*ea)` (i.e., `SMB2_FILE_FULL_EA_INFO_SIZE`) is 12 bytes.
Line 143 check: `(u8 *)ea > ea_end - sizeof(*ea)` becomes `0x1050 > 0x1060 - 12` which is `0x1050 > 0x1054`. This is false, so it passes.
Since both checks pass, it is guaranteed that `ea` points to a location where at least `sizeof(*ea)` bytes are available within `ea_end`, and `ea_end` itself is within the actual `iov_len`. Thus, `ea->ea_name_length` (an offset within `sizeof(*ea)`) can be safely dereferenced. No OOB occurs.


#### Finding #2 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 135 |
| Taint snippet | `ea = (void *)((u8 *)rsp_iov->iov_base +` |
| Tainted var | `nlen` |
| Sink | `strncmp()` line 154 (arg 2, role=size) |
| Sink snippet | `if (strncmp(ea->ea_data, SMB2_WSL_XATTR_UID, nlen) &&` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The variable `nlen` is sourced from `ea->ea_name_length`, which is part of the server-supplied data. Thus, `nlen` is tainted.

The `strncmp` sink is protected by the check at line 149: `if (nlen != SMB2_WSL_XATTR_NAME_LEN || (u8 *)ea->ea_data + nlen + 1 + vlen > ea_end)`.
This check ensures that the name (`nlen` bytes), value (`vlen` bytes), and an additional byte for padding/separator, all fit within the `ea_end` boundary. If this check passes, it implies that `(u8 *)ea->ea_data + nlen <= ea_end - (1 + vlen)`. Since `vlen >= 0`, this means `(u8 *)ea->ea_data + nlen <= ea_end - 1`. Therefore, `nlen` bytes read from `ea->ea_data` for `strncmp` will not exceed `ea_end`. As `ea_end` is itself validated against `iov_end` (line 139), the access is safe.

Counterexample test:
Using the same values as Finding #1: `ea = 0x1050`, `ea_end = 0x1060`.
Assume `ea` has `ea_name_length = 5` (`nlen = 5`) and `ea_value_length = 4` (`vlen = 4`).
`ea->ea_data` starts at `0x1058` (offset 8 from `ea`).
Line 149 check:
`nlen != SMB2_WSL_XATTR_NAME_LEN` (5 != 4) is true, so the first part of the `||` causes it to continue.
Then, `(u8 *)ea->ea_data + nlen + 1 + vlen > ea_end` becomes `0x1058 + 5 + 1 + 4 > 0x1060`.
`0x1068 > 0x1060` is false. So the `return -EINVAL` is NOT triggered, and the code proceeds to `strncmp`.
The evaluation `0x1068 > 0x1060` being false means `0x1068 <= 0x1060`. This is mathematically incorrect in the test case (`0x1068` is clearly greater than `0x1060`). Let me re-evaluate this carefully.

Correct counterexample test for line 149:
Assume `ea = 0x1050`, `ea_end = 0x1060` (so `outlen = 0x10`). `sizeof(*ea) = 12`.
Line 143 passes: `0x1050 > 0x1060 - 12` (0x1050 > 0x1054) is false.
Now, suppose server sends `nlen = 5`, `vlen = 4`.
`ea->ea_data` (start of name) is at `ea + 8 = 0x1058`.
Line 149 check:
`nlen != SMB2_WSL_XATTR_NAME_LEN` (5 != 4) is `true`. The `||` means the expression is `true`.
This would cause `return -EINVAL` to be triggered. This means `nlen=5` is *rejected* by the first part of the guard. This is good because `SMB2_WSL_XATTR_NAME_LEN` is 4 for these specific attributes.

What if `nlen = 4`?
Then `nlen != SMB2_WSL_XATTR_NAME_LEN` (4 != 4) is `false`.
The check proceeds to `(u8 *)ea->ea_data + nlen + 1 + vlen > ea_end`.
Let `vlen = 3`.
`0x1058 + 4 + 1 + 3 > 0x1060` becomes `0x1060 > 0x1060`. This is `false`. So it passes.
`strncmp(ea->ea_data, ..., nlen)` uses `nlen = 4` bytes from `0x1058`.
The passing condition `0x1060 > 0x1060` being false implies `0x1060 <= 0x1060`. This means `ea->ea_data + nlen + 1 + vlen` is within `ea_end`.
`0x1058 + 4` (end of name string) is `0x105C`. `0x105C` is indeed within `ea_end` (`0x1060`).

The validation is sufficient: the length `nlen` used in `strncmp` is either explicitly restricted to `SMB2_WSL_XATTR_NAME_LEN` (4), or it's implicitly bounded by the `ea_end` check, which ensures `ea->ea_data + nlen` is within the valid buffer section.



### <a name="parse-posix-sids--fs-smb-client-smb2inode-c"></a>parse_posix_sids() — `fs/smb/client/smb2inode.c`

**Assessment:** FP  |  **Confidence:** high

> The function `parse_posix_sids` receives a response buffer `rsp_iov` and a pointer to a response structure `qi` within that buffer. It extracts `OutputBufferLength` and `OutputBufferOffset` (assumed to be `__le32` and `__le16` respectively as per the `le*_to_cpu` calls in the snippet, despite conflicting standard SMB2 structure definitions, as this is an assessment of the *given code*). These values define a data block within the `rsp_iov` buffer containing `posix_fi` data followed by SIDs.

Validation flow:
1.  **Overall buffer extent**: The expression `sidsbuf_end = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + le32_to_cpu(qi->OutputBufferLength)` computes the absolute end of the server-supplied data block. This `sidsbuf_end` is explicitly checked against the actual received buffer length (`rsp_iov->iov_len`) at line 85. This ensures the entire data block, including all SIDs, does not exceed the received buffer.
2.  **SIDs buffer start**: The base pointer `sidsbuf` is calculated as `(u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + sizeof(data->posix_fi)`. The call site in `smb2_compound_op` shows a preceding `smb2_validate_and_copy_iov` call which copies `sizeof(idata->posix_fi)` bytes from `le16_to_cpu(qi_rsp->OutputBufferOffset)` within `rsp_iov[i+1]`. This implies that `(u8 *)qi + le16_to_cpu(qi->OutputBufferOffset)` is a valid start for `sizeof(data->posix_fi)` bytes, and thus `sidsbuf` (pointing immediately after this fixed-size data) is also a valid pointer within the received buffer.
3.  **Individual SID size and buffer traversal**: `owner_len` and `group_len` are determined by calls to `posix_info_sid_size`. This helper function validates that the SID structure (of computed `total` length) fits entirely within the provided `beg` and `end` pointers (`sidsbuf` and `sidsbuf_end`). If a SID would exceed its allocated space (`sidsbuf_end`), `posix_info_sid_size` returns -1, which is handled by `parse_posix_sids` at lines 93 and 98, causing an early error return.
4.  **Destination buffer size**: `data->posix_owner` and `data->posix_group` are of type `struct cifs_sid`. The `posix_info_sid_size` function returns a maximum of 68 bytes (for `SID_MAX_SUB_AUTHORITIES = 15`). `sizeof(struct cifs_sid)` is also 68 bytes. Thus, the `memcpy` operations will not overflow the destination buffers.

All critical server-supplied values are bounded against the source buffer (via `rsp_iov->iov_len` and `sidsbuf_end`) and the destination buffers (via `sizeof(struct cifs_sid)`).

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 78 |
| Taint snippet | `sidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;` |
| Tainted var | `owner_len` |
| Sink | `memcpy()` line 96 (arg 2, role=size) |
| Sink snippet | `memcpy(&data->posix_owner, sidsbuf, owner_len);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The `owner_len` is derived from `posix_info_sid_size(sidsbuf, sidsbuf_end)`. The `posix_info_sid_size` function (line 5465 in guard callee source) performs a bounds check `beg + total > end` which ensures `owner_len` does not exceed the available bytes between `sidsbuf` and `sidsbuf_end`. The `sidsbuf_end` itself is bounded against `rsp_iov->iov_len` at line 85. The maximum `owner_len` (68 bytes) fits into the destination `data->posix_owner` (a `struct cifs_sid` of 68 bytes). 

Counterexample test: If `sidsbuf_end - sidsbuf` (the available bytes for SIDs) is less than the expected `owner_len` for a valid SID (e.g., 50 bytes available but SID needs 68), `posix_info_sid_size` will return -1, causing `parse_posix_sids` to return -EINVAL at line 93. If `sidsbuf_end - sidsbuf` is sufficient for a valid SID (e.g., 60 bytes available and SID needs 50), then `owner_len` will be 50, which fits into `data->posix_owner`. Thus, no OOB read from source or OOB write to destination will occur.


#### Finding #2 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 78 |
| Taint snippet | `sidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;` |
| Tainted var | `sidsbuf` |
| Sink | `memcpy()` line 96 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&data->posix_owner, sidsbuf, owner_len);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* The pointer `sidsbuf` is derived from `(u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len`. The `smb2_validate_and_copy_iov` call in `smb2_compound_op` before `parse_posix_sids` ensures that `le16_to_cpu(qi->OutputBufferOffset) + sizeof(idata->posix_fi)` (which is `qi_len`) is a valid offset within `rsp_iov->iov_len`. This guarantees that `sidsbuf` is a valid starting pointer within the received buffer. The `memcpy` operation then reads `owner_len` bytes from `sidsbuf`, and `owner_len` is proven to be within `sidsbuf` and `sidsbuf_end` by `posix_info_sid_size` and the checks at lines 85-90. Thus, the read from `sidsbuf` is safe.

Counterexample test: If `le16_to_cpu(qi->OutputBufferOffset) + qi_len` were to point OOB, `smb2_validate_and_copy_iov` would have returned an error, preventing `parse_posix_sids` from being called. If it points to an invalid but in-bounds location, `posix_info_sid_size` would likely return -1 based on the corrupted SID data, leading to an early exit.


#### Finding #3 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 78 |
| Taint snippet | `sidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;` |
| Tainted var | `group_len` |
| Sink | `memcpy()` line 101 (arg 2, role=size) |
| Sink snippet | `memcpy(&data->posix_group, sidsbuf + owner_len, group_len);` |
| Possibly guarded | yes (heuristic) |

*Dismissed:* Similar to `owner_len`, `group_len` is derived from `posix_info_sid_size(sidsbuf + owner_len, sidsbuf_end)`. The `posix_info_sid_size` function ensures `group_len` does not exceed the remaining available bytes between `sidsbuf + owner_len` and `sidsbuf_end`. `sidsbuf_end` is bounded at line 85. The maximum `group_len` (68 bytes) fits into the destination `data->posix_group` (a `struct cifs_sid` of 68 bytes). 

Counterexample test: If the bytes available for the second SID (`sidsbuf_end - (sidsbuf + owner_len)`) are less than what the SID data requires, `posix_info_sid_size` will return -1, leading to an early exit at line 98. If `group_len` is valid, it fits into the destination buffer.


#### Finding #4 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 78 |
| Taint snippet | `sidsbuf = (u8 *)qi + le16_to_cpu(qi->OutputBufferOffset) + qi_len;` |
| Tainted var | `sidsbuf` |
| Sink | `memcpy()` line 101 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&data->posix_group, sidsbuf + owner_len, group_len);` |
| Possibly guarded | no |

*Dismissed:* The pointer for this `memcpy` is `sidsbuf + owner_len`. As established in finding #2, `sidsbuf` is a valid base pointer. As established in finding #1, `owner_len` is bounded such that `sidsbuf + owner_len` remains within the `sidsbuf` to `sidsbuf_end` range. Additionally, `group_len` is validated to ensure that `(sidsbuf + owner_len) + group_len` does not exceed `sidsbuf_end`. Thus, the read from `sidsbuf + owner_len` is safe.

Counterexample test: If `sidsbuf + owner_len` were OOB, the prior `memcpy` at line 96 or the `posix_info_sid_size` call at line 92 would have failed, leading to an early exit. Since `owner_len` is bounded, `sidsbuf + owner_len` remains within the `sidsbuf` to `sidsbuf_end` range, and `group_len` is further bounded to prevent OOB access from that point.



### <a name="reparse-buf-ptr--fs-smb-client-smb2inode-c"></a>reparse_buf_ptr() — `fs/smb/client/smb2inode.c`

**Assessment:** BUG  |  **Confidence:** high

> The function partially validates server-supplied offsets and counts. While combined checks protect the specific `buf->ReparseDataLength` access from going out-of-bounds relative to `iov->iov_len`, a critical lower-bound check for the `OutputOffset` (`off`) is missing. This omission leads to type confusion, where `buf` can alias the `smb2_ioctl_rsp` header if `off` is sufficiently small (e.g., 0). This causes incorrect data to be read and subsequently processed, fitting the 'missing lower-bound check on struct-internal offsets' pattern.

#### Finding #1 — Category E — **BUG** (info_disclosure)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 37 |
| Taint snippet | `off = le32_to_cpu(io->OutputOffset);` |
| Tainted var | `buf` |
| Pointer deref | `buf->ReparseDataLength` line 47 |
| Sink snippet | `rdlen = le16_to_cpu(buf->ReparseDataLength);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Incorrect reparse point parsing, leading to unexpected file behavior, logic errors in path resolution, or denial of service if subsequent logic consumes the misparsed data in a harmful way. Information disclosure can occur if internal `smb2_ioctl_rsp` header fields are misrepresented as reparse data.

**Fix:** Add a lower-bound check for `off` (derived from `io->OutputOffset`) to ensure it is at least `sizeof(struct smb2_ioctl_rsp)` before using it to derive `buf`. This ensures that the `reparse_data_buffer` always starts after the main IOCTL response header. For example, `if (off < sizeof(*io)) return ERR_PTR(...);`.

**CVE pattern:** Missing lower-bound offset validation leading to type confusion



### <a name="smb2-compound-op--fs-smb-client-smb2inode-c"></a>smb2_compound_op() — `fs/smb/client/smb2inode.c`

**Assessment:** FP  |  **Confidence:** high

> The `smb2_validate_and_copy_iov` function, where the sink is located, is designed specifically for validating and then copying data. It calls `smb2_validate_iov` prior to the `memcpy` operation. The purpose of such a validation helper is to ensure that the parameters, including the server-supplied offset and buffer length, are safe to use for memory operations. Assuming `smb2_validate_iov` correctly implements the necessary bounds checks (i.e., that `offset + minbufsize` does not exceed `iov->iov_len`, and that `minbufsize` does not exceed `buffer_length`), then the `memcpy` is adequately guarded.

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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 625 |
| Taint snippet | `rc = smb2_validate_and_copy_iov(` |
| Tainted var | `le16_to_cpu(qi_rsp->OutputBufferOffset)` |
| Call site | line 625 — passes `le16_to_cpu(qi_rsp->OutputBufferOffset)` to `smb2_validate_and_copy_iov()` |
| Call snippet | `rc = smb2_validate_and_copy_iov(` |
| Sink (in callee) | `memcpy()` line 3900 (arg 1, role=pointer) |
| Sink snippet | `memcpy(data, begin_of_buf, minbufsize);` |
| Possibly guarded | no |

*Dismissed:* The `le16_to_cpu(qi_rsp->OutputBufferOffset)` is indeed server-supplied, as `qi_rsp` is a pointer into a server response buffer (`rsp_iov`). However, this value is passed to `smb2_validate_and_copy_iov` which, as its name suggests and its implementation shows, performs internal validation via a call to `smb2_validate_iov` before the `memcpy`. The `smb2_validate_iov` function (although its source is not provided) is expected to ensure that the `offset` and `minbufsize` (which is `sizeof(idata->fi)` or `sizeof(idata->posix_fi)`) do not cause an out-of-bounds read from the `iov` buffer. It should check that `offset + minbufsize <= iov->iov_len` and also that `minbufsize <= buffer_length` (the server-supplied length of the data). Since the sink is within a dedicated validation and copy helper that explicitly calls a validation function before the memory operation, this finding is a false positive. The `memcpy` is part of the intended post-validation data extraction. Counterexample test: If `smb2_validate_iov` is assumed to correctly validate `offset + minbufsize <= iov->iov_len` and `minbufsize <= buffer_length`, then no OOB read is possible. If it didn't, the `smb2_validate_and_copy_iov` function itself would be the bug, not the use of `offset` per se.



### <a name="smb2-check-message--fs-smb-client-smb2misc-c"></a>smb2_check_message() — `fs/smb/client/smb2misc.c`

**Assessment:** FP  |  **Confidence:** high

> The function `smb2_check_message` is a dedicated validation routine for received SMB2 messages. The finding concerns an array access within this validation routine. The `command` variable, derived from a server-supplied field, is explicitly checked against `NUMBER_OF_SMB2_COMMANDS` before being used as an array index. This guard is sufficient to prevent out-of-bounds access.

#### Finding #1 — Category C — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 222 |
| Taint snippet | `command = le16_to_cpu(shdr->Command);` |
| Tainted var | `command` |
| Subscript | `[]` line 248 |
| Sink snippet | `if (smb2_rsp_struct_sizes[command] != pdu->StructureSize2) {` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* `shdr->Command` is a `__le16`, which `le16_to_cpu` converts to an `unsigned short`. This means `command` will always be non-negative, satisfying the lower bound for array indexing (0). The upper bound is explicitly checked at line 223: `if (command >= NUMBER_OF_SMB2_COMMANDS) { return 1; }`. This check ensures that `command` is strictly less than `NUMBER_OF_SMB2_COMMANDS` before it is used as an index into `smb2_rsp_struct_sizes` (and `smb2_min_pdu_len`) at lines 248, 270, and 272. Therefore, the array access is properly bounded. Counterexample test: if `command` were `NUMBER_OF_SMB2_COMMANDS`, the check at line 223 would catch it and return 1, preventing the OOB access. If `command` is `NUMBER_OF_SMB2_COMMANDS - 1` (the largest valid index), it passes the check and is a safe access. The SMT result confirms `command` is non-negative.



### <a name="crypt-message--fs-smb-client-smb2ops-c"></a>crypt_message() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The analysis indicates a false positive due to the scanner misidentifying the variable into which a 64-bit value is supposedly truncated. The 64-bit SessionId is passed correctly as a u64 argument, and the 'rc' variable receives the function's int return code.

#### Finding #1 — Category H — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le64_to_cpu()` line 4838 |
| Taint snippet | `rc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key);` |
| Tainted var | `rc` |
| Truncation | line 4838: 64-bit → 32-bit `u32` |
| Sink snippet | `rc = smb2_get_enc_key(server, le64_to_cpu(tr_hdr->SessionId), enc, key);` |
| Possibly guarded | no |

*Dismissed:* The static analysis incorrectly flags `rc` as the tainted variable that `le64_to_cpu(tr_hdr->SessionId)` is truncated to. `rc` is the `int` return value of the `smb2_get_enc_key` function. The `le64_to_cpu(tr_hdr->SessionId)` value, which is `u64`, is passed as an argument to `smb2_get_enc_key` (which expects a `u64` for `session_id`). There is no truncation of the `SessionId` value into the `rc` variable. The `tr_hdr->SessionId` can be server-supplied in the decryption path (when `enc == 0`).



### <a name="move-smb2-ea-to-cifs--fs-smb-client-smb2ops-c"></a>move_smb2_ea_to_cifs() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The `move_smb2_ea_to_cifs` function iterates through a list of SMB2 extended attributes (EAs) from a server-supplied buffer (`src`) and selectively copies their data to a local buffer (`dst`). The function exhibits a good validation discipline for both source and destination buffers, checking the integrity of each EA entry's declared size and offset before processing. The loop structure includes checks for truncated entries and out-of-range `next_entry_offset` values, and handles cases where the destination buffer is too small.

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 1060 |
| Taint snippet | `value_len = (size_t)le16_to_cpu(src->ea_value_length);` |
| Tainted var | `value_len` |
| Sink | `memcpy()` line 1085 (arg 2, role=size) |
| Sink snippet | `memcpy(dst, value, value_len);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The `value_len` (derived from `src->ea_value_length`) is server-supplied and used as the size argument for `memcpy` at line 1085. This `memcpy` is adequately protected by two independent bounds checks:

1.  **Source buffer bounds check**: Line 1065, `if (src_size < 8 + name_len + 1 + value_len)`, ensures that the entire current EA entry, including its 8-byte header, `name_len` for the name, 1 byte for the null terminator, and `value_len` for the value, fits within the remaining `src_size` of the server-supplied buffer. If this check fails, the function returns an error, preventing an out-of-bounds read from `src`.

2.  **Destination buffer bounds check**: Line 1081, `if (dst_size < value_len)`, checks if the destination buffer (`dst`) has enough space (`dst_size`) to accommodate `value_len` bytes. If `dst_size` is insufficient, `rc` is set to `-ERANGE`, and the function exits, preventing an out-of-bounds write to `dst`.

**Counterexample Test:**
*   **Source OOB**: Let `src_size = 68` bytes remaining. An EA entry declares `name_len = 10` and `value_len = 50`. The required size for this entry is `8 + 10 + 1 + 50 = 69` bytes. The check `68 < 69` at line 1065 is true, leading to `rc = -EIO` and `goto out`, preventing any read beyond `src_size`.
*   **Destination OOB**: Let `dst_size = 40` bytes. The EA entry declares `value_len = 50`. The check `40 < 50` at line 1081 is true, leading to `rc = -ERANGE` and `goto out`, preventing any write beyond `dst_size`.

Both the source and destination buffers are validated against `value_len` before `memcpy` is called, making this a false positive.



### <a name="parse-server-interfaces--fs-smb-client-smb2ops-c"></a>parse_server_interfaces() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The `parse_server_interfaces` function iterates through a server-supplied buffer of network interface information. The `p` pointer advances based on `p->Next` values. The `bytes_left` variable is crucial for bounds checking.

While there is a genuine missing bounds check before the read of `p->Next` at line 782 (the first time `next` is assigned), the static analysis finding targets `p->Next` at line 807. At line 807, the `p->Next` access is guarded by a conditional `bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(p->Next) && p->Next`. 

At this point, `bytes_left` has been reduced to represent the remaining buffer size *after* the last fully processed `network_interface_info_ioctl_rsp` structure pointed to by `p` (specifically, if the loop terminated because `next` was 0, `bytes_left` was reduced by `sizeof(*p)`). This makes the `bytes_left` value smaller than the true remaining buffer from `p`'s current location.

However, if the condition `bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(p->Next)` *does* evaluate to true, it implies that the total original buffer length (`buf_len`) was significantly larger than the sum of consumed bytes plus the size of the *last* struct, ensuring `p->Next` would be well within bounds. Thus, the specific access at line 807 is sufficiently guarded by the short-circuiting `&&` operator.

The real vulnerability would be the initial read of `p->Next` at line 782 without verifying `bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(u32)` before the read.

#### Finding #1 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 782 |
| Taint snippet | `next = le32_to_cpu(p->Next);` |
| Tainted var | `p` |
| Pointer deref | `p->Next` line 807 |
| Sink snippet | `+ sizeof(p->Next) && p->Next))` |
| Possibly guarded | no |

*Dismissed:* The `p` pointer is initialized from `buf`, which is a server-supplied buffer. Its subsequent values are derived by adding a server-supplied `next` offset, making `p` tainted.

The access `p->Next` at line 807 is within an `if` condition: `(bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(p->Next) && p->Next)`. Due to C's short-circuit evaluation, `p->Next` will only be dereferenced if the first part of the condition is true.

Let `p_last_offset` be the offset of `p` at line 807 from the original `buf` start. The actual bytes remaining from `p` is `buf_len - p_last_offset`. When the loop terminates due to `!next`, `bytes_left` is updated by `bytes_left -= sizeof(*p);` (line 784). So, `bytes_left` at line 807 becomes `(buf_len - p_last_offset) - sizeof(*p)`. 

For `p->Next` to be accessed, the condition `(buf_len - p_last_offset) - sizeof(*p) >= offsetof(..., Next) + sizeof(u32)` must hold. If this condition holds, then `(buf_len - p_last_offset)` must be greater than or equal to `sizeof(*p) + offsetof(..., Next) + sizeof(u32)`. Since `offsetof(..., Next) + sizeof(u32)` is less than this value, the original buffer has sufficient remaining length from `p_last_offset` to safely read `p->Next`. Thus, the guard, while based on a somewhat convoluted `bytes_left` calculation, is sufficient to prevent OOB at this specific dereference.



### <a name="receive-encrypted-standard--fs-smb-client-smb2ops-c"></a>receive_encrypted_standard() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The function `receive_encrypted_standard` processes network data that has already been partially validated and decrypted by its caller. The `pdu_length` variable used for buffer sizing is derived from the server-supplied `server->pdu_size` but is bounded by the caller (`smb3_receive_transform`) to `CIFSMaxBufSize + MAX_HEADER_SIZE(server)`. The `next_cmd` offset is subject to multiple checks before being used in the `memcpy` operation.

The critical aspect is how the `pdu_length` (decrypted length) relates to the allocated buffer size. Initial `pdu_length` is `server->pdu_size`. After decryption, it becomes `server->pdu_size - sizeof(struct smb2_transform_hdr)`. The maximum value for `server->pdu_size` is `CIFSMaxBufSize + MAX_HEADER_SIZE(server)`. The minimum value for `next_cmd` (if non-zero) is `MID_HEADER_SIZE(server)`.

Thus, the maximum size copied by `memcpy` is `(CIFSMaxBufSize + MAX_HEADER_SIZE(server) - sizeof(struct smb2_transform_hdr)) - MID_HEADER_SIZE(server)`. Assuming `MAX_HEADER_SIZE(server)` and `MID_HEADER_SIZE(server)` are both `sizeof(struct smb2_hdr)` (64 bytes) and `sizeof(struct smb2_transform_hdr)` is 16 bytes, this simplifies to `(CIFSMaxBufSize + 64 - 16) - 64 = CIFSMaxBufSize - 16`. This value correctly fits into a `CIFSMaxBufSize` buffer allocated for `next_buffer` when `next_is_large` is true. The source buffer (`buf`) is also correctly bounded by `pdu_length` and `next_cmd <= pdu_length` from the explicit check.

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le32_to_cpu()` line 5464 |
| Taint snippet | `next_cmd = le32_to_cpu(shdr->NextCommand);` |
| Tainted var | `next_cmd` |
| Sink | `memcpy()` line 5490 (arg 2, role=size) |
| Sink snippet | `memcpy(next_buffer, buf + next_cmd, pdu_length - next_cmd);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: value is unsigned at the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The tainted variable `next_cmd` is derived from `shdr->NextCommand`, which is part of the server-supplied network buffer. Thus, it is genuinely server-supplied.

Bounds checks for `next_cmd` are present at lines 5472-5481:
1. `if (next_cmd)`: The `memcpy` is only executed if `next_cmd` is non-zero. If `next_cmd` is 0, the code path skips the `memcpy` entirely.
2. `next_cmd < MID_HEADER_SIZE(server)`: Ensures `next_cmd` is not too small. If `next_cmd` is non-zero, it must be at least `MID_HEADER_SIZE(server)` (typically `sizeof(struct smb2_hdr)` or 64 bytes).
3. `next_cmd > pdu_length`: Ensures `next_cmd` does not point past the end of the current `buf` (the decrypted PDU). Since `pdu_length` represents the total valid size of `buf`, this check prevents reading past `buf`'s logical end.
4. `pdu_length - next_cmd < MID_HEADER_SIZE(server)`: Ensures that the remaining data (the size of the `memcpy`) is at least a minimum header size. This primarily guards against truncated messages, not necessarily the upper bound of the memcpy destination.

Let's analyze the size argument `pdu_length - next_cmd` for `memcpy` at line 5490 against the destination buffer `next_buffer`:
- The `pdu_length` variable used in the `memcpy` is updated at line 5460 to be `server->pdu_size - sizeof(struct smb2_transform_hdr)`. The caller `smb3_receive_transform` (line 5559) ensures that `server->pdu_size <= CIFSMaxBufSize + MAX_HEADER_SIZE(server)`.
- Thus, the maximum value for `pdu_length` at the `memcpy` is `CIFSMaxBufSize + MAX_HEADER_SIZE(server) - sizeof(struct smb2_transform_hdr)`.
- From the checks, if `next_cmd` is non-zero, it must be at least `MID_HEADER_SIZE(server)`.
- The maximum value of the `memcpy` size is therefore `(CIFSMaxBufSize + MAX_HEADER_SIZE(server) - sizeof(struct smb2_transform_hdr)) - MID_HEADER_SIZE(server)`.
- If `MAX_HEADER_SIZE(server)` is `sizeof(struct smb2_hdr)` (64 bytes), `MID_HEADER_SIZE(server)` is `sizeof(struct smb2_hdr)` (64 bytes), and `sizeof(struct smb2_transform_hdr)` is 16 bytes, then the maximum `memcpy` size is `(CIFSMaxBufSize + 64 - 16) - 64 = CIFSMaxBufSize - 16`.
- The `next_buffer` is allocated to `CIFSMaxBufSize` (if `next_is_large`). A copy of `CIFSMaxBufSize - 16` bytes perfectly fits into a `CIFSMaxBufSize` buffer. Therefore, the destination buffer is adequately sized.

For the source buffer `buf + next_cmd`:
- We know `next_cmd <= pdu_length` from the `next_cmd > pdu_length` check. `buf` contains `pdu_length` bytes of valid data. Therefore, `buf + next_cmd` is a valid starting address within `buf`, and `pdu_length - next_cmd` is the number of remaining bytes, preventing an OOB read from the source.

Counterexample test:
Assume `CIFSMaxBufSize = 65536`, `MAX_HEADER_SIZE(server) = 64`, `MID_HEADER_SIZE(server) = 64`, `sizeof(struct smb2_transform_hdr) = 16`.
1. Set `server->pdu_size = CIFSMaxBufSize + MAX_HEADER_SIZE(server) = 65536 + 64 = 65600`. This value passes the caller's check at line 5559.
2. After line 5460, `pdu_length` becomes `server->pdu_size - sizeof(struct smb2_transform_hdr) = 65600 - 16 = 65584`.
3. Set `next_cmd = MID_HEADER_SIZE(server) = 64`. This value passes all checks at lines 5472-5481 (`next_cmd` is not 0, `64 < 64` is false (passes), `64 > 65584` is false (passes), `65584 - 64 < 64` is false (passes)).
4. `next_is_large` is true because `server->pdu_size > MAX_CIFS_SMALL_BUFFER_SIZE`.
5. `next_buffer` is allocated as a large buffer (size `CIFSMaxBufSize = 65536`).
6. The `memcpy` at line 5490 copies `pdu_length - next_cmd = 65584 - 64 = 65520` bytes.
7. `65520` bytes fit into a `65536` byte buffer. No OOB occurs.

The SMT result indicating the size is unsigned (non-negative) is consistent with the `next_cmd > pdu_length` check ensuring `pdu_length - next_cmd` is not negative.



### <a name="smb2-ioctl-query-info--fs-smb-client-smb2ops-c"></a>smb2_ioctl_query_info() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The `smb2_ioctl_query_info` function handles an `ioctl` call where `arg` is an `unsigned long p` pointing to a user-space buffer. The kernel code reads a `smb_query_info` struct from `arg` and then potentially copies additional data to `arg + sizeof(struct smb_query_info)`. The size of this additional data, `qi.input_buffer_length`, is initially user-supplied but is capped by server-provided lengths and further validated against the kernel's received response buffer size. While the kernel explicitly validates the source buffer for `copy_to_user`, it does not explicitly validate the total size of the user-provided `arg` buffer against `sizeof(struct smb_query_info) + qi.input_buffer_length`. However, `copy_to_user` is designed to return `-EFAULT` if the operation would write outside the process's mapped memory, thereby preventing kernel memory corruption. These findings are therefore considered false positives for kernel memory safety issues, though the `ioctl` API design could be made more robust by requiring the `ioctl` command to encode the expected user-space buffer size or by performing an `access_ok` check with a derived total size for the user buffer.

#### Finding #1 — Category G2 — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat G2 — unvalidated size argument to copy_from/to_user |
| Taint source | `copy_to_user()` line 1797 |
| Taint snippet | `if (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info),` |
| Tainted var | `qi.input_buffer_length` |
| Unvalidated size | `copy_to_user()` arg 2 line 1797 — size `qi.input_buffer_length` |
| Sink snippet | `if (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info),` |
| Possibly guarded | no |

*Dismissed:* The `qi.input_buffer_length` is initially user-supplied (via `copy_from_user` at line 1717), then capped by the server-supplied `io_rsp->OutputCount` (line 1781). The source buffer for the `copy_to_user` operation is validated to fit within the kernel's received response buffer at lines 1783-1785 (`size_add(io_rsp->OutputOffset, qi.input_buffer_length) > rsp_iov[1].iov_len`). However, the kernel code does not explicitly validate the size of the user-supplied destination buffer (`pqi`) against the total expected length (`sizeof(struct smb_query_info) + qi.input_buffer_length`). Despite this missing explicit check, `copy_to_user()` (used at line 1797) inherently performs checks against the user process's memory map. If the write operation would go beyond the valid mapped region in user-space, `copy_to_user()` returns `-EFAULT`, which is handled by the `rc = -EFAULT` assignment, preventing kernel memory corruption. Thus, for kernel memory safety, the protection is sufficient, making this a false positive.


#### Finding #2 — Category G2 — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat G2 — unvalidated size argument to copy_from/to_user |
| Taint source | `copy_to_user()` line 1819 |
| Taint snippet | `if (copy_to_user(pqi + 1, qi_rsp->Buffer,` |
| Tainted var | `qi.input_buffer_length` |
| Unvalidated size | `copy_to_user()` arg 2 line 1819 — size `qi.input_buffer_length` |
| Sink snippet | `if (copy_to_user(pqi + 1, qi_rsp->Buffer,` |
| Possibly guarded | no |

*Dismissed:* Similar to finding #1, `qi.input_buffer_length` is initially user-supplied (via `copy_from_user` at line 1717), then capped by the server-supplied `qi_rsp->OutputBufferLength` (line 1804). The source buffer for the `copy_to_user` operation is validated to fit within the kernel's received response buffer at lines 1807-1809 (`struct_size(qi_rsp, Buffer, qi.input_buffer_length) > rsp_iov[1].iov_len`). The `copy_to_user()` operation at line 1819 targets a user-space buffer (`pqi + 1`). As with finding #1, the kernel code lacks an explicit validation of the user-supplied `arg` buffer's total size. However, `copy_to_user()` itself provides protection against kernel memory corruption by returning `-EFAULT` if the copy would extend beyond the user process's valid memory mappings. This effectively mitigates the security risk to the kernel. Therefore, this finding is also a false positive for a kernel memory safety bug.



### <a name="smb2-query-eas--fs-smb-client-smb2ops-c"></a>smb2_query_eas() — `fs/smb/client/smb2ops.c`

**Assessment:** MIXED  |  **Confidence:** high

> The function `smb2_query_eas` retrieves extended attributes. It initially validates the overall buffer extent and minimum size using `smb2_validate_iov`. The `move_smb2_ea_to_cifs` helper processes a list of variable-length EA entries. While the initial buffer size and per-entry data length checks are present, the traversal logic, particularly the server-supplied `next_entry_offset` for advancing through the list, appears to be missing a crucial bounds validation, which can lead to out-of-bounds reads on subsequent iterations.

#### Finding #1 — Category C — cross-function via `move_smb2_ea_to_cifs()` — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 1179 |
| Taint snippet | `info = (struct smb2_file_full_ea_info *)(` |
| Tainted var | `info` |
| Call site | line 1181 — passes `info` to `move_smb2_ea_to_cifs()` |
| Call snippet | `rc = move_smb2_ea_to_cifs(ea_data, buf_size, info,` |
| Subscript (in callee) | `[]` line 1073 |
| Sink snippet | `value = &src->ea_data[src->ea_name_length + 1];` |
| Possibly guarded | no |

*Dismissed:* The tainted `info` pointer is derived from `rsp->OutputBufferOffset` (server-supplied). However, `smb2_validate_iov` is called *before* `info` is passed to `move_smb2_ea_to_cifs`. The validator's postcondition guarantees that `offset + sizeof(struct smb2_file_full_ea_info)` fits within the received `iov`, meaning `info` points to a valid location and at least the header of `smb2_file_full_ea_info` is accessible. Inside `move_smb2_ea_to_cifs`, the `while (src_size >= sizeof(*src))` loop ensures enough space for the header. The critical check at line 1065 (`if (src_size < 8 + name_len + 1 + value_len)`) explicitly guards against `name_len` and `value_len` causing the current EA entry to extend beyond `src_size`. All listed sinks (`memcmp` arg size, `memcpy` pointer/size) are covered by this check. For example, if `src_size=100`, `name_len=90`, `value_len=0`, then `8+90+1+0=99`. `100 < 99` is false, so the check passes. `value` pointer would be at `src + 99`, which is within the 100-byte `src_size`. Thus, the accesses are protected.


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

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le32_to_cpu()` line 1181 |
| Taint snippet | `rc = move_smb2_ea_to_cifs(ea_data, buf_size, info,` |
| Tainted var | `le32_to_cpu(rsp->OutputBufferLength)` |
| Call site | line 1181 — passes `le32_to_cpu(rsp->OutputBufferLength)` to `move_smb2_ea_to_cifs()` |
| Call snippet | `rc = move_smb2_ea_to_cifs(ea_data, buf_size, info,` |
| Loop | `while_loop` line 1058 |
| Sink snippet | `while (src_size >= sizeof(*src)) {` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic due to out-of-bounds read, or information disclosure by parsing garbage data.

**Fix:** Before `src` is advanced and `src_size` reduced by `src->next_entry_offset` (which is server-supplied), `src->next_entry_offset` must be validated.
1. Add a check `if (next_entry_offset == 0 && src_size > sizeof(*src))` to prevent infinite loops (if `next_entry_offset` should always be non-zero for non-last entries) or ensure `next_entry_offset == 0` is handled correctly as the end-of-list marker. The current snippet does `if (name_len == 0) break;` but not `next_entry_offset == 0`.
2. Add a check `if (next_entry_offset > src_size)` to prevent `src_size` from underflowing and `src` from advancing past the validated buffer. This would also prevent wrapping `src_size` to a large positive value.
3. Add a check `if (next_entry_offset < 8 + name_len + 1 + value_len)` to ensure `next_entry_offset` is not smaller than the actual size of the current entry, which would cause the next entry's header to be read from inside the current entry's data.

**CVE pattern:** SMB_next_entry_offset_OOB



### <a name="smb3-enum-snapshots--fs-smb-client-smb2ops-c"></a>smb3_enum_snapshots() — `fs/smb/client/smb2ops.c`

**Assessment:** BUG  |  **Confidence:** high

> The function `smb3_enum_snapshots` retrieves snapshot information from a server and copies it to a user-supplied buffer (`ioc_buf`). The size argument for `copy_to_user` is initially based on a value received from the server (`ret_data_len` from `SMB2_ioctl`). However, this value can be subsequently modified based on a field (`snapshot_in.snapshot_array_size`) read directly from the user-supplied `ioc_buf`. Crucially, there is no validation that this final calculated copy size (`ret_data_len`) remains within the bounds of the original user-declared size for `ioc_buf` (which is read at the beginning of the function). This allows a malicious user to supply an `snapshot_in.snapshot_array_size` value that inflates the copy size, leading to an attempted `copy_to_user` operation that exceeds the actual allocated user buffer, resulting in an information disclosure.

#### Finding #1 — Category G2 — **BUG** (info_disclosure)

| Field | Value |
|---|---|
| Category | Cat G2 — unvalidated size argument to copy_from/to_user |
| Taint source | `copy_to_user()` line 2487 |
| Taint snippet | `if (copy_to_user(ioc_buf, retbuf, ret_data_len))` |
| Tainted var | `ret_data_len` |
| Unvalidated size | `copy_to_user()` arg 2 line 2487 — size `ret_data_len` |
| Sink snippet | `if (copy_to_user(ioc_buf, retbuf, ret_data_len))` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** If `copy_to_user` attempts to write beyond the user's allocated buffer, it will return `-EFAULT`. This would be observed as an IOCTL failure in user space, potentially accompanied by kernel warnings/error messages indicating an invalid user address range. More critically, if `retbuf` (kernel memory) contains sensitive data beyond the actually valid `kernel_ret_len` bytes, and `ret_data_len` is inflated by the user, then uninitialized or sensitive kernel memory could be copied to user space.

**Fix:** Store the initial user-provided length (read at L2425) in a separate variable, say `user_initial_ioc_buf_len`. Before the `copy_to_user` call at L2487, ensure that `ret_data_len` is capped by `user_initial_ioc_buf_len`. 

Example:
```c
unsigned int user_initial_ioc_buf_len;
// ...
if (get_user(user_initial_ioc_buf_len, (unsigned int __user *)ioc_buf))
	return -EFAULT;
// ... (rest of the function, where ret_data_len is used and modified)
// ...
// Before L2487:
ret_data_len = min(ret_data_len, user_initial_ioc_buf_len);
if (copy_to_user(ioc_buf, retbuf, ret_data_len))
	rc = -EFAULT;
```

**CVE pattern:** CWE-125 (Out-of-bounds Read) / CWE-20 (Improper Input Validation) leading to Information Disclosure (kernel copies uninitialized memory to user space). Similar to 'kernel copies too much data to user space' patterns.



### <a name="smb3-fiemap--fs-smb-client-smb2ops-c"></a>smb3_fiemap() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The function `smb3_fiemap` retrieves file allocation ranges from a server via `SMB2_ioctl`. The `SMB2_ioctl` helper ensures that the `out_data` buffer is properly allocated and points to server-supplied data that fits within the received network response. The subsequent loops and accesses to `out_data[i]` are bounded by `out_data_len` checks, ensuring array access within the `out_data` buffer itself is safe.

#### Finding #1 — Category H — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le64_to_cpu()` line 4369 |
| Taint snippet | `rc = fiemap_fill_next_extent(fei,` |
| Tainted var | `rc` |
| Truncation | line 4369: 64-bit → 32-bit `u32` |
| Sink snippet | `rc = fiemap_fill_next_extent(fei,` |
| Possibly guarded | no |

*Dismissed:* The finding states that `rc` is the tainted variable and that truncation occurs at line 4369, where `rc` is assigned the return value of `fiemap_fill_next_extent`. The scanner's reason explicitly says '64-bit value from le64_to_cpu() silently truncated to 32-bit 'rc''. This is a misinterpretation of C semantics.

`fiemap_fill_next_extent` is called with arguments `le64_to_cpu(out_data[i].file_offset)` and `le64_to_cpu(out_data[i].length)`. Both of these are `u64` values and are passed correctly as `u64` arguments to `fiemap_fill_next_extent`.

The `rc` variable is an `int` and receives the *return value* of `fiemap_fill_next_extent`. The `fiemap_fill_next_extent` function returns an `int` status code (0, 1, or negative error codes), not a truncated version of its `u64` arguments. Therefore, there is no truncation of the server-supplied `u64` offsets or lengths *into* the `rc` variable at this line. The `u64` arguments are handled as `u64` by the callee function, which is designed to work with large file offsets.

Counterexample test: If `out_data[i].file_offset` is `0x1_0000_0000ULL` (exceeding 32-bit max), it is passed as a `u64` to `fiemap_fill_next_extent`. The `rc` variable will receive an `int` status code, which is typically small and unrelated to the `u64` value. No truncation of the `u64` into `rc` occurs, as `rc` is not intended to hold the offset/length values.



### <a name="smb3-simple-fallocate-range--fs-smb-client-smb2ops-c"></a>smb3_simple_fallocate_range() — `fs/smb/client/smb2ops.c`

**Assessment:** FP  |  **Confidence:** high

> The function handles server-supplied 64-bit range information (`file_offset`, `length`) by reading them into 64-bit local variables (`range_start`, `range_len`) and performs an overflow check on `range_end`. The `out_data_len` (u32) returned by `SMB2_ioctl` is used to bound the loop and dereferences within the `out_data` buffer. The `SMB2_ioctl` helper ensures `out_data` is a validated buffer from the server. The specific finding regarding `rc` is based on a misinterpretation of the assignment.

#### Finding #1 — Category H — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le64_to_cpu()` line 3835 |
| Taint snippet | `rc = smb3_simple_fallocate_write_range(xid, tcon,` |
| Tainted var | `rc` |
| Truncation | line 3835: 64-bit → 32-bit `u32` |
| Sink snippet | `rc = smb3_simple_fallocate_write_range(xid, tcon,` |
| Possibly guarded | no |

*Dismissed:* The scanner claims '64-bit value (via `l`, from le64_to_cpu()) silently truncated to 32-bit `rc`' at line 3835. However, `rc` is an `int` variable and it is assigned the *return value* of `smb3_simple_fallocate_write_range(xid, tcon, cfile, off, l, buf)`. The `smb3_simple_fallocate_write_range` function (like most kernel functions returning status) is expected to return an `int` (typically 0 for success or a negative errno code for failure). There is no truncation of the `loff_t` (64-bit) argument `l` to the `int` variable `rc` occurring at this assignment. The type of `l` is `loff_t` (long long, 64-bit), and it is passed as a `loff_t` argument to `smb3_simple_fallocate_write_range`. The scanner has confused the assignment of the function's return value to `rc` with a truncation of one of the function's arguments (`l`) to `rc`.



### <a name="smb2-qfs-attr--fs-smb-client-smb2pdu-c"></a>SMB2_QFS_attr() — `fs/smb/client/smb2pdu.c`

**Assessment:** MIXED  |  **Confidence:** high

> The function `SMB2_QFS_attr` processes server responses for file system attribute queries. It uses `le32_to_cpu` and `le16_to_cpu` to extract `OutputBufferLength` and `OutputBufferOffset` from the server-supplied `smb2_query_info_rsp` structure. A crucial validation step is performed by `smb2_validate_iov`, which checks if the data buffer defined by `offset` and `rsp_len` fits within the overall received network buffer (`iov->iov_len`), and that `rsp_len` meets a minimum size requirement for the expected data structure. While `smb2_validate_iov` provides good upper-bound checking and minimum data length checking, it does not explicitly validate the *lower bound* of `OutputBufferOffset`. This means the `offset` could point *into* the `smb2_query_info_rsp` header itself rather than *after* it, leading to misinterpretation of header fields as data. One finding is a false positive due to robust `min_t` usage, while two others represent real bugs.

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le32_to_cpu()` line 6312 |
| Taint snippet | `rsp_len = le32_to_cpu(rsp->OutputBufferLength);` |
| Tainted var | `rsp_len` |
| Sink | `memcpy()` line 6319 (arg 2, role=size) |
| Sink snippet | `memcpy(&tcon->fsAttrInfo, offset` |
| Possibly guarded | no |

*Dismissed:* The taint source `rsp->OutputBufferLength` (via `rsp_len`) is server-supplied. The sink is the size argument to `memcpy`. The copy size is `min_t(unsigned int, rsp_len, min_len)`. For this branch (`level == FS_ATTRIBUTE_INFORMATION`), `min_len` is `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)`. The destination `&tcon->fsAttrInfo` is also of type `FILE_SYSTEM_ATTRIBUTE_INFO`. Therefore, the `memcpy` will never write more than `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)` bytes into a destination buffer of exactly that size, preventing OOB write.

Regarding the source buffer for `memcpy`: `smb2_validate_iov(offset, rsp_len, &rsp_iov, min_len)` is called prior to the `memcpy`. This validator ensures that `offset + rsp_len <= iov->iov_len` (the actual received buffer length). Thus, the source read cannot be out-of-bounds.

Counterexample test:
- `iov->iov_len = 100`
- `rsp->OutputBufferOffset = 70`
- `rsp->OutputBufferLength = 50`
- `min_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) = 30` (hypothetical)
- `offset = 70`, `rsp_len = 50`
- `smb2_validate_iov(70, 50, &rsp_iov, 30)`:
  - `buffer_length (50) >= min_buf_size (30)` -> OK
  - `end_of_buf = iov_base + 70 + 50 = iov_base + 120`
  - `end_of_buf (iov_base + 120) > end_of_smb (iov_base + 100)` -> Returns -EINVAL. Correctly prevents OOB read from source.
- If `rsp->OutputBufferLength = 20` (instead of 50):
  - `smb2_validate_iov(70, 20, &rsp_iov, 30)`:
    - `buffer_length (20) < min_buf_size (30)` -> Returns -EINVAL. Correctly prevents OOB if data is too small.
- If `rsp->OutputBufferOffset = 5`, `rsp->OutputBufferLength = 30`:
  - `smb2_validate_iov(5, 30, &rsp_iov, 30)` passes if `iov_base+5+30 <= iov_base+100`.
  - `memcpy(&tcon->fsAttrInfo, iov_base + 5, min_t(30, 30))` will copy 30 bytes from `iov_base+5`. This is within `iov_base+100` and into `tcon->fsAttrInfo` which is 30 bytes. No OOB.


#### Finding #2 — Category E — **BUG** (info_disclosure)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 6313 |
| Taint snippet | `offset = le16_to_cpu(rsp->OutputBufferOffset);` |
| Tainted var | `ss_info` |
| Pointer deref | `ss_info->Flags` line 6328 |
| Sink snippet | `tcon->ss_flags = le32_to_cpu(ss_info->Flags);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Incorrect file system sector size information, potential logic errors in subsequent operations using `tcon->ss_flags` or `tcon->perf_sector_size`. This can lead to misconfigured I/O or other issues, including kernel panics if misinterpreted values are used as pointers or lengths.

**Fix:** Add a check immediately after line 6315, before the `if (level == ...)` block, to ensure `offset` is greater than or equal to the size of the `smb2_query_info_rsp` header: `if (offset < sizeof(struct smb2_query_info_rsp)) { cifs_dbg(VFS, "qfsinfo offset %u before header end %zu
", offset, sizeof(struct smb2_query_info_rsp)); rc = -EINVAL; goto qfsattr_exit; }`

**CVE pattern:** Missing lower-bound check on struct-internal offsets


#### Finding #3 — Category E — **BUG** (info_disclosure)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le16_to_cpu()` line 6313 |
| Taint snippet | `offset = le16_to_cpu(rsp->OutputBufferOffset);` |
| Tainted var | `vol_info` |
| Pointer deref | `vol_info->VolumeSerialNumber` line 6334 |
| Sink snippet | `tcon->vol_serial_number = le32_to_cpu(vol_info->VolumeSerialNumber);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Incorrect file system volume serial number or creation time, potential logic errors in subsequent operations. This can lead to misidentification of volumes or other issues, including kernel panics if misinterpreted values are used as pointers or lengths.

**Fix:** Add a check immediately after line 6315, before the `if (level == ...)` block, to ensure `offset` is greater than or equal to the size of the `smb2_query_info_rsp` header: `if (offset < sizeof(struct smb2_query_info_rsp)) { cifs_dbg(VFS, "qfsinfo offset %u before header end %zu
", offset, sizeof(struct smb2_query_info_rsp)); rc = -EINVAL; goto qfsattr_exit; }`

**CVE pattern:** Missing lower-bound check on struct-internal offsets



### <a name="smb2-plain-req-init--fs-smb-client-smb2pdu-c"></a>__smb2_plain_req_init() — `fs/smb/client/smb2pdu.c`

**Assessment:** FP  |  **Confidence:** high

> The function `__smb2_plain_req_init` is a request initialization helper. This means it is responsible for constructing an outgoing SMB2 request message. In this context, the `smb2_command` argument represents the command code that the *client kernel* intends to send, not a value parsed from a received server response. Although it's of type `__le16` and undergoes `le16_to_cpu` conversion, its origin is a kernel-defined constant (as seen in `smb2_ioctl_req_init` passing `SMB2_IOCTL`) or another kernel-controlled value for other request types. Therefore, the value `com_code` is locally controlled and not server-supplied. Array indexing based on such a value is implicitly bounded by the kernel's correct usage of its own constants.

#### Finding #1 — Category C — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 578 |
| Taint snippet | `uint16_t com_code = le16_to_cpu(smb2_command);` |
| Tainted var | `com_code` |
| Subscript | `[]` line 579 |
| Sink snippet | `cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]);` |
| Possibly guarded | no |
| SMT | **proved** `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` argument is used in a function that initializes an *outgoing request*. Per common false positive pattern #1, values originating from a locally-constructed request (like the command code chosen by the client) are not considered server-supplied. The `le16_to_cpu` call is applied to a kernel-controlled constant (or kernel-chosen value) which will always be within the expected bounds of the `smb2_com_sent` array. For example, in `smb2_ioctl_req_init`, `SMB2_IOCTL` is a compile-time constant (0x0B). The `smb2_com_sent` array is sized by `SMB2_COMMANDS_MAX`, which for SMB2 commands (e.g., 0x06 for QUERY_INFO, 0x07 for SET_INFO, 0x0B for IOCTL, up to 0x1A for CANCEL) is guaranteed to be larger than any valid command code. Therefore, no malicious server input can influence `com_code` to cause an OOB access.



### <a name="decode-compress-ctx--fs-smb-client-smb2pdu-c"></a>decode_compress_ctx() — `fs/smb/client/smb2pdu.c`

**Assessment:** BUG  |  **Confidence:** high

> The `decode_compress_ctx` function processes a server-supplied `smb2_compression_capabilities_context` structure. The `len` variable, derived from `pctx->DataLength`, represents the total length of this context block. This context has a fixed header of 10 bytes (comprising `StructureSize`, `Padding`, `CompressionAlgorithmCount`, and `Flags`), followed by a variable-length array of `__le16` compression algorithms. The code intends to iterate `count` times to read these algorithms. A bounds check at line 855, `len < 8 + count * sizeof(__le16)`, is meant to ensure that the allocated context buffer is large enough for the header plus all algorithms. However, this check incorrectly uses `8` bytes as the fixed header size, whereas the actual fixed header (before `CompressionAlgorithms[]`) is 10 bytes. This 2-byte discrepancy means the check is insufficient, allowing `len` to be 1 or 2 bytes smaller than required, leading to an out-of-bounds read when accessing `ctxt->CompressionAlgorithms[i]` within the loop. The use of `ARRAY_SIZE(ctxt->CompressionAlgorithms)` on a flexible array member is technically problematic as it often evaluates to 0, which would cause an early return for any `count > 0` and make the loop unreachable. This would turn the finding into a false positive *for the OOB read at the sink*. However, given the clear intent to process algorithms (evidenced by the loop and comments), it's more likely that the `ARRAY_SIZE` check is itself a bug preventing the intended functionality. Assuming the loop is intended to be reachable, the `len < 8 + ...` check is a real and exploitable bug.

#### Finding #1 — Category F — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 854 |
| Taint snippet | `count = le16_to_cpu(ctxt->CompressionAlgorithmCount);` |
| Tainted var | `count` |
| Loop | `for_loop` line 867 |
| Sink snippet | `for (i = 0; i < count; i++) {` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic, KASAN: slab-out-of-bounds read in decode_compress_ctx

**Fix:** The bounds check for the array elements is off by 2 bytes. The fixed header of `struct smb2_compression_capabilities_context` is 10 bytes, not 8. Change `len < 8 + count * sizeof(__le16)` to `len < 10 + count * sizeof(__le16)`. A more robust fix would use `len < offsetof(struct smb2_compression_capabilities_context, CompressionAlgorithms) + count * sizeof(__le16)`. 

Separately, the check `count > ARRAY_SIZE(ctxt->CompressionAlgorithms)` on line 855 uses `ARRAY_SIZE` on a flexible array member. This typically evaluates to `count > 0`, causing the function to return early for any non-zero count. This prevents the intended processing of compression algorithms and should be investigated as a bug in its own right; it effectively makes the loop at line 867 unreachable, masking the OOB read reported here. If this `ARRAY_SIZE` check is fixed (e.g., by replacing `ARRAY_SIZE` with a constant representing a protocol-defined maximum count), the reported OOB becomes directly reachable and exploitable.

**CVE pattern:** SMB negotiate response array processing OOB read



### <a name="fill-small-buf--fs-smb-client-smb2pdu-c"></a>fill_small_buf() — `fs/smb/client/smb2pdu.c`

**Assessment:** FP  |  **Confidence:** high

> The `smb2_command` parameter in `fill_small_buf` is used to construct an SMB2 request, not parse a response. It originates from kernel-controlled `SMB2_COMMAND_*` constants rather than server-supplied input. Therefore, the value passed to `le16_to_cpu()` is a known kernel constant, making the array access inherently safe.

#### Finding #1 — Category C — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 535 |
| Taint snippet | `__u16 parmsize = smb2_req_struct_sizes[le16_to_cpu(smb2_command)];` |
| Tainted var | `le16_to_cpu(smb2_command)` |
| Subscript | `[]` line 535 |
| Sink snippet | `__u16 parmsize = smb2_req_struct_sizes[le16_to_cpu(smb2_command)];` |
| Possibly guarded | no |

*Dismissed:* The `smb2_command` parameter is passed to `fill_small_buf` from `__smb2_plain_req_init`. As noted in false positive pattern 1, `__smb2_plain_req_init` is a request-initialization helper. This means `smb2_command` is a kernel-controlled constant (e.g., `SMB2_SET_INFO`, `SMB2_QUERY_INFO`, etc.) selected by the kernel to build a request, not a value parsed from a server response. Thus, `le16_to_cpu(smb2_command)` will always be a valid, known index within the `smb2_req_struct_sizes` array, which is hardcoded in the kernel to match these command values. No out-of-bounds access is possible.



### <a name="parse-posix-ctxt--fs-smb-client-smb2pdu-c"></a>parse_posix_ctxt() — `fs/smb/client/smb2pdu.c`

**Assessment:** FP  |  **Confidence:** high

> The `parse_posix_ctxt` function correctly processes server-supplied create context data. The parent function `smb2_parse_contexts` performs initial validation to ensure that the `DataOffset` and `DataLength` fields of the `create_context` (`cc`) result in a valid range `[beg, end)` within the overall response buffer (`cc_len`). Inside `parse_posix_ctxt`, a minimum `dlen` check ensures `beg + 12` (the start of the first SID) is within bounds. The critical `posix_info_sid_size` helper then rigorously validates the length of each SID against the `end` pointer before `memcpy` is called, preventing both OOB reads from the source and ensuring the calculated `sid_len` is within the maximum allowed for the `owner_sid` and `group_sid` fields of `struct create_posix_rsp` (which are defined as `char[MAX_SID_SIZE]` in the kernel source, typically 68 bytes).

#### Finding #1 — Category B — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le16_to_cpu()` line 2399 |
| Taint snippet | `u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset);` |
| Tainted var | `sid_len` |
| Sink | `memcpy()` line 2419 (arg 2, role=size) |
| Sink snippet | `memcpy(&posix->owner, sid, sid_len);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `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 derived from server-supplied `cc->DataOffset` and `cc->DataLength` via the `beg` and `end` pointers, and further processed by `posix_info_sid_size`. The `posix_info_sid_size` function explicitly checks `beg + total > end` (line 5465), where `total` becomes `sid_len`. This ensures that the calculated `sid_len` bytes can be safely read from `sid` without exceeding `end`. The `end` pointer itself is validated by `smb2_parse_contexts` (lines 2477-2479) to be within the `cc_len` buffer. The SMT result indicates `sid_len` is non-negative, which is a necessary but not sufficient condition. The destination buffer `posix->owner` (which is `char owner_sid[MAX_SID_SIZE]`) is known to be large enough (MAX_SID_SIZE is 68, max SID length is 68) for any valid `sid_len`. Therefore, both source and destination bounds are sufficiently checked. Counterexample Test: If `dlen` is 15, `beg + 12` is `sid`. `end` is `beg + 15`. `posix_info_sid_size` (with `beg`=sid, `end`=beg+15) checks `sid + 2 > beg + 15` (false, good) and `sid + total > beg + 15`. If `total` (derived from `*(u8 *)(sid+1)`) was, for example, 12, then `sid + 12 > beg + 15` would be true (`beg+24 > beg+15`), causing `posix_info_sid_size` to return -1. This is caught by `if (sid_len < 0)` at line 2415, preventing the `memcpy` from an undersized buffer. If `total` was, for example, 3, it would pass. The maximum valid `sid_len` of 68 bytes (when SubAuthorityCount is 15) fits into `posix->owner_sid[68]` without overflow.


#### Finding #2 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 2399 |
| Taint snippet | `u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset);` |
| Tainted var | `sid` |
| Sink | `memcpy()` line 2419 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&posix->owner, sid, sid_len);` |
| Possibly guarded | no |

*Dismissed:* The `sid` pointer is derived from `beg` (`(u8 *)cc + le16_to_cpu(cc->DataOffset)`) plus a constant offset of 12. The `beg` pointer itself is validated by the caller `smb2_parse_contexts` to be within the bounds of the received `rsp_iov` buffer. The `dlen` value (from `cc->DataLength`) is checked at line 2406: `if (dlen < 3 * sizeof(__le32))` (i.e., `dlen < 12`) returns early. This guarantees that `dlen` is at least 12, meaning `end` (`beg + dlen`) is at least `beg + 12`. Consequently, `sid` (`beg + 12`) is always a valid pointer within the `[beg, end)` range. The subsequent `memcpy` operation uses `sid` as the source pointer, and `sid_len` (validated as per finding #1) to ensure the read does not exceed `end`. Counterexample Test: If `cc->DataOffset` leads to `beg` being `rsp_iov->iov_base + X`, and `cc->DataLength` is 10. The `if (dlen < 3 * sizeof(__le32))` condition (`10 < 12`) would be true, and the function would return early before `sid` is even calculated, let alone used for `memcpy`. Thus, `sid` is always guaranteed to be within `[beg, end)` when it's used.



### <a name="parse-query-id-ctxt--fs-smb-client-smb2pdu-c"></a>parse_query_id_ctxt() — `fs/smb/client/smb2pdu.c`

**Assessment:** FP  |  **Confidence:** high

> The function `parse_query_id_ctxt` is a static helper function called exclusively by `smb2_parse_contexts`. The caller performs comprehensive bounds checking on the `DataOffset` (`doff`) and `DataLength` (`dlen`) fields of the `create_context` struct against the overall length of the context block (`cc_len`). Specifically, the caller ensures `doff >= sizeof(*cc)` (lower bound) and `doff + dlen <= cc_len` (upper bound for the data payload). The callee `parse_query_id_ctxt` further checks `dlen >= sizeof(__le64)`, which is the size of the data it intends to copy. Combining these, if `dlen >= sizeof(__le64)` and `doff + dlen <= cc_len`, it necessarily follows that `doff + sizeof(__le64) <= cc_len`. This guarantees that the `memcpy` operation, which reads `sizeof(__le64)` bytes from `cc + doff`, will not read out of bounds of the `cc` block.

#### Finding #1 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 2382 |
| Taint snippet | `u16 doff = le16_to_cpu(cc->DataOffset);` |
| Tainted var | `beg` |
| Sink | `memcpy()` line 2390 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&buf->IndexNumber, beg, sizeof(__le64));` |
| Possibly guarded | no |

*Dismissed:* The `doff` (DataOffset) is derived from `cc->DataOffset` which is part of a server-supplied `create_context` struct. This makes `doff` server-supplied. The `beg` pointer is calculated as `(u8 *)cc + doff`. The `memcpy` sink reads `sizeof(__le64)` bytes from `beg`. 

Validation in `parse_query_id_ctxt`:
- Line 2386: `if (dlen < sizeof(__le64)) return;` This ensures the reported `DataLength` is at least as large as the data being copied (8 bytes). This is an important part of the overall check.

Validation in `smb2_parse_contexts` (caller):
- Lines 2475-2479 perform critical validation for `doff` and `dlen`:
    - `doff = le16_to_cpu(cc->DataOffset);`
    - `dlen = le32_to_cpu(cc->DataLength);`
    - `if (doff < sizeof(*cc) || check_add_overflow(doff, dlen, &len) || len > cc_len)`
        - `doff < sizeof(*cc)`: This is a lower-bound check, ensuring `doff` points beyond the fixed header of the `create_context` struct.
        - `check_add_overflow(doff, dlen, &len)`: Guards against integer overflow when adding `doff` and `dlen`.
        - `len > cc_len`: `len` is `doff + dlen`. This is the crucial upper-bound check, ensuring that the entire data payload described by `doff` and `dlen` fits within the current `create_context` block (`cc_len`).

Combined sufficiency:
Given `dlen >= sizeof(__le64)` (from callee) and `doff + dlen <= cc_len` (from caller), we can infer that `doff + sizeof(__le64) <= doff + dlen <= cc_len`. This mathematically guarantees that the memory access `(u8 *)cc + doff` for `sizeof(__le64)` bytes will not exceed the `cc_len` boundary. The `memcpy` is therefore safe.

Counterexample Test:
- Let `sizeof(*cc)` be 8 bytes (hypothetical, actual value might differ but principle holds). Let `sizeof(__le64)` be 8 bytes.
- Assume `cc_len = 24` bytes (a context block of 24 bytes).
- Assume server provides `cc->DataOffset = 8` and `cc->DataLength = 8`.
- Caller checks (smb2_parse_contexts):
    - `doff = 8`, `dlen = 8`.
    - `doff < sizeof(*cc)` (i.e., `8 < 8`) is false. Valid.
    - `check_add_overflow(8, 8, &len)` sets `len = 16`. No overflow. Valid.
    - `len > cc_len` (i.e., `16 > 24`) is false. Valid. The data payload `doff + dlen` (16 bytes) fits within `cc_len` (24 bytes).
- Callee checks (parse_query_id_ctxt):
    - `dlen < sizeof(__le64)` (i.e., `8 < 8`) is false. Valid. The reported data length is sufficient.
- Sink: `beg = (u8 *)cc + 8`. `memcpy(&buf->IndexNumber, beg, 8)`. This reads from `cc + 8` to `cc + 8 + 8 - 1 = cc + 15`. This range is within `cc + 24`. No OOB read occurs.



### <a name="posix-info-parse--fs-smb-client-smb2pdu-c"></a>posix_info_parse() — `fs/smb/client/smb2pdu.c`

**Assessment:** BUG  |  **Confidence:** high

> The primary issue in `posix_info_parse` is twofold:

1.  **Tainted Trust Boundary for `end`**: If the `end` parameter is initially `NULL`, the function calculates `end` using `le32_to_cpu(p->NextEntryOffset)`. `p->NextEntryOffset` is a server-supplied value (`p` is `beg`, the input buffer). This `NextEntryOffset` is *not* validated against the actual received buffer length that `beg` points to. This means the `end` pointer can be maliciously set by the server to point far beyond the true buffer boundary (rule #9). Consequently, all subsequent `beg + X > end` checks in `posix_info_parse` and its callees (`posix_info_sid_size`) become ineffective at preventing OOB reads from the source buffer.

2.  **Undersized Destination Buffers**: The `out->owner` and `out->group` fields are `struct smb_sid`. The `owner_len` and `group_len` values, derived from server-supplied data, can be up to 68 bytes (`1 + 1 + 6 + 4*15`). A standard `struct smb_sid` (with `u32 SubAuth[1]`) is typically 12 bytes (`8 + 4`). Copying up to 68 bytes into a 12-byte buffer constitutes a guaranteed buffer overflow, regardless of the validity of the `end` pointer. This leads to OOB writes into the `out` structure.

#### Finding #1 — Category B — **BUG** (oob_write)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le32_to_cpu()` line 5486 |
| Taint snippet | `end = beg + le32_to_cpu(p->NextEntryOffset);` |
| Tainted var | `owner_len` |
| Sink | `memcpy()` line 5530 (arg 2, role=size) |
| Sink snippet | `memcpy(&out->owner, owner_sid, owner_len);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (stack corruption if `out` is stack-allocated, heap corruption if `out` is heap-allocated)

**Fix:** 1. The caller of `posix_info_parse` must always provide a validated `end` pointer that precisely defines the actual received buffer length. Remove the `if (!end)` block from `posix_info_parse` or robustly validate `p->NextEntryOffset` against the *actual* buffer size if `end` must be derived internally. 2. The `struct smb2_posix_info_parsed` should be redesigned to either dynamically allocate space for SIDs based on their validated length, store pointers and lengths, or embed fixed-size arrays large enough to accommodate the maximum possible SID size (e.g., `u8 owner[SMB_MAX_SID_SIZE];` where `SMB_MAX_SID_SIZE` is at least 68).

**CVE pattern:** SMB response parsing OOB write


#### Finding #2 — Category B — **BUG** (oob_write)

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | `le32_to_cpu()` line 5486 |
| Taint snippet | `end = beg + le32_to_cpu(p->NextEntryOffset);` |
| Tainted var | `group_len` |
| Sink | `memcpy()` line 5531 (arg 2, role=size) |
| Sink snippet | `memcpy(&out->group, group_sid, group_len);` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (stack corruption if `out` is stack-allocated, heap corruption if `out` is heap-allocated)

**Fix:** Same as Finding #1.

**CVE pattern:** SMB response parsing OOB write


#### Finding #3 — Category A — **BUG** (oob_read)

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le32_to_cpu()` line 5486 |
| Taint snippet | `end = beg + le32_to_cpu(p->NextEntryOffset);` |
| Tainted var | `group_sid` |
| Sink | `memcpy()` line 5531 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&out->group, group_sid, group_len);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic (page fault, general protection fault) due to reading from an invalid memory address.

**Fix:** Same as Finding #1. The primary issue is the unvalidated `NextEntryOffset` when `end` is `NULL`, leading to a tainted trust boundary.

**CVE pattern:** SMB response parsing OOB read



### <a name="query-info--fs-smb-client-smb2pdu-c"></a>query_info() — `fs/smb/client/smb2pdu.c`

**Assessment:** FP  |  **Confidence:** high

> The `smb2_validate_and_copy_iov` function acts as a wrapper that calls `smb2_validate_iov` for actual bounds checking before performing a `memcpy`. The `memcpy` at smb2pdu.c:3900 is guarded by the preceding call to `smb2_validate_iov` (smb2pdu.c:3896). Although the source code for `smb2_validate_iov` is not provided, its name and typical kernel design patterns strongly indicate that it performs the necessary bounds checks to ensure that the `offset` and `minbufsize` are within the `iov` buffer's limits. The prompt guidance states that functions named `validate_*` are likely validators, and findings about accesses after their successful return are typically false positives.

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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 4043 |
| Taint snippet | `rc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),` |
| Tainted var | `le16_to_cpu(rsp->OutputBufferOffset)` |
| Call site | line 4043 — passes `le16_to_cpu(rsp->OutputBufferOffset)` to `smb2_validate_and_copy_iov()` |
| Call snippet | `rc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),` |
| Sink (in callee) | `memcpy()` line 3900 (arg 1, role=pointer) |
| Sink snippet | `memcpy(data, begin_of_buf, minbufsize);` |
| Possibly guarded | no |

*Dismissed:* The tainted `OutputBufferOffset` is passed to `smb2_validate_and_copy_iov` as `offset`. Inside this function, `smb2_validate_iov(offset, buffer_length, iov, minbufsize)` is called. The `memcpy` sink occurs only if `smb2_validate_iov` returns successfully (rc == 0). The `smb2_validate_iov` function is designed to validate that `offset + minbufsize` does not exceed `iov->iov_len`. For example, if `iov->iov_len = 100`, `offset = 90`, and `minbufsize = 20`, the required check is `90 + 20 <= 100`, which is `110 <= 100`. This condition should evaluate to false, causing `smb2_validate_iov` to return an error, thereby preventing the `memcpy` and any OOB access. Without the explicit source for `smb2_validate_iov`, we rely on the strong implication from its name and the surrounding code structure that it correctly performs this validation. Thus, the `memcpy` is sufficiently guarded.



### <a name="smb2-parse-contexts--fs-smb-client-smb2pdu-c"></a>smb2_parse_contexts() — `fs/smb/client/smb2pdu.c`

**Assessment:** FP  |  **Confidence:** high

> The `smb2_parse_contexts` function implements a robust series of nested bounds checks for parsing the create contexts. The overall contexts block (`CreateContextsOffset`, `CreateContextsLength`) is validated against the received buffer length. Then, for each individual create context, its length (derived from `cc->Next` or the remaining buffer) is validated. Finally, the internal offsets and lengths (`DataOffset`, `DataLength`, `NameOffset`, `NameLength`) are validated against the current context's determined length. These combined checks ensure that all pointer derivations and memory operations are within bounds.

#### Finding #1 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le32_to_cpu()` line 2456 |
| Taint snippet | `rem = le32_to_cpu(rsp->CreateContextsLength);` |
| Tainted var | `rem` |
| Loop | `while_loop` line 2465 |
| Sink snippet | `while (rem >= sizeof(*cc)) {` |
| Possibly guarded | no |

*Dismissed:* The `rem` variable, representing the remaining length of create contexts, is server-supplied. However, it is adequately validated. Firstly, the initial `rsp->CreateContextsOffset` (`off`) and `rsp->CreateContextsLength` (`rem`) are validated together at line 2457 (`len > rsp_iov->iov_len`) to ensure the entire block fits within the received buffer. Inside the loop, the `cc->Next` field (which becomes `off` in the inner scope and then `cc_len` for the current context's length) is validated at line 2468 with `off >= rem || off < sizeof(*cc)`. This check ensures that the next context does not extend beyond the current `rem` boundary and does not start too early. The `rem` variable is then correctly decremented by this validated `off` (or `cc_len`) at line 2516-2517. The loop guard `rem >= sizeof(*cc)` ensures there is always enough space for the `create_context` header before attempting to read its fields. These combined checks prevent OOB access and ensure the loop iteration count respects buffer boundaries. Counterexample tests with various values for `rsp_iov->iov_len`, `CreateContextsOffset`, `CreateContextsLength`, and `cc->Next` confirmed that the existing checks catch any out-of-bounds conditions or invalid length scenarios. For example, if `cc->Next` is larger than `rem`, it is caught by `off >= rem` at line 2468.


#### Finding #2 — Category E — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 2455 |
| Taint snippet | `off = le32_to_cpu(rsp->CreateContextsOffset);` |
| Tainted var | `cc` |
| Pointer deref | `cc->Next` line 2466 |
| Sink snippet | `off = le32_to_cpu(cc->Next);` |
| Possibly guarded | no |

*Dismissed:* The pointer `cc` is derived from a server-supplied offset (`rsp->CreateContextsOffset`). However, its dereferences are protected by several checks. The initial validation at line 2457 (`len > rsp_iov->iov_len`) ensures that the entire create contexts block (from `rsp + CreateContextsOffset` to `rsp + CreateContextsOffset + CreateContextsLength`) fits within the `rsp_iov` buffer. The loop condition `while (rem >= sizeof(*cc))` guarantees that for every iteration where `cc` is dereferenced, at least `sizeof(*cc)` bytes are available at the `cc` pointer. When `cc` is advanced by `off = le32_to_cpu(cc->Next)` (line 2518), this `off` value has been validated at line 2468 (`if ((off & 0x7) || off >= rem || off < sizeof(*cc))`). Specifically, `off >= rem` prevents `cc->Next` from indicating an offset that would take the *next* context beyond the remaining buffer, and `off < sizeof(*cc)` prevents invalid overlaps. These combined checks ensure that `cc` always points within valid bounds before any of its fields are accessed. Counterexample tests, including small `rem` values or `cc->Next` pointing OOB, confirm the `EINVAL` returns. For instance, if `rsp->CreateContextsOffset` + `sizeof(*cc)` were to exceed `rsp_iov->iov_len`, the initial check at line 2457 would catch it immediately. If `cc->Next` indicated an OOB jump for the next context, it would be caught by `off >= rem` at line 2468.


#### Finding #3 — Category A — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le32_to_cpu()` line 2455 |
| Taint snippet | `off = le32_to_cpu(rsp->CreateContextsOffset);` |
| Tainted var | `name` |
| Sink | `memcmp()` line 2500 (arg 0, role=pointer) |
| Sink snippet | `if (dlen && posix && !memcmp(name, smb3_create_tag_posix, 16))` |
| Possibly guarded | no |

*Dismissed:* The pointer `name` is derived from `cc` (which is tainted) and `cc->NameOffset` (`noff`). The `memcmp` operation uses `name` with a length of `16` (from `nlen`). Crucially, before `name` is used, its boundaries are validated at line 2483: `if (noff < sizeof(*cc) || check_add_overflow(noff, nlen, &len) || len > cc_len || (dlen && len > doff))`. This validation ensures that `noff` is not less than the header size, and more importantly, that `noff + nlen` (the end of the name buffer) does not exceed `cc_len` (the length of the current create context). Since `nlen` is 16 for this specific case, the check `noff + 16 <= cc_len` is performed. As `cc_len` itself has been validated against `rem`, and `rem` against `rsp_iov->iov_len`, the `name` pointer of length 16 is guaranteed to be within the overall response buffer. Counterexample test: if `cc->NameOffset = 20`, `cc->NameLength = 16`, and `cc_len = 32`, then `noff + nlen = 36`, which is `> cc_len`. This would trigger `len > cc_len` at line 2483 and return `-EINVAL`, preventing the `memcmp` call.


#### Finding #4 — Category A — cross-function via `parse_query_id_ctxt()` — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le32_to_cpu()` line 2455 |
| Taint snippet | `off = le32_to_cpu(rsp->CreateContextsOffset);` |
| Tainted var | `cc` |
| Call site | line 2496 — passes `cc` to `parse_query_id_ctxt()` |
| Call snippet | `parse_query_id_ctxt(cc, buf);` |
| Sink (in callee) | `memcpy()` line 2390 (arg 1, role=pointer) |
| Sink snippet | `memcpy(&buf->IndexNumber, beg, sizeof(__le64));` |
| Possibly guarded | no |

*Dismissed:* The pointer `cc` is passed to `parse_query_id_ctxt()` where a `memcpy` operation (`memcpy(&buf->IndexNumber, beg, sizeof(__le64));`) uses a derived pointer `beg = (u8 *)cc + doff;`. Both `cc` and `doff` (`cc->DataOffset`) are server-supplied. However, `smb2_parse_contexts()` performs pre-call validation for `doff` and `dlen` (`cc->DataLength`) at line 2477: `if (doff < sizeof(*cc) || check_add_overflow(doff, dlen, &len) || len > cc_len)`. This check ensures that the entire data region (`cc + doff` to `cc + doff + dlen`) fits within the current context's length (`cc_len`). `cc_len` itself is bounded by `rem`, which is bounded by `rsp_iov->iov_len`. Additionally, `parse_query_id_ctxt()` performs an internal check at line 2386: `if (dlen < sizeof(__le64)) return;`. This ensures that the `DataLength` is sufficient for a `sizeof(__le64)` read. Combining these, the `memcpy` is safe: `doff + sizeof(__le64)` must be less than or equal to `doff + dlen`, and `doff + dlen` is guaranteed to be within `cc_len`. Counterexample test: if `dlen` is less than `sizeof(__le64)` (e.g., 4 bytes), the check at 2386 would cause an early return, preventing the `memcpy`. If `doff + dlen` were to exceed `cc_len`, the check at 2477 would trigger `-EINVAL` before the call to `parse_query_id_ctxt()` even happens.



### <a name="smb311-decode-neg-context--fs-smb-client-smb2pdu-c"></a>smb311_decode_neg_context() — `fs/smb/client/smb2pdu.c`

**Assessment:** MIXED  |  **Confidence:** high

> The function processes negotiate contexts based on server-supplied offsets and counts. Overall, the function has several checks against `len_of_smb` (the validated total length of the SMB message) to prevent out-of-bounds reads when advancing pointers and calculating total context sizes. However, a crucial check regarding the relative placement of `NegotiateContextOffset` with respect to the security buffer is missing, leading to potential type confusion and misinterpretation of data.

#### Finding #1 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 976 |
| Taint snippet | `unsigned int ctxt_cnt = le16_to_cpu(rsp->NegotiateContextCount);` |
| Tainted var | `ctxt_cnt` |
| Loop | `for_loop` line 988 |
| Sink snippet | `for (i = 0; i < ctxt_cnt; i++) {` |
| Possibly guarded | no |

*Dismissed:* The `ctxt_cnt` (NegotiateContextCount) is server-supplied. While it controls the loop iteration count, the loop body contains sufficient per-iteration bounds checks that prevent out-of-bounds memory access. Specifically, `if (len_of_ctxts < sizeof(struct smb2_neg_context))` at line 991 ensures that at least the header of the current context fits into the remaining buffer. This allows safe dereference of `pctx->DataLength` (from which `clen` is derived). Subsequently, `if (clen > len_of_ctxts)` at line 1004 ensures that the entire calculated context size (`clen`, including header and data) fits in the remaining buffer before `offset` and `len_of_ctxts` are updated. If `ctxt_cnt` is excessively large, the loop will break early when `len_of_ctxts` is exhausted. Counterexample test: assume `len_of_smb=100`, `offset=50`, `ctxt_cnt=100`. Then `len_of_ctxts` initially is 50. In the first iteration, `pctx` is computed. If `pctx->DataLength` (a server-supplied value, potentially malicious) causes `clen` to be > 50, the loop breaks at line 1004. This prevents any OOB access or consumption of more bytes than available. Thus, the iteration count being unvalidated does not lead to a real bug due to the robust per-iteration checks.


#### Finding #2 — Category E — **BUG** (protocol_confusion)

| Field | Value |
|---|---|
| Category | Cat E — tainted pointer dereference (->field access beyond packet bounds) |
| Taint source | `le32_to_cpu()` line 975 |
| Taint snippet | `unsigned int offset = le32_to_cpu(rsp->NegotiateContextOffset);` |
| Tainted var | `pctx` |
| Pointer deref | `pctx->DataLength` line 996 |
| Sink snippet | `+ le16_to_cpu(pctx->DataLength);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or unexpected behavior in `decode_*_context` functions due to misinterpretation of data; potential information disclosure if security blob contents are processed as sensitive context data.

**Fix:** The caller function `SMB2_negotiate` uses `smb2_validate_negotiate_resp` to validate fields before calling `smb311_decode_neg_context`. This validator already ensures that `le32_to_cpu(rsp->NegotiateContextOffset)` is within `[SMB2_NEG_RESP_SIZE, total_len)`. However, it does not check that the negotiate contexts (starting at `NegotiateContextOffset`) do not overlap with the variable-length security blob (defined by `SecurityBufferOffset` and `SecurityBufferLength`). To fix this, in `smb2_validate_negotiate_resp`, add a check similar to: `if (le32_to_cpu(rsp->NegotiateContextOffset) < le32_to_cpu(rsp->SecurityBufferOffset) + le32_to_cpu(rsp->SecurityBufferLength)) return -EINVAL;`. This ensures that contexts are placed strictly after the security blob.

**CVE pattern:** SMB negotiation response offset validation bug, leading to type confusion/misinterpretation.



### <a name="smb2-calc-signature--fs-smb-client-smb2transport-c"></a>smb2_calc_signature() — `fs/smb/client/smb2transport.c`

**Assessment:** FP  |  **Confidence:** high

> The static analysis finding for 'smb2_calc_signature' incorrectly identifies a truncation. The variable 'rc' is assigned the integer return value of 'smb2_get_sign_key', not the 64-bit 'sid' value. The 'sid' value itself is passed as a 64-bit argument to 'smb2_get_sign_key' without truncation. This is a common misinterpretation by static analyzers when a larger-width variable is passed as an argument to a function whose return value (which might be smaller) is assigned to another variable.

#### Finding #1 — Category H — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le64_to_cpu()` line 220 |
| Taint snippet | `rc = smb2_get_sign_key(server, sid, key);` |
| Tainted var | `rc` |
| Truncation | line 220: 64-bit → 32-bit `u32` |
| Sink snippet | `rc = smb2_get_sign_key(server, sid, key);` |
| Possibly guarded | no |

*Dismissed:* The scanner incorrectly interprets the line `rc = smb2_get_sign_key(server, sid, key);`. It states that the 64-bit 'sid' is truncated to the 32-bit 'rc'. However, 'rc' is assigned the *return value* of `smb2_get_sign_key`, which is an `int` (typically 32-bit on Linux). The 64-bit 'sid' is passed as an argument to `smb2_get_sign_key` (as `const __u64 ses_id`), where it maintains its 64-bit width. There is no truncation of the server-supplied `sid` into `rc`. The variable `rc` is correctly used to store an error code. Thus, the premise of the finding (truncation of `sid` into `rc`) is false.



### <a name="smb2-seq-num-into-buf--fs-smb-client-smb2transport-c"></a>smb2_seq_num_into_buf() — `fs/smb/client/smb2transport.c`

**Assessment:** FP  |  **Confidence:** high

> The function `smb2_seq_num_into_buf` is called during the construction of SMB2 client requests (`smb2_setup_request`, `smb2_setup_async_request`). The `shdr` parameter points to a buffer that the kernel is populating with a request to send to the server, not a buffer received from the server. Therefore, `shdr->CreditCharge` is a value previously written by the kernel into the request buffer (e.g., using `cpu_to_le16`) and is not server-supplied. The `le16_to_cpu()` call here is part of the client's internal request preparation logic, not parsing server-provided data. The loop also does not perform any memory access based on `num`, only calls a counter function `get_next_mid`.

#### Finding #1 — Category F — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le16_to_cpu()` line 606 |
| Taint snippet | `unsigned int i, num = le16_to_cpu(shdr->CreditCharge);` |
| Tainted var | `num` |
| Loop | `for_loop` line 610 |
| Sink snippet | `for (i = 1; i < num; i++)` |
| Possibly guarded | no |

*Dismissed:* The `shdr` parameter refers to a `smb2_hdr` structure within a `smb_rqst` buffer, which is a request being *built by the kernel* to be sent to the server. The `CreditCharge` field in a request header is a value set by the client (kernel) to indicate credit consumption. Thus, `le16_to_cpu(shdr->CreditCharge)` is reading a value that the kernel itself wrote, not a server-supplied value. Therefore, the taint source is not genuinely server-supplied. Additionally, the loop body `get_next_mid(server)` does not perform any memory access that is bounded or indexed by `num`, so even if `num` were server-supplied and large, it would not lead to an out-of-bounds memory access within this function, though it could lead to excessive CPU consumption.



### <a name="smb3-calc-signature--fs-smb-client-smb2transport-c"></a>smb3_calc_signature() — `fs/smb/client/smb2transport.c`

**Assessment:** FP  |  **Confidence:** high

> The scanner incorrectly identified `rc` as the variable being truncated. The `le64_to_cpu(shdr->SessionId)` (a `u64`) is passed as an argument to `smb3_get_sign_key`. The `rc` variable is assigned the *return value* of `smb3_get_sign_key`, which is an `int`. There is no implicit truncation of a `u64` to `rc` as described by the scanner.

#### Finding #1 — Category H — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le64_to_cpu()` line 478 |
| Taint snippet | `rc = smb3_get_sign_key(le64_to_cpu(shdr->SessionId), server, key);` |
| Tainted var | `rc` |
| Truncation | line 478: 64-bit → 32-bit `u32` |
| Sink snippet | `rc = smb3_get_sign_key(le64_to_cpu(shdr->SessionId), server, key);` |
| Possibly guarded | no |

*Dismissed:* The scanner's description of the truncation is flawed. The `le64_to_cpu(shdr->SessionId)` expression results in a `u64` value. This `u64` is passed as the `session_id` argument (which is of type `u64`) to the `smb3_get_sign_key` function. The `rc` variable is declared as an `int` and receives the `int` return value from `smb3_get_sign_key`. No 64-bit to 32-bit truncation occurs on `rc` itself in this assignment.



### <a name="release-mid--fs-smb-client-transport-c"></a>__release_mid() — `fs/smb/client/transport.c`

**Assessment:** FP  |  **Confidence:** high

> The function `__release_mid` processes a `mid_q_entry` structure which contains server-supplied data. The `command` field from this structure is used as an index into several statistics arrays. The code explicitly checks the `smb_cmd` value against `NUMBER_OF_SMB2_COMMANDS` before using it as an array index, which prevents out-of-bounds access.

#### Finding #1 — Category C — ~~false positive~~

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 45 |
| Taint snippet | `__u16 smb_cmd = le16_to_cpu(midEntry->command);` |
| Tainted var | `smb_cmd` |
| Subscript | `[]` line 69 |
| Sink snippet | `if (atomic_read(&server->num_cmds[smb_cmd]) == 0) {` |
| Possibly guarded | yes (heuristic) |
| SMT | **proved** `negative`: signed value cannot be negative where it reaches the sink *(proof covers every unresolved value; it answers only this property)* |

*Dismissed:* The `midEntry->command` field is part of a `mid_q_entry` structure, which typically holds information from a server response, making `smb_cmd` server-supplied. The `smb_cmd` value, after `le16_to_cpu`, is an unsigned 16-bit integer, so it cannot be negative. It is used as an array subscript for `server->num_cmds`, `server->slowest_cmd`, `server->fastest_cmd`, `server->time_per_cmd`, and `server->smb2slowcmd`. All these uses are immediately preceded by an explicit bounds check: `if (smb_cmd < NUMBER_OF_SMB2_COMMANDS)`. This check correctly ensures that `smb_cmd` is within the valid index range [0, NUMBER_OF_SMB2_COMMANDS - 1].

Counterexample test:
- If `midEntry->command` is `0x0000` (meaning `smb_cmd = 0`): `0 < NUMBER_OF_SMB2_COMMANDS` is true (assuming `NUMBER_OF_SMB2_COMMANDS > 0`). Accesses like `server->num_cmds[0]` are in bounds.
- If `midEntry->command` is `0xFFFF` (meaning `smb_cmd = 65535`): `65535 < NUMBER_OF_SMB2_COMMANDS` is false (as `NUMBER_OF_SMB2_COMMANDS` would be much smaller, e.g., ~100). The `if` condition at line 68 and line 98 would prevent the out-of-bounds access to the arrays. The `smb_cmd` variable is not reassigned between the guard and the sink.

The check is sufficient to prevent OOB access.


