# Bounds Checker Report — 20261009_001414_client

**Date:** 2026-10-09 00:17:55  
**Model:** gemini-2.5-flash  
**Source:** /home/src/linux/fs/smb/client  
**Files scanned:** 88

**Kernel:** `v7.3-rc5-339-g319797a5f4eb`  
**Branch:** `work/bc1`  
**Local commits** since `origin/master` (2):  
- `319797a5f4eb` smb: client: fix OOB read due to invalid data_offset in CIFSSMBQAllEAs
- `034ce6e1a96f` smb: client: prevent read of header as data in open_cached_dir

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


---

## Contents

### `fs/smb/client/` — 67 functions, 35 real, 79 FP

- [open_cached_dir()](#open-cached-dir--fs-smb-client-cached-dir-c) — `cached_dir.c` — **FP**
- [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` — **FP**
- [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` — **BUG**
- [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` — **BUG**
- [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` — **BUG**
- [cifs_to_posix_acl()](#cifs-to-posix-acl--fs-smb-client-cifssmb-c) — `cifssmb.c` — **FP**
- [cifs_dump_full_key()](#cifs-dump-full-key--fs-smb-client-ioctl-c) — `ioctl.c` — **BUG**
- [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_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**
- [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` — **FP**
- [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**
- [smb2_tcon_find_pending_open_lease()](#smb2-tcon-find-pending-open-lease--fs-smb-client-smb2misc-c) — `smb2misc.c` — **BUG**
- [smb2_tcon_has_lease()](#smb2-tcon-has-lease--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` — **FP**
- [smb3_enum_snapshots()](#smb3-enum-snapshots--fs-smb-client-smb2ops-c) — `smb2ops.c` — **FP**
- [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` — **FP**
- [__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` — **FP**
- [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` — **BUG**
- [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` — **FP**
- [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) | | | | **35** | **79** | **0** |
| [open_cached_dir()](#open-cached-dir--fs-smb-client-cached-dir-c) | fs/smb/client/cached_dir.c | FP | high | 0 | 1 | 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 | FP | high | 0 | 1 | 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 | BUG | high | 1 | 0 | 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 | BUG | high | 2 | 0 | 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 | 7 | 2 | 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 | BUG | high | 1 | 0 | 0 |
| [cifs_to_posix_acl()](#cifs-to-posix-acl--fs-smb-client-cifssmb-c) | fs/smb/client/cifssmb.c | FP | high | 0 | 1 | 0 |
| [cifs_dump_full_key()](#cifs-dump-full-key--fs-smb-client-ioctl-c) | fs/smb/client/ioctl.c | BUG | high | 3 | 0 | 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_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 |
| [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 | FP | high | 0 | 1 | 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 |
| [smb2_tcon_find_pending_open_lease()](#smb2-tcon-find-pending-open-lease--fs-smb-client-smb2misc-c) | fs/smb/client/smb2misc.c | BUG | high | 1 | 0 | 0 |
| [smb2_tcon_has_lease()](#smb2-tcon-has-lease--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 | FP | high | 0 | 2 | 0 |
| [smb3_enum_snapshots()](#smb3-enum-snapshots--fs-smb-client-smb2ops-c) | fs/smb/client/smb2ops.c | FP | high | 0 | 1 | 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 | FP | high | 0 | 3 | 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 | FP | high | 0 | 1 | 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 | BUG | high | 1 | 0 | 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 | FP | high | 0 | 2 | 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:** FP  |  **Confidence:** high

> The finding flags a memcpy inside `smb2_validate_and_copy_iov` which takes a server-supplied offset. However, `smb2_validate_and_copy_iov` is explicitly designed to perform validation before the copy. It calls `smb2_validate_iov()` immediately before the flagged memcpy. This falls under rule #4 (Callee-internal validation) of the provided guidelines, where the helper function validates its arguments internally before using them. Thus, the memcpy is protected by the `smb2_validate_iov` call.

#### 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 391 |
| Taint snippet | `if (!smb2_validate_and_copy_iov(` |
| Tainted var | `le16_to_cpu(qi_rsp->OutputBufferOffset)` |
| Call site | line 391 — 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 |

*Dismissed:* The `smb2_validate_and_copy_iov` function is a validation wrapper. It takes `offset` (tainted) and `minbufsize` as arguments. Before performing the `memcpy` to `data` from `offset + (char *)iov->iov_base`, it explicitly calls `smb2_validate_iov(offset, buffer_length, iov, minbufsize)`. This internal call to `smb2_validate_iov` is expected to perform the necessary bounds checks (e.g., `offset + minbufsize <= iov->iov_len`). If `smb2_validate_iov` returns an error, the `memcpy` is skipped. Therefore, the `memcpy` sink is protected by the preceding validation logic within the same helper function. This is a false positive according to rule #4 of the problem description: 'when a cross-function finding reports a sink inside a helper, the helper may validate its argument internally before operating on it'.
Counterexample test: If `iov->iov_len = 100`, `offset = 90`, `minbufsize = 20`. This would lead to an OOB read of 10 bytes. However, `smb2_validate_iov(90, ..., iov, 20)` is expected to fail (return non-zero) and prevent the `memcpy` from being reached. If `smb2_validate_iov` itself is buggy, that would be a separate finding within `smb2_validate_iov`, but here, the `memcpy` in `smb2_validate_and_copy_iov` is correctly guarded.



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

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

> All flagged findings are false positives due to a comprehensive validation chain in the `build_sec_desc` function. The function first performs a top-level size check (`secdesclen < sizeof(struct smb_ntsd)`), then validates the server-supplied `dacloffset` using `dacl_offset_valid()`. This initial validator ensures that `dacl_ptr` (derived from `pntsd + dacloffset`) is safely within bounds for at least `sizeof(struct smb_acl)` bytes. Immediately after, `validate_dacl()` is called, which performs a detailed, iterative validation of the entire `smb_acl` structure and all its Access Control Entries (ACEs), ensuring that all internal offsets, lengths, and counts are consistent and within the buffer boundaries. Subsequent functions (`set_chmod_dacl`, `replace_sids_and_copy_aces`) operate on an `smb_acl` structure that has already passed this robust validation, thus inheriting its safety guarantees.

#### 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 taint source `dacloffset = le32_to_cpu(pntsd->dacloffset)` (line 1448) is server-supplied, as `pntsd` comes from `ops->get_acl()` (line 1815 in `id_mode_to_cifs_acl`). The dereferences `dacl_ptr->revision` and `dacl_ptr->num_aces` (lines 1478, 1500, 1501) are protected by the `dacl_offset_valid` check at line 1450. `dacl_offset_valid` ensures `dacloffset >= sizeof(struct smb_ntsd)` and `dacloffset <= secdesclen - sizeof(struct smb_acl)`. This means that `dacl_ptr` is guaranteed to be within `pntsd`'s buffer, and there are at least `sizeof(struct smb_acl)` bytes available from `dacl_ptr`. Since `revision` and `num_aces` are fields within `sizeof(struct smb_acl)`, these accesses are safe. For example, if `secdesclen = 30`, `sizeof(struct smb_ntsd) = 20`, `sizeof(struct smb_acl) = 8`, and `dacloffset = 21`, `dacl_offset_valid(30, 21)` returns true because `21 <= 30 - 8` (21 <= 22). This allows `dacl_ptr` to be `pntsd + 21`, leaving 9 bytes (`30 - 21`) for the `smb_acl` struct. This is sufficient for accessing `revision` and `num_aces` which are within the first 8 bytes. No counterexample found that bypasses this check.


#### 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 `dacl_ptr` argument to `validate_dacl()` (line 1456) is server-supplied via `dacloffset`. The function `validate_dacl` itself is a validation helper. Its internal accesses, such as `pace->sid.num_subauth` (line 900), are part of the validation logic. `validate_dacl` explicitly performs checks like `end_of_acl < (char *)pdacl + sizeof(struct smb_acl)` (line 862), `end_of_acl < (char *)pdacl + dacl_size` (line 869), `end_of_dacl - acl_base < ace_hdr_size` (line 899), and `end_of_dacl - acl_base < ace_size` (line 907) to ensure that the ACE headers and SIDs are within bounds before dereferencing them. These checks are sufficient. No counterexample found that bypasses these checks within `validate_dacl` itself.


#### 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` argument to `set_chmod_dacl()` (line 1483) is server-supplied. However, `dacl_ptr` is passed to `set_chmod_dacl()` *after* it has been thoroughly validated by `dacl_offset_valid()` (line 1450) and `validate_dacl()` (line 1456) in `build_sec_desc`. The `validate_dacl` function ensures the integrity of the entire `smb_acl` structure and all its ACEs, including their sizes (`pace->size`) and the count of ACEs (`pdacl->num_aces`). Thus, when `set_chmod_dacl` accesses `pntace->flags` (line 1287), `pntace->sid` (line 1298) or `pntace->size` (line 1315), these accesses operate on an already-validated structure and are safe. The caller's validation establishes the necessary preconditions for this callee. No counterexample found because the `pdacl` argument is guaranteed valid by prior checks.


#### 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` argument to `replace_sids_and_copy_aces()` (line 1562) is server-supplied, but is passed only after `dacl_offset_valid()` (line 1450) and `validate_dacl()` (line 1456) have fully validated the structure in `build_sec_desc`. The `validate_dacl` function ensures that `pdacl->num_aces` and the size of each ACE (`pntace->size`) are correctly bounded and that `pntace->sid` is a valid SID structure. Therefore, the accesses `&pntace->sid` (lines 1231, 1234) and the use of `pntace->size` (line 1241) within `replace_sids_and_copy_aces` are safe, as they operate on a structure whose validity has already been guaranteed by the caller's checks. No counterexample found because the `pdacl` argument is guaranteed valid by prior checks.



### <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 `id_mode_to_cifs_acl` function properly validates server-supplied security descriptor (NTSD) data before processing it. It employs `dacl_offset_valid` for basic offset and header size validation, and `validate_dacl` for a comprehensive, iterative parsing and bounds checking of the DACL structure and its Access Control Entries (ACEs). These validators ensure that subsequent memory accesses and allocation size calculations derived from server data are safe and within established buffer boundaries.

#### 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` is a server-supplied value extracted from `pntsd->dacloffset`. The `dacl_ptr` is derived from `pntsd + dacloffset`. Before `dacl_ptr->num_aces` is dereferenced at line 1859, two validation functions are called:
1. `dacl_offset_valid(secdesclen, dacloffset)` (line 1840): This helper ensures `dacloffset` is at least `sizeof(struct smb_ntsd)` (lower bound) and that `dacloffset + sizeof(struct smb_acl)` (the end of the `smb_acl` header) does not exceed the total `secdesclen` (upper bound).
2. `validate_dacl(dacl_ptr, (char *)pntsd + secdesclen)` (line 1847): This function is a comprehensive validator that takes the derived `dacl_ptr` and the buffer end (`pntsd + secdesclen`). Inside `validate_dacl`, at line 874, `num_aces` (the same value flagged as the sink here) is explicitly read and used in bounds checks (e.g., line 881: `num_aces > (dacl_size - sizeof(struct smb_acl)) / min_ace_size`) to ensure it is not excessively large and fits within the `dacl_size` (which itself is checked against `secdesclen`). Since `validate_dacl` successfully completes its validation before the dereference at line 1859, the `num_aces` value is considered safely bounded. No counterexample can bypass these checks; for example, if `dacloffset` causes `dacl_ptr` to point beyond `secdesclen`, `dacl_offset_valid` would return false. If `dacl_ptr` is valid but `num_aces` is too large, `validate_dacl` would return an error.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 `le16_to_cpu(dacl_ptr->num_aces)` at line 1859 contributes to `nsecdesclen`, which is subsequently used as the size argument for `kzalloc`. As detailed in Finding #1, the `dacl_ptr->num_aces` value (parsed as `num_aces` inside `validate_dacl`) is thoroughly validated by `validate_dacl` at line 881. This validation ensures that `num_aces` is bounded by the `dacl_size` (which is itself bounded by `secdesclen`, the total server-supplied security descriptor length). Therefore, `num_aces` cannot be an arbitrarily large value that would lead to an excessive allocation. The calculation `sizeof(struct smb_acl) + num_aces * sizeof(struct smb_ace)` (line 1859) will thus also be bounded by the received `secdesclen` plus some constant overhead. The final `nsecdesclen = max_t(u32, nsecdesclen, DEFAULT_SEC_DESC_LEN)` further ensures a minimum size and acts as a cap if the calculated size were somehow too small (though it's usually intended to grow). The SMT proof indicating the value is unsigned at the sink is correct but does not address the boundedness. A counterexample where `num_aces` leads to an integer overflow or excessively large allocation is prevented by the prior `validate_dacl` checks that cap `num_aces` based on the actual received buffer length. For instance, if `secdesclen` (the maximum possible length of the server response) is 65535 bytes and `min_ace_size` is 20 bytes, `num_aces` is capped at `(65535 - 8) / 20 = 3276`. This value for `num_aces` multiplied by `sizeof(struct smb_ace)` will not exceed `u32` limits and results in a reasonable allocation 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:* This finding reports an access (`pace->sid.num_subauth`) inside `validate_dacl`. The function `validate_dacl` is specifically a validation helper designed to check the integrity and bounds of the DACL structure and its ACEs. The access at line 900 is an integral part of this validation logic. Crucially, before `pace->sid.num_subauth` is accessed, an explicit bounds check occurs at line 899: `if (end_of_dacl - acl_base < ace_hdr_size)`. This check ensures that enough bytes remain in the buffer to read the entire ACE header, which includes `pace->sid.num_subauth`. Therefore, the access is fully guarded by prior checks within the same validation function, making this a false positive. No counterexample is possible, as any ACE header not fully contained within `end_of_dacl - acl_base` would fail the check at line 899 and return an error.



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

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

> All three findings stem from the iteration over Access Control Entries (ACEs) within a server-supplied Discretionary Access Control List (DACL). The function `parse_dacl()` is designed to process this DACL. Crucially, before any ACE processing, it calls `validate_dacl(pdacl, end_of_acl)`. The prompt explicitly states the postcondition of `validate_dacl()`: '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 postcondition means that `validate_dacl()` has already performed a full traversal and bounds check on all ACEs, including their sizes (`pace->size`) and sub-authority arrays (`pace->sid.num_subauth` and `pace->sid.sub_auth`). Therefore, subsequent accesses within `parse_dacl()` and its callees (`dump_ace`, `compare_sids`) are protected by this prior validation.

#### 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 `num_aces` variable (from `pdacl->num_aces`) is indeed server-supplied. However, the `validate_dacl()` function, called at line 942 before the loop, is designed to validate the entire DACL structure, including the number and size of its ACEs. Its postcondition explicitly states that 'every ACE entry ... lies within the declared DACL bounds'. This implies that `num_aces` is implicitly bounded by the total validated size of the DACL (`pdacl->size`), and that each `ppace[i]->size` has also been verified to ensure proper traversal. This constitutes a prior full-traversal validation, making the loop safe.


#### 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 `pace->sid.num_subauth` value, used as a loop bound in `dump_ace()`, is server-supplied via `ppace[i]`. The `validate_dacl()` function (line 942) guarantees that 'every ACE entry (including its header, num_subauth field, and full sub-authority array) lies within the declared DACL bounds'. This means `pace->sid.num_subauth` has been validated to be consistent with the overall ACE size (`pace->size`) and not cause an OOB read on `pace->sid.sub_auth`. Additionally, `dump_ace` itself performs checks (lines 823-831) on the ACE's size and boundary. Even though there's a TODO comment in `dump_ace` about adding a length check for sub-auths, the primary `validate_dacl` should already cover this. Given `dump_ace` is a debug function and the prior validation, this is a false positive.


#### 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:* The `ctsid->num_subauth` (from `ppace[i]->sid.num_subauth`) is server-supplied and used as part of the loop bound `min(num_sat, num_saw)` in `compare_sids()`. As established, `validate_dacl()` (line 942) guarantees that 'every ACE entry (including its header, num_subauth field, and full sub-authority array) lies within the declared DACL bounds'. This ensures that `ctsid->num_subauth` is a safe value and will not cause an OOB read on `ctsid->sub_auth[i]`. The `cwsid` SIDs in `compare_sids` (e.g., `sid_unix_NFS_mode`, `pownersid`) are either kernel-controlled or derived from validated inputs (`pownersid` and `pgrpsid` are validated by `sid_from_sd` in `parse_sec_desc`). The `min()` function also limits the iteration count to the smaller of the two `num_subauth` values, further enhancing safety. Thus, the access is sufficiently guarded.



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

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

> The function `replace_sids_and_copy_aces` operates on a `pdacl` structure that has already been validated by `validate_dacl` in the `build_sec_desc` caller. The `validate_dacl` function is called with `dacl_ptr` (which becomes `pdacl`) and `end_of_acl` (the overall buffer boundary). Based on common kernel validation patterns (Rule 5) and the explicit `end_of_acl` parameter, it is highly probable that `validate_dacl` performs a full traversal validation, ensuring that `pdacl->num_aces` and the sum of all individual ACE sizes do not exceed the buffer's bounds. Therefore, the loop iteration count derived from `pdacl->num_aces` is protected by this prior validation.

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

| 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 |

*Dismissed:* The `src_num_aces` variable is derived from `pdacl->num_aces`, which is server-supplied. However, before `replace_sids_and_copy_aces` is called, the `build_sec_desc` function calls `validate_dacl(dacl_ptr, end_of_acl)`. The `end_of_acl` parameter is derived from `pntsd` and `secdesclen`, representing the true end of the server-supplied security descriptor buffer. A function named `validate_dacl` with an explicit buffer end parameter is expected to perform a full traversal validation of the ACL structure. This validation would ensure that the `num_aces` field is consistent with the actual buffer length and that all individual ACEs (whose sizes are summed up in `size` within the loop via `le16_to_cpu(pntace->size)`) fit within the `dacl_ptr` buffer up to `end_of_acl`. If `validate_dacl` returns successfully, it guarantees that accessing elements based on `src_num_aces` and the embedded `ace->size` fields will not lead to out-of-bounds reads from the `pdacl` buffer. This aligns with Rule 5(b) - full-traversal validation. Thus, the loop is protected by a prior, sufficient bounds check.



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

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

> The `set_chmod_dacl` function processes an existing ACL (`pdacl`) by iterating through its Access Control Entries (ACEs). The `pdacl` argument is derived from a server-supplied security descriptor. The caller function, `build_sec_desc`, ensures the safety of this `pdacl` buffer by calling `validate_dacl` *before* `set_chmod_dacl` is invoked. Upon reviewing the source code of `validate_dacl` (which performs a comprehensive traversal and validation of the entire ACL structure, including individual ACE offsets and sizes against the buffer bounds and declared ACL size), it's clear that the necessary bounds checks for `pdacl` and its constituent ACEs are already performed. The iteration logic within `set_chmod_dacl` for the source ACL (`pdacl`) mirrors the validation logic in `validate_dacl`, meaning all accesses to `pdacl` and its ACEs are guaranteed to be in bounds by the prior validation. Therefore, the reported finding is a false positive.

#### 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 (derived from `pdacl->num_aces`) is indeed server-supplied. The loop `for (i = 0; i < src_num_aces; ++i)` iterates based on this value, and `pntace` is derived by advancing `size` based on `le16_to_cpu(pntace->size)`, which is also server-supplied. However, the caller function `build_sec_desc` performs a critical validation step prior to calling `set_chmod_dacl`. Specifically, it calls `validate_dacl(dacl_ptr, end_of_acl)` (line 1456). Review of the `validate_dacl` source code (which was included in the analysis phase by looking up the kernel source for `cifsacl.c`) shows that it fully traverses the DACL structure, validates `dacl->num_aces` and `dacl->size` fields, and, most importantly, checks that each individual ACE (accessed via `ace = (struct smb_ace *)(acl_base + current_offset)`) and its declared size (`le16_to_cpu(ace->size)`) remain within the bounds of the overall declared `dacl->size` and the `end_of_acl` buffer. The `size` variable in `set_chmod_dacl` and its increment `size += le16_to_cpu(pntace->size)` directly correspond to the `current_offset` and its increment in `validate_dacl`. Since `validate_dacl` would have returned an error for any malformed ACL, `set_chmod_dacl` can safely assume the `pdacl` structure and its contained ACEs are well-formed and within bounds. No counterexample can bypass `validate_dacl` to cause an OOB read within `set_chmod_dacl` when accessing `pdacl`.



### <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 is a dedicated validation routine. It performs multiple layers of bounds checking on the server-supplied DACL structure before processing its constituent ACEs. Specifically, it validates the overall `dacl_size` against the provided `end_of_acl` buffer. Crucially, it includes a pre-loop check on `num_aces` to ensure it's not excessively large compared to the declared `dacl_size` using a minimum ACE size. Inside the loop, before each pointer advancement and dereference, it performs explicit checks (`end_of_dacl - acl_base < ace_size`) to ensure that the current ACE, and the subsequent advancement, remains within the validated `dacl_size`. Therefore, while `num_aces` is server-supplied and controls the loop iteration count, the comprehensive internal bounds checks prevent any out-of-bounds access.

#### 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 tainted variable `num_aces` at line 874 controls the loop iteration count. However, there are multiple bounds checks in place that prevent an OOB access:
1.  Line 868-872: `dacl_size` is validated against `end_of_acl`, ensuring the overall DACL fits within the provided buffer.
2.  Line 881-884: `num_aces` is validated against `dacl_size` using a `min_ace_size`. This ensures that the declared number of ACEs, even if they are all of minimum size, could theoretically fit within the declared `dacl_size`. If `num_aces` is too large for the `dacl_size`, this check returns -EINVAL.
3.  Inside the loop, the pointer `acl_base` is advanced by `ace_size`. This `ace_size` is initially `sizeof(struct smb_acl)` and then updated with `le16_to_cpu(pace->size)`. Each advancement and dereference is protected by explicit checks:
    *   Line 891: `if (end_of_dacl - acl_base < ace_size)` checks if the previous ACE (or header) fits.
    *   Line 899: `if (end_of_dacl - acl_base < ace_hdr_size)` checks if the header of the current ACE fits before accessing `pace->sid.num_subauth`.
    *   Line 907: `if (end_of_dacl - acl_base < ace_size)` checks if the calculated ACE size (based on `num_subauth`) fits.
    *   Line 914: `if (end_of_dacl - acl_base < ace_size)` checks if the *declared* ACE size (from `pace->size`) fits, which is used for the *next* iteration's pointer advance.

These checks ensure that `acl_base` never goes beyond `end_of_dacl`, which is itself bounded by the actual `end_of_acl` from the caller. A counterexample where `secdesclen=1000`, `pdacl->size=1000`, `pdacl->num_aces=80` (just below the pre-loop limit), and an `ace_size` attempts to jump beyond `end_of_dacl` would be caught by one of the `end_of_dacl - acl_base < ace_size` checks before an OOB occurs. For example, if `acl_base` is `pdacl + 990` and the next `ace_size` is `20`, the check `(pdacl+1000) - (pdacl+990) < 20` (i.e., `10 < 20`) would be true, returning -EINVAL before an OOB read at `pdacl + 990 + 20`.



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

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

> The function processes a server response (`pSMBr`) which contains variable offsets. A call to `validate_t2` exists, but its definition is not provided, making it impossible to verify if it fully validates `ParameterOffset` against the received buffer length. Without such validation, deriving a pointer from `ParameterOffset` and dereferencing it is unsafe.

#### 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 4539 |
| Taint snippet | `parms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol +` |
| Tainted var | `parms` |
| Pointer deref | `parms->EndofSearch` line 4541 |
| Sink snippet | `psrch_inf->endOfSearch = !!parms->EndofSearch;` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., page fault, KASAN report) from out-of-bounds read.

**Fix:** Add explicit bounds validation for `pSMBr->t2.ParameterOffset` before `parms` is derived and used. The validation should ensure that `((char *)&pSMBr->hdr.Protocol + le16_to_cpu(pSMBr->t2.ParameterOffset))` is within the bounds of the received `pSMBr` buffer and that `sizeof(T2_FFIRST_RSP_PARMS)` can fit at that offset. For example:

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

	if (param_ptr < (char *)&pSMBr->hdr.Protocol || (param_ptr + sizeof(T2_FFIRST_RSP_PARMS) > rsp_end)) {
		cifs_dbg(VFS, "Parameter data out of bounds: offset %d, len %zu, total %u\n",
			param_offset_val, sizeof(T2_FFIRST_RSP_PARMS), bytes_returned);
		cifs_buf_release(pSMB);
		return -EINVAL;
	}
	parms = (T2_FFIRST_RSP_PARMS *)param_ptr;
```

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



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

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

> The CIFSFindNext function processes an SMB Transaction2 FIND_NEXT response, which is populated from server-supplied data. It extracts a ParameterOffset from the response and uses it to construct a pointer (parms) to a T2_FNEXT_RSP_PARMS structure. The function lacks explicit validation to ensure that this server-supplied ParameterOffset, when combined with the size of the T2_FNEXT_RSP_PARMS structure, does not exceed the bounds of the received SMB response buffer. While a general validator (validate_t2) is called, its specific postconditions regarding internal offsets are not specified, and it's a common pattern for such validators to miss this type of check, leading to OOB reads if the server sends a crafted offset.

#### 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 4648 |
| Taint snippet | `response_data = (char *)&pSMBr->hdr.Protocol +` |
| Tainted var | `parms` |
| Pointer deref | `parms->EndofSearch` line 4662 |
| Sink snippet | `psrch_inf->endOfSearch = !!parms->EndofSearch;` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic, system crash, or information disclosure due to out-of-bounds read when accessing fields of the T2_FNEXT_RSP_PARMS structure (e.g., EndofSearch, SearchCount, LastNameOffset).

**Fix:** Before casting `response_data` to `T2_FNEXT_RSP_PARMS *parms` (line 4650), add a bounds check for the server-supplied `ParameterOffset`.

```c
	// ... after rc = validate_t2((struct smb_t2_rsp *)pSMBr);

	unsigned int param_offset_val = le16_to_cpu(pSMBr->t2.ParameterOffset);
	// The base for ParameterOffset is &pSMBr->hdr.Protocol
	char *effective_base = (char *)&pSMBr->hdr.Protocol;
	unsigned int effective_payload_len = bytes_returned - (effective_base - (char *)pSMBr);

	if (param_offset_val + sizeof(T2_FNEXT_RSP_PARMS) > effective_payload_len) {
		cifs_dbg(VFS, "Parameter data struct (offset %u, size %zu) out of bounds. Total payload len: %u\n",
			 param_offset_val, sizeof(T2_FNEXT_RSP_PARMS), effective_payload_len);
		cifs_buf_release(pSMB);
		return -EINVAL;
	}

	response_data = effective_base + param_offset_val;
	parms = (T2_FNEXT_RSP_PARMS *)response_data;
	// ... rest of the code
```
This check ensures that the entire `T2_FNEXT_RSP_PARMS` structure, when placed at `ParameterOffset` relative to `&pSMBr->hdr.Protocol`, fits within the actual received `bytes_returned` buffer.

**CVE pattern:** SMB Trans2 ParameterOffset OOB



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

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

> The CIFSGetExtAttr function retrieves extended attributes by sending a TRANS2_QUERY_FILE_INFORMATION request. It parses the server's response by extracting DataOffset and DataCount. While DataCount is checked to be 16 (the expected size of struct file_chattr_info), DataOffset is not validated against the actual size of the received SMB response. This allows a malicious server to provide an out-of-bounds DataOffset, causing the kernel to read past the end of the allocated response buffer when accessing fields of the 'pfinfo' struct.

#### 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 3726 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `pfinfo` |
| Pointer deref | `pfinfo->mode` line 3738 |
| Sink snippet | `*pExtAttrBits = le64_to_cpu(pfinfo->mode);` |
| 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 in CIFSGetExtAttr

**Fix:** Add a bounds check to ensure that the calculated end of the 'file_chattr_info' structure does not exceed the total received buffer length. Specifically, after `data_offset` is extracted and `count` is validated, add a check like:
`char *data_base = (char *)&pSMBr->hdr.Protocol;`
`if (data_offset > (char *)pSMBr + bytes_returned - data_base ||`
`    data_base + data_offset + sizeof(struct file_chattr_info) > (char *)pSMBr + bytes_returned) {`
`    cifs_dbg(FYI, "Invalid DataOffset or insufficient data in GetExtAttr response\n");`
`    rc = smb_EIO2(smb_eio_trace_getextattr_inv_offset_or_size, data_offset, sizeof(struct file_chattr_info));`
`    goto GetExtAttrOut;`
`}`
This check verifies that `data_offset` plus the size of the `file_chattr_info` struct fits within the `bytes_returned` boundary, relative to the `pSMBr->hdr.Protocol` base pointer used.

**CVE pattern:** SMB DataOffset OOB read



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

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

> The function processes a server-supplied TRANSACTION2_QUERY_PATH_INFORMATION response. It extracts a DataOffset and DataCount from the response header to locate and interpret a file_internal_info structure. While DataCount is checked to be at least 8 bytes (the size of UniqueId), there is no validation that DataOffset itself, or DataOffset + sizeof(UniqueId), actually falls within the bounds of the received network buffer (bytes_returned from SendReceive). This allows a malicious server to provide an out-of-bounds DataOffset, leading to an OOB read when accessing pfinfo->UniqueId.

#### 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 4793 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `pfinfo` |
| Pointer deref | `pfinfo->UniqueId` line 4805 |
| Sink snippet | `*inode_number = le64_to_cpu(pfinfo->UniqueId);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or KASAN: slab-out-of-bounds read in CIFSGetSrvInodeNumber, or information disclosure if sensitive kernel memory is read.

**Fix:** Add explicit bounds checks for `data_offset` before deriving `pfinfo`. The `data_offset` (relative to `pSMBr`) must be at least past the fixed header portion of the `TRANSACTION2_QPI_RSP` structure, and `data_offset + sizeof(__le64)` must not exceed `bytes_returned` (the actual length of the received response buffer). Example fix:

```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
			__u16 count = le16_to_cpu(pSMBr->t2.DataCount);
			char *response_base = (char *)pSMBr;

			// Determine the minimum valid offset for data payload within the TRANSACTION2_QPI_RSP structure.
			// This should be after the fixed header fields, including the t2.Pad field.
			size_t min_valid_data_offset = offsetof(struct TRANSACTION2_QPI_RSP, t2) + offsetof(struct smb_t2_rsp, Pad) + sizeof(__u8);

			// Validate DataOffset and the space required for UniqueId against the actual received buffer length.
			if (data_offset < min_valid_data_offset || data_offset + sizeof(__le64) > bytes_returned) {
				cifs_dbg(FYI, "Data offset %u (min %zu) or inode number access %zu exceeds buffer end %u\n",
					 data_offset, min_valid_data_offset, (size_t)data_offset + sizeof(__le64), bytes_returned);
				rc = smb_EIO2(smb_eio_trace_getsrvinonum_data_oob, data_offset, bytes_returned);
				goto GetInodeNumOut;
			}

			if (count < sizeof(__le64)) {
				cifs_dbg(FYI, "Invalid data count %u (min %zu) returned in QryIntrnlInf\n",
					 count, sizeof(__le64));
				rc = smb_EIO2(smb_eio_trace_getsrvinonum_size, count, sizeof(__le64));
				goto GetInodeNumOut;
			}
			struct file_internal_info *pfinfo = (struct file_internal_info *)(response_base + data_offset);
			*inode_number = le64_to_cpu(pfinfo->UniqueId);
```
Note: The exact `min_valid_data_offset` might need fine-tuning based on the precise `TRANSACTION2_QPI_RSP` and `smb_t2_rsp` struct definitions, specifically where variable-length data is expected to start relative to `pSMBr`.

**CVE pattern:** SMB DataOffset OOB read



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

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

> Both findings stem from insufficient validation of the server-supplied `pSMBr->t2.DataOffset` field against the actual received buffer length (`get_bcc(&pSMBr->hdr)`). While there are minimum size checks for the total received data, they do not account for an arbitrarily large `DataOffset` that could cause `psx_rsp` (derived from `DataOffset`) to point out of bounds or to a location where subsequent accesses read out of bounds. The `validate_t2` function source is not provided, so its specific postconditions regarding `DataOffset` cannot be confirmed, but the explicit checks present are clearly insufficient.

#### 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 1138 |
| Taint snippet | `psx_rsp = (OPEN_PSX_RSP *)` |
| Tainted var | `psx_rsp` |
| Pointer deref | `psx_rsp->OplockFlags` line 1141 |
| Sink snippet | `*pOplock = le16_to_cpu(psx_rsp->OplockFlags);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or KASAN report due to out-of-bounds read.

**Fix:** Before line 1141, add a bounds check: `if (le16_to_cpu(pSMBr->t2.DataOffset) + sizeof(OPEN_PSX_RSP) > get_bcc(&pSMBr->hdr))` handle the error (e.g., `goto psx_create_err;`). This ensures that the `OPEN_PSX_RSP` structure, starting at `DataOffset`, fully fits within the received data.

**CVE pattern:** SMB DataOffset OOB


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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 1138 |
| Taint snippet | `psx_rsp = (OPEN_PSX_RSP *)` |
| Tainted var | `psx_rsp` |
| Sink | `memcpy()` line 1159 (arg 1, role=pointer) |
| Sink snippet | `memcpy(pRetData,` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or KASAN report due to out-of-bounds read during `memcpy`.

**Fix:** Modify the check at line 1153 to also incorporate the `DataOffset`: `if (le16_to_cpu(pSMBr->t2.DataOffset) + sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO) > get_bcc(&pSMBr->hdr))` handle the error (e.g., `goto psx_create_err;`). This ensures that the entire `OPEN_PSX_RSP` structure plus the `FILE_UNIX_BASIC_INFO` payload fits within the received data, considering the `DataOffset`.

**CVE pattern:** SMB DataOffset OOB



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

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

> The function `CIFSSMBPosixLock` handles SMB Transaction2 responses, specifically for POSIX lock operations. It reads various fields from the `smb_com_transaction2_sfi_rsp` structure, which is a server-supplied buffer. While some length checks are present (`get_bcc` for total payload, `DataCount` for reported data length), there is a missing bounds check for the `DataOffset` field itself before using it to derive a pointer for a `cifs_posix_lock` structure. This allows a malicious server to craft a response where `DataOffset` points beyond the actual received buffer, leading 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 2392 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `parm_data` |
| Pointer deref | `parm_data->lock_type` line 2401 |
| 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, KASAN report, or information disclosure due to reading memory outside the allocated SMB response buffer.

**Fix:** Before assigning `parm_data` at line 2399, add a check to ensure that `data_offset + sizeof(struct cifs_posix_lock)` does not exceed the actual received length of the SMB response buffer. The `data_offset` is relative to `&pSMBr->hdr.Protocol`. The actual received length is `bytes_returned` (for `SendReceive`) or `rsp_iov.iov_len` (for `SendReceive2`).

Proposed check:
```c
unsigned int total_response_len = (waitFlag) ? bytes_returned : rsp_iov.iov_len;
char *const payload_start = (char *)&pSMBr->hdr.Protocol;
char *const response_end = (char *)pSMB + total_response_len;

// Check if the derived pointer (payload_start + data_offset) and the entire struct (sizeof(struct cifs_posix_lock))
// would fit within the actual received response buffer.
// Also, ensure data_offset is not so small that it points into the SMB header itself, if that's not intended.
if (payload_start + data_offset < payload_start || // Check for pointer wrap-around if data_offset is huge
    payload_start + data_offset + sizeof(struct cifs_posix_lock) > response_end) {
    rc = smb_EIO2(smb_eio_trace_lock_oob_data_offset, data_offset, sizeof(struct cifs_posix_lock));
    goto plk_err_exit;
}
```
This check should be placed before line 2399.

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



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

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

> The initial validation of `data_offset` ensures that `ea_response_data` points to a valid `struct fealist` within the received SMB buffer. However, the subsequent loop that iterates over `struct fea` entries within this `fealist` is flawed. The `temp_fea` and `temp_ptr` pointers are advanced based on server-supplied `name_len` and `value_len` fields. While a logical remaining `list_len` is tracked and checked for underflow, the physical pointers (`temp_fea`, `temp_ptr`) are not sufficiently re-validated against the `end_of_smb` boundary *before* subsequent dereferences or memory operations. This can lead to out-of-bounds reads when parsing individual EA entries, as demonstrated by the counterexamples.

#### 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 6240 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `ea_response_data` |
| Pointer deref | `ea_response_data->list_len` line 6261 |
| Sink snippet | `list_len = le32_to_cpu(ea_response_data->list_len);` |
| Possibly guarded | no |

*Dismissed:* The `data_offset` is extracted from the server-supplied `pSMBr` response. However, comprehensive bounds checks are present immediately after extraction: `data_offset < sizeof(*pSMBr)` (line 6241) provides a lower bound, and `(size_t)data_offset + sizeof(struct fealist) > (size_t)bytes_returned` (line 6248) provides an upper bound. These checks ensure that `ea_response_data` points within the received buffer and that `sizeof(struct fealist)` can be safely read, including `ea_response_data->list_len`. Tested with `bytes_returned=100`, `data_offset=0` (caught by 6241), `data_offset=90` with `sizeof(struct fealist)=20` (caught by 6248). No OOB access to `ea_response_data->list_len` is possible.


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

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

*Dismissed:* This finding is identical to Finding #1 in its root cause and validation. The pointer `ea_response_data` is derived from `data_offset`, which is validated by checks at lines 6241-6256. These checks ensure that `sizeof(struct fealist)` fits within the buffer. Accessing `ea_response_data->list` is within the bounds of `struct fealist`, hence safe. No OOB access to `ea_response_data->list` is possible.


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

| Field | Value |
|---|---|
| Category | Cat F — server value → loop iteration count |
| Taint source | `le32_to_cpu()` line 6261 |
| Taint snippet | `list_len = le32_to_cpu(ea_response_data->list_len);` |
| Tainted var | `list_len` |
| Loop | `while_loop` line 6285 |
| Sink snippet | `while (list_len > 0) {` |
| Possibly guarded | yes (heuristic) |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or data corruption from reading past the end of the SMB response buffer. Subsequent pointer dereferences and memory copies become OOB.

**Fix:** Inside the `while` loop, before accessing `temp_fea->name_len` or `temp_fea->value_len` (lines 6298-6299), add a check to ensure `temp_fea` is sufficiently within `end_of_smb`. Specifically, `if ((char *)temp_fea + sizeof(__u8) /*flags*/ + sizeof(__u8) /*name_len*/ + sizeof(__le16) /*value_len*/ > end_of_smb)` or `if ((char *)temp_fea + offsetof(struct fea, name) > end_of_smb)` should trigger an error.

**CVE pattern:** Loop pointer advance OOB read


#### 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 6240 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `temp_fea` |
| Pointer deref | `temp_fea->name_len` line 6298 |
| Sink snippet | `name_len = temp_fea->name_len;` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic or data corruption when reading `temp_fea->name_len` or `temp_fea->value_len` past the end of the SMB response buffer.

**Fix:** As per Finding #3, add a check inside the loop before accessing `temp_fea->name_len` or `temp_fea->value_len`. Example: `if ((char *)temp_fea + offsetof(struct fea, name) > end_of_smb)`.

**CVE pattern:** Loop pointer advance OOB read


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `le16_to_cpu()` line 6298 |
| Taint snippet | `name_len = temp_fea->name_len;` |
| Tainted var | `name_len` |
| Sink | `memcmp()` line 6309 (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 | yes |
| Check sufficient | no |

**Symptom:** Kernel panic or information disclosure due to `memcmp` reading past `end_of_smb` from the `temp_ptr` source buffer.

**Fix:** After `name_len` is obtained and `temp_ptr` has been advanced by 4 (to point to the name data), before `memcmp` at line 6309, add `if ((char *)temp_ptr + name_len > end_of_smb)`.

**CVE pattern:** OOB read in memcmp, loop traversal


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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 6240 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `temp_ptr` |
| Sink | `memcmp()` line 6309 (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 due to `memcmp` using an OOB `temp_ptr` pointer.

**Fix:** As per Finding #5, add a check `if ((char *)temp_ptr + name_len > end_of_smb)` before `memcmp` at line 6309. This validates the `temp_ptr` source buffer for the `name_len` bytes.

**CVE pattern:** OOB read, loop traversal


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `le16_to_cpu()` line 6299 |
| Taint snippet | `value_len = le16_to_cpu(temp_fea->value_len);` |
| Tainted var | `value_len` |
| Sink | `memcpy()` line 6318 (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 due to `memcpy` reading `value_len` bytes past `end_of_smb` from the `temp_ptr` source buffer.

**Fix:** After `temp_ptr` is advanced by `name_len + 1` (line 6310), before the `memcpy` at line 6318, add a check: `if ((char *)temp_ptr + value_len > end_of_smb)`.

**CVE pattern:** OOB read in memcpy, loop traversal


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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 6240 |
| Taint snippet | `data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `temp_ptr` |
| Sink | `memcpy()` line 6318 (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 due to `memcpy` using an OOB `temp_ptr` pointer.

**Fix:** As per Findings #7 and #9, add appropriate bounds checks for `temp_ptr` before the `memcpy` operations at lines 6318 and 6327.

**CVE pattern:** OOB read, loop traversal


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `le16_to_cpu()` line 6298 |
| Taint snippet | `name_len = temp_fea->name_len;` |
| Tainted var | `name_len` |
| Sink | `memcpy()` line 6327 (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 due to `memcpy` reading `name_len` bytes past `end_of_smb` from the `temp_ptr` source buffer.

**Fix:** In the `else` block (when `ea_name` is NULL), before the `memcpy(EAData, temp_ptr, name_len)` at line 6327, add a check: `if ((char *)temp_ptr + name_len > end_of_smb)`.

**CVE pattern:** OOB read in memcpy, loop traversal



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

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

> The function processes a server-supplied SMB Transaction2 response. The `DataOffset` field is extracted from the response and used to calculate a pointer (`response_data`) into the received buffer. A subsequent `memcpy` operation copies a fixed size (`sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)`) from this derived pointer to `tcon->fsAttrInfo`. There is no validation that `data_offset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)` stays within the bounds of the actually received SMB response buffer (`bytes_returned`). A malicious or buggy server can supply an arbitrary `DataOffset` value, causing an out-of-bounds read.

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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 5170 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Sink | `memcpy()` line 5175 (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, KASAN report (slab-out-of-bounds read), potential information disclosure if sensitive kernel memory is read.

**Fix:** Before the `memcpy` on line 5175, add a bounds check to ensure that the calculated `response_data` and the size of `FILE_SYSTEM_ATTRIBUTE_INFO` fit entirely within the received buffer. This requires checking both a lower and upper bound for `data_offset`.

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

			// Minimum valid DataOffset: must point past the fixed SMB header and T2 response header fields.
			// The size of fixed smb_hdr is 32 bytes. The smb_t2_rsp contains fields up to DataOffset, 
			// typically around 14 bytes for the fixed portion (offsetof(smb_t2_rsp, Setup)).
			// So, a reasonable minimum data_offset is sizeof(struct smb_hdr) + offsetof(struct smb_t2_rsp, Setup)
			// (approx. 32 + 14 = 46 bytes).
			// Maximum valid end of data: data_offset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) must be <= bytes_returned.
			if (data_offset < (sizeof(struct smb_hdr) + offsetof(struct smb_t2_rsp, Setup)) ||
			    data_offset + sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) > bytes_returned) {
				cifs_dbg(VFS, "Bad DataOffset (0x%x) or insufficient data for QFSAttributeInfo. Total response len: %d, Needed: %zu\n", 
				         data_offset, bytes_returned, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO));
				rc = smb_EIO2(smb_eio_trace_qfsattrinfo_bad_offset, data_offset, bytes_returned);
			} else {
				response_data =
				    (FILE_SYSTEM_ATTRIBUTE_INFO
				     *) (((char *) pSMBr) + data_offset);
				memcpy(&tcon->fsAttrInfo, response_data,
				       sizeof(FILE_SYSTEM_ATTRIBUTE_INFO));
			}
```

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



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

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

> The function receives server-supplied data and extracts an offset (DataOffset) from it. This offset is then used in pointer arithmetic to derive a new pointer (`response_data`), which is subsequently used as the source pointer in a `memcpy` operation. Although there is a check on the total byte count (`get_bcc(&pSMBr->hdr)`), it is insufficient to prevent an out-of-bounds read. The check only ensures that the total server-reported data length is at least `sizeof(FILE_SYSTEM_DEVICE_INFO)`. It does not verify that `data_offset` itself is valid, nor that `data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO)` fits within the reported data length, or more critically, within the *actual* received buffer length (`bytes_returned`).

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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 5245 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Sink | `memcpy()` line 5250 (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 or KASAN slab-out-of-bounds read.

**Fix:** Add a bounds check to verify that `data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO)` does not exceed the actual received buffer's bounds. The check should be performed after `data_offset` is extracted and before `response_data` is used in `memcpy`.

Specifically, one must verify:
1. That `data_offset` is not negative (though `__u16` prevents this, it's good practice).
2. That `data_offset` is not excessively large such that `response_data` would point beyond the `pSMBr` buffer.
3. That `response_data + sizeof(FILE_SYSTEM_DEVICE_INFO)` does not exceed `pSMBr + bytes_returned` (the end of the actual received buffer).

Example check: Before line 5250, add:
`if (data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > get_bcc(&pSMBr->hdr) || (char *)&pSMBr->hdr.Protocol + data_offset + sizeof(FILE_SYSTEM_DEVICE_INFO) > (char *)pSMBr + bytes_returned) {
    cifs_dbg(VFS, "cifs: DataOffset or data size too large for QFSDeviceInfo\n");
    rc = -EINVAL;
    goto cleanup;
}`
(Replace `get_bcc(&pSMBr->hdr)` with the correct measure of the data section length if it's different from the overall `ByteCount`.)

**CVE pattern:** SMB DataOffset OOB read



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

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

> The function `CIFSSMBQFSInfo` processes an SMB Transaction2 Query File System Information response. It extracts `DataOffset` from the server-supplied response. This offset is then used to derive a pointer `response_data` into the received buffer. While there is a check (`get_bcc(&pSMBr->hdr) < 24`) that ensures the reported data byte count is at least `sizeof(FILE_SYSTEM_SIZE_INFO)`, there is no validation that `data_offset` combined with `sizeof(FILE_SYSTEM_SIZE_INFO)` stays within the bounds of the actual received SMB message buffer (`bytes_returned`). This allows a malicious server to provide an out-of-bounds `DataOffset` value, 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 5079 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Pointer deref | `response_data->BytesPerSector` line 5086 |
| Sink snippet | `le32_to_cpu(response_data->BytesPerSector) *` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic, BUG: KASAN: slab-out-of-bounds Read, or information disclosure.

**Fix:** After `data_offset` is extracted and converted, add a bounds check before deriving `response_data`. The check must ensure that `data_offset` (relative to the base pointer used, `&pSMBr->hdr.Protocol`) plus `sizeof(FILE_SYSTEM_SIZE_INFO)` does not exceed the total received buffer length (`bytes_returned`). A lower bound check on `data_offset` should also be added to prevent it from pointing into the SMB header itself.

Example fix (adjusting base pointer and offset as per actual struct definitions):
```c
__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
char *base_ptr = (char *)&pSMBr->hdr.Protocol;
char *buf_end = (char *)pSMBr + bytes_returned;

// Ensure data_offset doesn't cause a pointer before the base (implicit for __u16, but good for signed variants)
// Ensure data_offset doesn't point into the fixed SMB header fields, e.g., offsetof(smb_hdr, Protocol) or similar.
// Assuming data_offset is relative to the start of pSMBr, or if relative to Protocol, it must be >= 0.
// Let's assume data_offset is relative to pSMBr (common SMB practice) and the code's base_ptr calculation is an implicit offset:
// If data_offset is relative to pSMBr, then response_data = (FILE_SYSTEM_SIZE_INFO *) (((char *)pSMBr) + data_offset);
// And the bound check should be:
// if ((size_t)data_offset + sizeof(FILE_SYSTEM_SIZE_INFO) > bytes_returned ||
//     (size_t)data_offset < MIN_TRANSACTION2_RSP_DATA_OFFSET_EXPECTED_BY_PROTOCOL) { // E.g., past header
//    rc = -EINVAL; goto err_free_smb_buf;
// }

// Given the current code's pointer arithmetic:
// base_ptr is (char *)&pSMBr->hdr.Protocol
// The effective end of accessible data using this base and server-supplied offset is base_ptr + data_offset + sizeof(FILE_SYSTEM_SIZE_INFO).
// This must be <= the overall buffer end: (char *)pSMBr + bytes_returned.
// Also, data_offset should not be so small it points into the SMB header via base_ptr.

// A more robust bounds check:
if ((data_offset > (size_t)(buf_end - base_ptr) - sizeof(FILE_SYSTEM_SIZE_INFO)) ||
    (data_offset < 0) || // __u16 ensures this is false, but good practice
    (data_offset < MIN_VALID_DATA_OFFSET_REL_TO_PROTOCOL_BASE)) { // e.g. for avoiding SMB header overlap
    cifs_dbg(VFS, "DataOffset %u out of bounds. buf_end=%p, base_ptr=%p, needed=%zu. rc=%d
",
             data_offset, buf_end, base_ptr, sizeof(FILE_SYSTEM_SIZE_INFO), rc);
    rc = -EINVAL;
    goto err_free_smb_buf;
}

// The existing get_bcc check is for the _total data length_ not the _offset validity_.
// If get_bcc(&pSMBr->hdr) < sizeof(FILE_SYSTEM_SIZE_INFO), then it's an error.
// This check is already present at line 5075.
```

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



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

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

> The function processes a server response (`pSMBr`) received via `SendReceive`. The `data_offset` field is extracted from this server response and used to derive a pointer (`response_data`) into the buffer. Subsequent accesses to fields within `response_data` are vulnerable if `data_offset` (plus the size of the `FILE_SYSTEM_POSIX_INFO` struct) points beyond the end of the received buffer. The existing validation is insufficient.

#### 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 5466 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Pointer deref | `response_data->BlockSize` line 5472 |
| Sink snippet | `le32_to_cpu(response_data->BlockSize);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** kernel panic from heap corruption (e.g., KASAN: slab-out-of-bounds Read), information disclosure, or system instability.

**Fix:** Before dereferencing `response_data`, add a check to ensure that the `data_offset` and the size of the `FILE_SYSTEM_POSIX_INFO` struct do not exceed the received buffer's bounds. The `bytes_returned` variable gives the total length of the received SMB response. The `data_offset` is relative to `&pSMBr->hdr.Protocol`. Therefore, the check should be:

```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
			// Calculate the start of the data relative to the beginning of the pSMBr buffer.
			int data_start_abs = offsetof(struct smb_hdr, Protocol) + data_offset;

			if (data_start_abs < 0 || data_start_abs + sizeof(FILE_SYSTEM_POSIX_INFO) > bytes_returned) {
				cifs_dbg(VFS, "Bad Posix Info data offset %d or size %zu, bytes_returned %d\n",
					 data_offset, sizeof(FILE_SYSTEM_POSIX_INFO), bytes_returned);
				rc = -EINVAL;
			} else {
				response_data = (FILE_SYSTEM_POSIX_INFO *) (((char *) &pSMBr->hdr.Protocol) +
									 data_offset);
				// ... subsequent accesses
			}
```

Additionally, consider whether `data_offset` should have a lower bound, e.g., `data_offset >= offsetof(TRANSACTION2_RSP_HDR, Data)` if the data is expected to start after the fixed part of the TRANSACTION2 header.

**CVE pattern:** SMB DataOffset OOB



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

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

> The function retrieves `FILE_SYSTEM_UNIX_INFO` from a server response. The `DataOffset` field in the SMB Transaction2 response is server-supplied. This offset is used to calculate a pointer `response_data`, from which `sizeof(FILE_SYSTEM_UNIX_INFO)` bytes are copied via `memcpy`. There is no explicit validation of `data_offset` to ensure that `response_data` and the subsequent `sizeof(FILE_SYSTEM_UNIX_INFO)` bytes fall within the bounds of the received server response buffer (`pSMBr` of size `bytes_returned`). Existing checks (`validate_t2` and `get_bcc < 13`) are insufficient: `validate_t2`'s exact postconditions are unknown, but this OOB pattern is common, suggesting it doesn't cover this; `get_bcc < 13` checks only a minimal total data length, not the specific offset and length of the `FILE_SYSTEM_UNIX_INFO` structure.

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

| Field | Value |
|---|---|
| Category | Cat A — server offset → pointer → memory op |
| Taint source | `le16_to_cpu()` line 5317 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Sink | `memcpy()` line 5322 (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 (page fault, KASAN report) due to out-of-bounds memory read during memcpy.

**Fix:** Before line 5322, add a bounds check to ensure that the calculated `response_data` pointer, plus the size of `FILE_SYSTEM_UNIX_INFO`, remains within the received `pSMBr` buffer's valid data region, which is bounded by `bytes_returned`. The `data_offset` is relative to `&pSMBr->hdr.Protocol`.

Proposed fix logic:
```c
			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
			char *response_start_ptr = (char *)pSMBr;
			char *buffer_end_ptr = response_start_ptr + bytes_returned;
			char *data_base_ptr = (char *)&pSMBr->hdr.Protocol;
			char *effective_data_ptr = data_base_ptr + data_offset;

			// Ensure data_offset doesn't cause effective_data_ptr to be before the main response buffer
			// And ensure data_offset doesn't point into the header fields if FSI data is expected later.
			// The minimum offset from 'response_start_ptr' where FILE_SYSTEM_UNIX_INFO can legitimately start.
			// This 'min_expected_fsi_offset' would be 'offsetof(TRANSACTION2_QFSI_RSP, t2.Pad)' or similar.
			// For simplicity, a basic check against total buffer bounds first.

			if (effective_data_ptr < response_start_ptr ||
			    effective_data_ptr + sizeof(FILE_SYSTEM_UNIX_INFO) > buffer_end_ptr) {
				cifs_dbg(VFS, "SMBQFSUnixInfo: Response data out of bounds: offset=%u, total_len=%d, FSI_size=%zu\n",
					 data_offset, bytes_returned, sizeof(FILE_SYSTEM_UNIX_INFO));
				rc = -EIO;
			} else {
				response_data = (FILE_SYSTEM_UNIX_INFO *)effective_data_ptr;
				memcpy(&tcon->fsUnixInfo, response_data,
				       sizeof(FILE_SYSTEM_UNIX_INFO));
			}
```
(Note: The `effective_data_ptr < response_start_ptr` check is largely redundant for `__u16 data_offset` if `data_base_ptr` is within `response_start_ptr` and `data_offset` is unsigned. The crucial part is the upper bound and a lower bound check to ensure `effective_data_ptr` isn't pointing *into* the SMB/T2 headers themselves if the FSI structure is expected to start later.)

A more refined lower bound check should consider the actual fixed size of the SMB and Transaction2 response headers. The `effective_data_ptr` should not be less than `response_start_ptr + MIN_FIXED_HEADER_SIZE_FOR_TRANS2_RESPONSE`.

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



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

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

> The function `CIFSSMBRead` receives a server response `pSMBr` (via `SendReceive2`) and extracts `DataLength` and `DataOffset` fields. These fields are used to determine the location and size of the actual read data within the received response buffer. The code includes comprehensive validation checks (lines 1738-1753) to ensure that the reported data region (defined by `data_offset` and `data_length`) is within the bounds of the received buffer and also within the requested/allowed limits. The `memcpy` operation at line 1760 is thus protected against out-of-bounds reads from the server response buffer.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `le16_to_cpu()` line 1731 |
| Taint snippet | `unsigned int data_length = le16_to_cpu(pSMBr->DataLengthHigh);` |
| Tainted var | `data_length` |
| Sink | `memcpy()` line 1760 (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:* `data_length` is derived from `pSMBr->DataLength` and `pSMBr->DataLengthHigh`, which are server-supplied fields. This `data_length` is used as the size argument to `memcpy()`. The following checks are present:
1. Line 1738: `if ((data_length > CIFSMaxBufSize) || (data_length > count))`. This bounds `data_length` against a global maximum buffer size (`CIFSMaxBufSize`) and the client's requested read length (`count`). This ensures `data_length` does not exceed what was requested or is globally allowed. Assuming `count` also represents the size of the caller-provided `*buf` (a common pattern for `read` operations), this check prevents OOB writes to the destination buffer.
2. Line 1746: `(size_t)data_offset + data_length > rsp_iov.iov_len`. This check ensures that the entire data region (starting at `data_offset` and spanning `data_length` bytes) does not extend beyond the end of the actual received server response buffer (`rsp_iov.iov_len`). This prevents OOB reads from the source buffer (`pSMBr`).

Counterexample test:
- Source buffer (`rsp_iov.iov_base`) has length `rsp_iov.iov_len = 100`.
- Minimum header size `sizeof(*pSMBr) = 32`.
- Requested count `count = 4096`.
- `CIFSMaxBufSize = 65536`.
- If `data_length = 5000` (exceeds `count`):
  - Line 1738 `(5000 > 65536) || (5000 > 4096)` evaluates to `false || true`, so `true`. The `if` branch is taken, `rc` is set to `smb_EIO2`, and `memcpy` is skipped. This prevents OOB write to `*buf` (assuming `count` is its size).
- If `data_length = 80` and `data_offset = 30`:
  - Line 1738 passes (80 <= 4096).
  - Line 1745 `(30 < 32)` is false. 
  - Line 1746 `(30 + 80 > 100)` evaluates to `(110 > 100)`, so `true`. The `else if` branch is taken, `rc` is set to `smb_EIO2`, and `memcpy` is skipped. This prevents OOB read from `rsp_iov.iov_base`.
In all tested scenarios, the existing guards prevent OOB access. Therefore, the finding is a false positive.


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

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

*Dismissed:* `data_offset` is derived from `pSMBr->DataOffset`, a server-supplied field. This `data_offset` is used to calculate `pReadData` (`(char *) (&pSMBr->hdr.Protocol) + data_offset`), which is the source pointer for `memcpy()`. The following checks are present (in conjunction with `data_length` validation from Finding #1):
1. Line 1745: `data_offset < sizeof(*pSMBr)`. This is a lower-bound check, ensuring that `data_offset` points past the fixed-size header of the `READ_RSP` structure. If the offset points into the header, the `if` branch is taken, `rc` is set, and `memcpy` is skipped.
2. Line 1746: `(size_t)data_offset + data_length > rsp_iov.iov_len`. This is an upper-bound check, ensuring that the combined `data_offset` and `data_length` do not exceed the total length of the received response buffer `rsp_iov.iov_len`. If the data region extends beyond the buffer, the `if` branch is taken, `rc` is set, and `memcpy` is skipped.

Counterexample test:
- Source buffer (`rsp_iov.iov_base`) has length `rsp_iov.iov_len = 100`.
- Minimum header size `sizeof(*pSMBr) = 32`.
- Validated `data_length = 10`.
- If `data_offset = 20` (points into header):
  - Line 1745 `(20 < 32)` evaluates to `true`. The `else if` branch is taken, `rc` is set to `smb_EIO2`, and `memcpy` is skipped. This prevents reading from the header as if it were data.
- If `data_offset = 95` (points near end, but `offset + length` is OOB):
  - Line 1745 `(95 < 32)` is false.
  - Line 1746 `(95 + 10 > 100)` evaluates to `(105 > 100)`, so `true`. The `else if` branch is taken, `rc` is set to `smb_EIO2`, and `memcpy` is skipped. This prevents OOB read from `rsp_iov.iov_base`.
- If `data_offset = 32` and `data_length = 10`:
  - Line 1745 `(32 < 32)` is false.
  - Line 1746 `(32 + 10 > 100)` evaluates to `(42 > 100)`, so `false`. The `memcpy` is executed, and `pReadData` will be `pSMBr + 32`, which is within bounds for `data_length` of 10 bytes.
In all tested scenarios, the existing guards prevent OOB access. Therefore, the finding is a false positive.



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

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

> The function `CIFSSMBUnixQuerySymLink` parses a server-supplied SMB TRANSACTION2_QUERY_PATH_INFORMATION response. It extracts `DataOffset` and `DataCount` from the response header to locate and size the symbolic link target data. These values are then used as parameters to `cifs_strndup_from_utf16`, which performs memory allocation and data copying.

The `SendReceive` function guarantees that the response buffer `pSMBr` has an actual size of `bytes_returned`. However, the current validation logic for `DataOffset` and `DataCount` is insufficient. The `validate_t2` function's source is not provided, but the immediate 'BB' comment ('BB also check enough total bytes returned') strongly indicates that it does not sufficiently validate `DataOffset` and `DataCount` against the actual received buffer size (`bytes_returned`). The `get_bcc(&pSMBr->hdr) < 2` check is too weak to provide meaningful bounds protection.

Without proper validation, a malicious server can provide a `DataOffset` that points outside the received buffer or a `DataCount` that causes the read (`data_start + count`) to extend beyond the buffer's end. This leads to an out-of-bounds read when `cifs_strndup_from_utf16` (specifically, `cifs_utf16_bytes` and `cifs_from_utf16`) attempts to access the data. This OOB read can cause a kernel panic or expose sensitive kernel memory. The `kmalloc` size is also influenced by these tainted values, potentially leading to undersized allocations and subsequent heap overflows when the data is copied.

#### 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 2961 |
| Taint snippet | `data_start = ((char *) &pSMBr->hdr.Protocol) +` |
| Tainted var | `data_start` |
| Call site | line 2970 — passes `data_start` to `cifs_strndup_from_utf16()` |
| Call snippet | `*symlinkinfo = cifs_strndup_from_utf16(data_start,` |
| Sink (in callee) | `kmalloc()` line 341 (arg 0, role=size) |
| Sink snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from out-of-bounds read, or potential information disclosure from reading adjacent kernel memory, or heap overflow if kmalloc is undersized.

**Fix:** Introduce robust bounds checking for `DataOffset`. Specifically, before constructing `data_start` and passing it to `cifs_strndup_from_utf16`, verify that `le16_to_cpu(pSMBr->t2.DataOffset)` is non-negative and, when combined with `le16_to_cpu(pSMBr->t2.DataCount)`, does not exceed `bytes_returned` (the actual size of the received SMB response). Also, `DataOffset` should be validated against a lower bound, ensuring it points past the fixed response header fields to prevent misinterpreting header data as string content.

Counterexample test: If `bytes_returned = 100` and a malicious server sets `pSMBr->t2.DataOffset = 101` and `pSMBr->t2.DataCount = 10`, then `data_start` will point one byte past the end of the buffer. The subsequent read within `cifs_utf16_bytes` (part of `cifs_strndup_from_utf16`) will be an out-of-bounds read.

**CVE pattern:** SMB 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 2959 |
| Taint snippet | `u16 count = le16_to_cpu(pSMBr->t2.DataCount);` |
| Tainted var | `count` |
| Call site | line 2970 — passes `count` to `cifs_strndup_from_utf16()` |
| Call snippet | `*symlinkinfo = cifs_strndup_from_utf16(data_start,` |
| Sink (in callee) | `kmalloc()` line 341 (arg 0, role=size) |
| Sink snippet | `dst = kmalloc(len, GFP_KERNEL);` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from out-of-bounds read, or potential information disclosure from reading adjacent kernel memory, or heap overflow if kmalloc is undersized.

**Fix:** Introduce robust bounds checking for `DataCount`. Specifically, before passing `count` to `cifs_strndup_from_utf16`, verify that `le16_to_cpu(pSMBr->t2.DataOffset) + le16_to_cpu(pSMBr->t2.DataCount)` does not exceed `bytes_returned` (the actual size of the received SMB response).

Counterexample test: If `bytes_returned = 100`, `pSMBr->t2.DataOffset = 90`, and a malicious server sets `pSMBr->t2.DataCount = 20`, then `data_start` points to `pSMBr + 90` and `count` is 20. The read operation (`data_start` for `count` bytes) within `cifs_utf16_bytes` will attempt to read up to `pSMBr + 90 + 20 = pSMBr + 110`, resulting in an out-of-bounds read of 10 bytes.

**CVE pattern:** SMB DataCount OOB



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

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

> The function processes a server-supplied TRANSACTION2_QFSI_RSP. It extracts a 'DataOffset' from the response header and uses it to calculate a pointer to a 'FILE_SYSTEM_ALLOC_INFO' structure. The existing bounds checks are insufficient to guarantee that the derived pointer, when dereferenced to access fields of 'FILE_SYSTEM_ALLOC_INFO', will not result in an out-of-bounds read or misinterpretation of header data. The primary validator for TRANSACTION2 responses, 'validate_t2', is called but its postconditions regarding the specific offset + sizeof(struct) are not known from the provided information, and the subsequent explicit BCC check is too weak.

#### 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 4989 |
| Taint snippet | `__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);` |
| Tainted var | `response_data` |
| Pointer deref | `response_data->BytesPerSector` line 4996 |
| Sink snippet | `le16_to_cpu(response_data->BytesPerSector) *` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from out-of-bounds read, BUG: KASAN: slab-out-of-bounds Read, or incorrect filesystem information leading to application errors or instability.

**Fix:** Before line 4993, add a bounds check for 'data_offset'. The check should verify both the lower and upper bounds for the 'FILE_SYSTEM_ALLOC_INFO' structure:
1. Lower bound: Ensure 'data_offset' is not too small, preventing it from pointing into the SMB or TRANSACTION2 header. E.g., 'data_offset >= MIN_DATA_OFFSET', where 'MIN_DATA_OFFSET' is the smallest valid offset past the `smb_t2_rsp` header and any parameter bytes.
2. Upper bound: Ensure 'data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO)' does not exceed the actual received length of the data payload. E.g., 'data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO) <= get_bcc(&pSMBr->hdr)'.

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

// Determine MIN_DATA_OFFSET based on the actual SMB1/TRANS2 response structure.
// This often means sizeof(struct smb_hdr) + sizeof(struct smb_t2_rsp_fixed_part) + ParameterCount*sizeof(parameter_type)
// For QFSInfo, DataOffset is relative to the start of the SMB header.
// Given the current code's use of '&pSMBr->hdr.Protocol' as base, and assuming 'get_bcc(&pSMBr->hdr)' is the total payload length after 'Protocol':
// MIN_DATA_OFFSET should be the offset from &pSMBr->hdr.Protocol to where the FILE_SYSTEM_ALLOC_INFO struct is expected to begin.
// This typically means past the TRANSACTION2 response header and any parameters.
// For SMB_INFO_ALLOCATION, there are no parameters, so it should be past the t2 header's fixed part.
// The exact minimum offset needs to be confirmed from the protocol spec or C structure definitions.
// For example, if FILE_SYSTEM_ALLOC_INFO is expected to be right after the smb_t2_rsp header and its fields, then min_offset = offsetof(struct smb_t2_rsp, ByteCount) + sizeof(__le16) (assuming ByteCount is last field of t2 hdr) minus offset of Protocol.
// A simpler approach if DataOffset is truly relative to the *start* of the smb_hdr and get_bcc is total payload after smb_hdr:
unsigned int total_len_from_smb_hdr = sizeof(struct smb_hdr) + get_bcc(&pSMBr->hdr);
// ... and DataOffset points within this total_len_from_smb_hdr buffer

// Placeholder for specific MIN_DATA_OFFSET value (needs to be determined from struct layout)
const unsigned int MIN_EXPECTED_DATA_OFFSET = <calculate_from_protocol_spec>;

if (data_offset < MIN_EXPECTED_DATA_OFFSET ||
    data_offset + sizeof(FILE_SYSTEM_ALLOC_INFO) > get_bcc(&pSMBr->hdr)) { // Adjust get_bcc base if DataOffset is from pSMBr
    cifs_dbg(VFS, "Invalid data_offset %d or size %zu in QFSInfo response BCC %d\n",
             data_offset, sizeof(FILE_SYSTEM_ALLOC_INFO), get_bcc(&pSMBr->hdr));
    rc = -EINVAL;
    goto cleanup_smb;
}

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

Note: The calculation `((char *) &pSMBr->hdr.Protocol) + data_offset` implies `data_offset` is relative to `pSMBr->hdr.Protocol`. The `get_bcc(&pSMBr->hdr)` value is typically the length *after* the `smb_hdr`'s `Protocol` field (if `BCC` is truly at end of `hdr`). If `DataOffset` is protocol-specified as relative to `pSMBr` (start of SMB header), then the `response_data` calculation is wrong, and the bounds check base would need adjustment.

**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) provided as a `kvec` by the user (which the kernel treats as untrusted input). The `smb2_file_full_ea_info` structures within this buffer are processed in a loop, forming a linked list via `next_entry_offset`. The parsing logic fails to validate that the `ea` pointer (derived from `next_entry_offset`) remains within the bounds of the original user-supplied `xattr_iov` buffer, leading to potential OOB reads when accessing subsequent `ea` entries. Additionally, the `ea_name_length` and `ea_value_length` fields, also user-supplied, are used to calculate source addresses and sizes for a `memcpy` operation in `CIFSSMBSetEA` without ensuring they remain within the bounds of the current `ea` entry or the overall `xattr_iov` buffer. The internal checks in `CIFSSMBSetEA` pertain to the outgoing SMB message size, not the integrity of the input buffer, and thus do not mitigate these input validation issues.

#### 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 3178 |
| Taint snippet | `ea = (struct smb2_file_full_ea_info *)((u8 *)ea +` |
| Tainted var | `ea` |
| Pointer deref | `ea->next_entry_offset` line 3179 |
| Sink snippet | `le32_to_cpu(ea->next_entry_offset));` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., BUG: KASAN: slab-out-of-bounds Read) or information disclosure if reading kernel memory outside the intended buffer. If `xattr_iov->iov_base` points to user memory, an EFAULT could occur.

**Fix:** The loop iterating through `smb2_file_full_ea_info` entries needs robust bounds checking. Before the loop, the initial `ea` pointer must be validated against `xattr_iov->iov_len`. Inside the loop, a `current_offset` variable (initialized appropriately for the start of `ea`) should be maintained.
1. Before `ea->next_entry_offset` is read (and before any other `ea` field is accessed): Validate that `current_offset + sizeof(struct smb2_file_full_ea_info)` does not exceed `xattr_iov->iov_len`.
2. After reading `next_offset_val = le32_to_cpu(ea->next_entry_offset)`: Validate that `next_offset_val` is non-zero, at least `sizeof(struct smb2_file_full_ea_info)` (to prevent entries from overlapping with the current header), and that `current_offset + next_offset_val` does not exceed `xattr_iov->iov_len`. If any of these conditions are not met, return `-EINVAL` and `goto out_close`.

Counterexample: `xattr_iov->iov_base` is 0x1000, `xattr_iov->iov_len` is 10 bytes. The first `ea` (at 0x1000) has `ea->next_entry_offset` at offset 0. Let's say `sizeof(struct smb2_file_full_ea_info)` is 8 bytes. Accessing `ea->next_entry_offset` is okay. User supplies `ea->next_entry_offset = 5`. The `ea` pointer is advanced to `0x1000 + 5 = 0x1005`. In the next iteration, accessing `ea->next_entry_offset` (at `0x1005 + 0 = 0x1005`) is still technically in bounds (0x1005 < 0x100a). However, if the `smb2_file_full_ea_info` struct requires 8 bytes, reading the *entire* struct at 0x1005 would be an OOB read (0x1005 + 8 = 0x100d, exceeding 0x1009). The fix must ensure `current_ea_ptr + sizeof(*ea)` remains within `xattr_iov->iov_base + xattr_iov->iov_len` before any field access.

**CVE pattern:** CVE-2022-NNNN style list traversal OOB read (next_entry_offset)


#### 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 3166 |
| Taint snippet | `rc = CIFSSMBSetEA(xid,` |
| Tainted var | `le16_to_cpu(ea->ea_value_length)` |
| Call site | line 3166 — passes `le16_to_cpu(ea->ea_value_length)` to `CIFSSMBSetEA()` |
| Call snippet | `rc = CIFSSMBSetEA(xid,` |
| Sink (in callee) | `memcpy()` line 6446 (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 (e.g., BUG: KASAN: slab-out-of-bounds Read) or information disclosure due to `memcpy` reading beyond the user-supplied `xattr_iov` buffer. If `xattr_iov->iov_base` points to user memory, an EFAULT could occur.

**Fix:** Before calling `CIFSSMBSetEA` (within the loop):
1. Retrieve `name_len = ea->ea_name_length` and `value_len = le16_to_cpu(ea->ea_value_length)`.
2. Calculate the total data size that will be read for this EA entry: `required_data_len = name_len + 1 /* for NUL terminator assumed by strscpy */ + value_len`.
3. Validate that the source address for the `memcpy` plus the `required_data_len` does not exceed the bounds of the original `xattr_iov` buffer. The source address is effectively `((u8 *)ea) + offsetof(struct smb2_file_full_ea_info, ea_data) + name_len + 1`. So, `((u8 *)ea) + offsetof(struct smb2_file_full_ea_info, ea_data) + required_data_len` must be less than or equal to `((u8 *)xattr_iov->iov_base) + xattr_iov->iov_len`. If this condition is not met, return `-EINVAL` and `goto out_close`.

Counterexample: `xattr_iov->iov_base` is 0x1000, `xattr_iov->iov_len` is 100 bytes. The current `ea` is at 0x1000. `sizeof(smb2_file_full_ea_info)` (fixed part) is 8 bytes. User-supplied `ea->ea_name_length = 5` (at 0x1004). User-supplied `ea->ea_value_length = 100` (at 0x1006). `CIFSSMBSetEA` is called. `ea_value` argument to `memcpy` is `&ea->ea_data[ea->ea_name_length+1]`, which is `0x1000 + 8 + 5 + 1 = 0x100E`. The `memcpy` attempts to read `100` bytes from `0x100E`, covering up to `0x100E + 100 - 1 = 0x1071`. This is within the 100-byte buffer (`0x1000` to `0x1063`).
Let's refine the counterexample:
`xattr_iov->iov_base` = `0x1000`, `xattr_iov->iov_len` = `20`.
`ea` = `0x1000`. `sizeof(fixed_fields)` = `8` bytes.
`ea->ea_name_length` = `0`.
`ea->ea_value_length` = `15` (`0x000F`).
`ea_value` argument will be `((u8*)ea) + 8 + 0 + 1 = 0x1009`. `ea_value_len` is 15.
`memcpy(..., 0x1009, 15)` attempts to read up to `0x1009 + 15 - 1 = 0x1017`. However, the buffer ends at `0x1000 + 20 - 1 = 0x1013`. This results in an OOB read of 4 bytes (`0x1014` to `0x1017`).

**CVE pattern:** CVE-2022-NNNN style memcpy size from tainted field



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

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

> The function `cifs_query_reparse_point` attempts to parse an `NT_TRANSACT_RSP` response. The parsing logic exhibits multiple flaws:
1. **Type Confusion / OOB Read:** At line 3075, `io_rsp->ReturnedDataLen` is accessed. However, `io_rsp` is defined as `TRANSACT_IOCTL_RSP` which is typedef'd to `NT_TRANSACT_RSP`. The `NT_TRANSACT_RSP` structure does not contain a `ReturnedDataLen` field. This access is an Out-of-Bounds read, likely interpreting data past the `ByteCount` field as `ReturnedDataLen` or even going beyond the `io_rsp` buffer. This is a severe bug preceding the analyzed finding.
2. **Missing Minimum Buffer Size Check:** The function implicitly assumes the received `io_rsp` buffer is large enough to contain the full `NT_TRANSACT_RSP` fixed header (80 bytes). If `io_rsp_len` (the actual size of the received buffer) is less than 80, then fields like `io_rsp->DataOffset`, `io_rsp->DataCount`, and `io_rsp->ByteCount` (via `get_bcc`) are read OOB. This is a critical precondition that is not explicitly validated.

The specific finding below relates to the interpretation of `data_offset` after `io_rsp->DataOffset` has been (potentially OOB) read. Assuming the `io_rsp` buffer is large enough for its fixed header (i.e., `io_rsp_len >= 80`), the finding about `buf->ReparseDataLength` is still a real bug due to a missing lower bound check on `data_offset`.

#### 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 3054 |
| Taint snippet | `data_offset = le32_to_cpu(io_rsp->DataOffset);` |
| Tainted var | `buf` |
| Pointer deref | `buf->ReparseDataLength` line 3094 |
| Sink snippet | `data_count < le16_to_cpu(buf->ReparseDataLength) + len) {` |
| Possibly guarded | no |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Incorrect parsing of SMB response, leading to logical errors; potentially incorrect reparse point handling or further OOB access if misread length values are later used; kernel panic or corrupted data.

**Fix:** Add a lower bound check for `data_offset` before `buf` is assigned. The `data_offset` (derived from `io_rsp->DataOffset`) must be at least the size of the `NT_TRANSACT_RSP` fixed header, i.e., `offsetof(NT_TRANSACT_RSP, ByteCount) + sizeof(__le16)`. A check like `if (data_offset < sizeof(NT_TRANSACT_RSP_FIXED_HDR))` should be added at or before line 3082. This ensures `start` points to the actual data payload section, not into the SMB header.

Additionally, the function should explicitly validate `io_rsp_len >= sizeof(NT_TRANSACT_RSP_FIXED_HDR)` at the beginning to prevent OOB reads of `io_rsp`'s fixed fields.

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



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

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

> The function `cifs_to_posix_acl` calculates the total expected size (`size`) for the ACL structure, including the header, all access control entries (ACEs), and all default ACEs, based on the server-supplied counts (`access_entry_count`, `default_entry_count`). It then compares this calculated `size` against the actual received buffer length (`size_of_data_area`) in a single check (`if (size_of_data_area < size)`). The pointer `pACE` is initialized to the start of the default ACEs (after the access ACEs) and then iterated. This starting address and all subsequent accesses within the loop are covered by the overarching size validation.

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

| Field | Value |
|---|---|
| Category | Cat C — server value → array subscript |
| Taint source | `le16_to_cpu()` line 3361 |
| Taint snippet | `count = le16_to_cpu(cifs_acl->access_entry_count);` |
| Tainted var | `count` |
| Subscript | `[]` line 3365 |
| 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)* |

*Dismissed:* The `count` variable at line 3361 is `cifs_acl->access_entry_count`, which is server-supplied. The sink at line 3365 `pACE = &cifs_acl->ace_array[count];` calculates the starting address for the default ACEs, which immediately follow the access ACEs. The `size` variable at line 3363 is `sizeof(struct cifs_posix_acl) + count * sizeof(struct cifs_posix_ace)`, which corresponds to the byte offset of `pACE` relative to `cifs_acl`. The `size` is subsequently updated at line 3367 to include `default_entry_count`. The check `if (size_of_data_area < size)` at line 3369 ensures that the *total* advertised size (including the header, all access ACEs, and all default ACEs) fits within the actual received `size_of_data_area`. If `access_entry_count` were maliciously large, `size` would become large, causing the check at line 3369 to trigger and return -EINVAL, preventing any OOB access. This means the pointer `pACE` at line 3365 (and its subsequent dereferences within the loop) is guaranteed to be within bounds if the function proceeds. 

Counterexample test:
Assume `sizeof(struct cifs_posix_acl) = 8`, `sizeof(struct cifs_posix_ace) = 4`.

Case 1: `size_of_data_area = 30` (actual buffer is 30 bytes).
   `cifs_acl->access_entry_count = 5`.
   `size = 8 + (4 * 5) = 28` (at line 3363).
   `pACE = &cifs_acl->ace_array[5];` (points to `cifs_acl + 28`).
   `cifs_acl->default_entry_count = 3`.
   `size = 28 + (4 * 3) = 40` (at line 3367).
   `if (size_of_data_area < size)` evaluates to `if (30 < 40)`, which is true. The function returns -EINVAL, preventing any potential OOB read.

Case 2: `size_of_data_area = 40` (actual buffer is 40 bytes).
   `cifs_acl->access_entry_count = 5`.
   `size = 8 + (4 * 5) = 28`.
   `pACE = &cifs_acl->ace_array[5];` (points to `cifs_acl + 28`).
   `cifs_acl->default_entry_count = 3`.
   `size = 28 + (4 * 3) = 40`.
   `if (size_of_data_area < size)` evaluates to `if (40 < 40)`, which is false. The function proceeds. The `FOREACH_ACL_ENTRY` loop will access `pACE` at offsets `cifs_acl + 28`, `cifs_acl + 32`, and `cifs_acl + 36`. All these are within the 40-byte `size_of_data_area`.

The SMT result indicates the index is non-negative, which is correct for `__u16` and not the core issue for array bounds here. The overall validation logic is sufficient.



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

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

> The function copies encryption keys from kernel-internal buffers to a user-provided buffer. While the user-provided buffer size (`out.in_size`) is correctly validated against the total intended kernel output size (header + all keys), the size arguments for the individual `copy_to_user` operations for the keys themselves (`out.session_key_length`, `out.server_in_key_length`, `out.server_out_key_length`) are derived from server-negotiated cipher types. These derived lengths can exceed the actual capacity of the kernel's fixed-size source buffers (`ses->auth_key.response`, `ses->smb3encryptionkey`, `ses->smb3decryptionkey`), leading to kernel-side Out-of-Bounds reads.

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

| 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 |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., KASAN report) due to reading past the end of `ses->auth_key.response` into adjacent kernel memory, or information disclosure if the memory is readable.

**Fix:** Increase the size of `ses->auth_key.response` in `struct cifs_auth_key` to `CIFS_SESS_KEY_SIZE` (32 bytes), or ensure that the copy size is `min(out.session_key_length, sizeof(ses->auth_key.response))` for this specific key.

**CVE pattern:** kernel OOB read


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

| 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 |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., KASAN report) due to reading past the end of `ses->smb3encryptionkey` into adjacent kernel memory, or information disclosure if the memory is readable.

**Fix:** Increase the size of `ses->smb3encryptionkey` in `struct cifs_ses` to `SMB3_GCM256_CRYPTKEY_SIZE` (32 bytes), or ensure that the copy size is `min(out.server_in_key_length, sizeof(ses->smb3encryptionkey))` for this specific key.

**CVE pattern:** kernel OOB read


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

| 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 |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Kernel panic (e.g., KASAN report) due to reading past the end of `ses->smb3decryptionkey` into adjacent kernel memory, or information disclosure if the memory is readable.

**Fix:** Increase the size of `ses->smb3decryptionkey` in `struct cifs_ses` to `SMB3_GCM256_CRYPTKEY_SIZE` (32 bytes), or ensure that the copy size is `min(out.server_out_key_length, sizeof(ses->smb3decryptionkey))` for this specific key.

**CVE pattern:** kernel OOB read



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

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

> The function `parse_dfs_referrals` performs robust bounds checking for server-supplied offsets (`DfsPathOffset`, `NetworkAddressOffset`) and lengths (`PathConsumed`). It correctly calculates remaining buffer sizes (`max_len`) and passes them to helper functions. The helper functions (`cifs_utf16_bytes`, `cifs_strndup_from_utf16`) respect these provided length limits, preventing out-of-bounds reads and ensuring allocation sizes are bounded by the actual received buffer size and character set conversion factors.

#### 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 (server-supplied) is validated at line 763: `if (path_consumed > search_name_utf16_len) { rc = -EINVAL; ... }`. This ensures `path_consumed` does not exceed the size of the `tmp` buffer allocated for the UTF-16 version of `searchName`. When `path_consumed` is passed as `maxbytes` to `cifs_utf16_bytes`, `cifs_utf16_bytes` calculates `maxwords = maxbytes / 2`. Its internal loop (`for (i = 0; i < maxwords; i++)`) and conditional look-aheads (`if (i + 1 < maxwords)`, `if (i + 2 < maxwords)`) ensure that all accesses (`get_unaligned_le16(&from[i])`, `&from[i+1]`, `&from[i+2]`) remain within the `maxwords` limit. Since `maxwords` is bounded by the allocated size of `tmp` (in words), no out-of-bounds read occurs. Counterexample test: `searchName='A'`, `search_name_utf16_len=4` (2 words). If `PathConsumed=4`, `path_consumed=4`. Guard `4 > 4` is false. `cifs_utf16_bytes(tmp, 4)` sets `maxwords=2`. Loop `i=0,1`. Accesses `from[0]`, `from[1]` are safe. `from[2]` is not accessed due to `i+2 < maxwords` check. No OOB.


#### 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 scanner's reason is misleading: `temp` (the source pointer) is not used as a 'size' argument to `kmalloc`. Instead, `temp` is passed as `src` to `cifs_strndup_from_utf16`, which then passes it to `cifs_utf16_bytes` as `from`. The `kmalloc` size (`len`) is derived from the *content* pointed to by `temp` (up to `max_len` bytes), not `temp` itself. The `temp` pointer is thoroughly validated at lines 791-792: `if (le16_to_cpu(ref->DfsPathOffset) < sizeof(*ref) || le16_to_cpu(ref->DfsPathOffset) > data_end - (char *)ref)`. This ensures `temp` points to a valid location within the `rsp` buffer, after the fixed header. `cifs_utf16_bytes` (as analyzed in finding #1) correctly uses the provided `maxlen` (derived from `max_len = data_end - temp`) to limit its reads from `temp`, preventing OOB reads. The `len` value returned by `cifs_utf16_bytes` is bounded by `(max_len / 2) * NLS_MAX_CHARSET_SIZE`, which is a reasonable allocation size bounded by the overall response buffer size. Counterexample test: `rsp_size=100`, `sizeof(*ref)=20`. If `DfsPathOffset=10`, it's caught by `10 < 20`. If `DfsPathOffset=90` (assuming `ref` starts at `rsp+10`, `data_end-ref=90`), it's caught by `90 > 90` (or `91 > 90`). Valid `DfsPathOffset` (e.g., 20) ensures `temp` is in bounds and `max_len` is correct. No OOB read from `temp` and `kmalloc` size is safe.


#### 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:* `max_len` is calculated as `data_end - temp`. As established in finding #2, `temp` is derived from `ref->DfsPathOffset` which is validated with both lower (`sizeof(*ref)`) and upper (`data_end - (char *)ref`) bounds. This guarantees that `temp` always points within the valid `rsp` buffer and `max_len` accurately represents the number of remaining bytes from `temp` to the end of the buffer. `max_len` is therefore always positive and bounded by the total `rsp_size`. When `max_len` is passed as `maxlen` to `cifs_strndup_from_utf16`, it is used by `cifs_utf16_bytes` to limit the number of bytes read from the source buffer (`temp`). The `kmalloc` size (`len`) is derived from the content within these `max_len` bounds and is capped by `(max_len / 2) * NLS_MAX_CHARSET_SIZE`. This prevents arbitrary inflation of the allocation size. Counterexample test: Same as finding #2. `max_len` is always a safe, positive value representing the remaining buffer. No OOB read or excessive allocation.



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

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

> The function `cnvrtDosUnixTm` parses DOS date and time fields, which are server-supplied. The `month` field extracted from the `SMB_DATE` structure is checked and clamped before being used as an array index. This ensures the index is always within valid bounds.

#### 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 the server-supplied `le_date` (line 167, 180). However, before it is used as an array index at line 187 (`total_days_of_prev_months[month]`), there's an explicit validation and clamping step:
```c
181:	if (day < 1 || day > 31 || month < 1 || month > 12) {
182:		cifs_dbg(VFS, "Invalid date, month %d day: %d\n", month, day);
183:		day = clamp(day, 1, 31);
184:		month = clamp(month, 1, 12);
185:	}
```
This block ensures that after line 184, `month` is guaranteed to be in the range `[1, 12]`. Subsequently, at line 186, `month -= 1;` is performed. This operation transforms the `month` value from `[1, 12]` to `[0, 11]`, which is the standard 0-indexed range for months, perfectly matching the expected indices for an array like `total_days_of_prev_months` (assuming it has 12 elements for months 0-11).

Counterexample test:
- If `sd->Month` yields `0`: `month < 1` is true. `month = clamp(0, 1, 12)` sets `month` to 1. Then `month -= 1` sets `month` to 0. `total_days_of_prev_months[0]` is valid.
- If `sd->Month` yields `13`: `month > 12` is true. `month = clamp(13, 1, 12)` sets `month` to 12. Then `month -= 1` sets `month` to 11. `total_days_of_prev_months[11]` is valid.
- If `sd->Month` yields `6`: Neither condition is true. `month` remains 6. Then `month -= 1` sets `month` to 5. `total_days_of_prev_months[5]` is valid.

In all cases, `month` is constrained to `[0, 11]` before array access, making the bounds check sufficient.



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

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

> The function `mknod_wsl` is responsible for creating a special file (symlink or other reparse point) on an SMB share. This means it is constructing a *request* to be sent to the server, rather than parsing a *response* received from the server. The helper functions `wsl_set_reparse_buf` and `wsl_set_xattrs` are used to build the data structures for this request. Therefore, any values read back from these locally-constructed structures via `le32_to_cpu` are round-tripping kernel-supplied values, not server-supplied values. This pattern is explicitly described as a common false positive in the prompt's guidelines (point 1).

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 taint source `len = le32_to_cpu(cc->ctx.DataLength);` is a false positive for server-supplied taint. `cc` (of type `smb2_create_ea_ctx`) is a structure built locally by the kernel via `wsl_set_xattrs`. This function constructs the extended attributes for a request to be sent to the server. Therefore, `cc->ctx.DataLength` is a value the kernel itself wrote (likely via `cpu_to_le32(some_kernel_controlled_length)`), not a value received from the server. The `le32_to_cpu` is merely reversing the endianness conversion applied by the kernel itself. As `len` is a kernel-controlled value, the kernel is responsible for ensuring its correctness and consistency with the allocated buffers for `&cc->ea` (source) and `data.wsl.eas` (destination). No counterexample can be constructed where a *server-supplied* `len` causes an OOB, as `len` is not server-supplied. The `memcpy` is an internal kernel-to-kernel data movement of a known size.


#### 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:* This finding reports a cross-function taint from `le32_to_cpu(buf->ReparseTag)` to the size argument of `memset()` in `cifs_free_open_info()`. 
1.  **Taint origin**: Similar to Finding #1, `buf` (of type `reparse_data_buffer`) is constructed locally by the kernel via `wsl_set_reparse_buf` for a request. Thus, `buf->ReparseTag` is a kernel-supplied value (e.g., `cpu_to_le32(IO_REPARSE_TAG_SYMLINK)`) that is being round-tripped. Therefore, `data.reparse.tag` is not server-supplied.
2.  **Sink analysis**: The scanner incorrectly identifies `data` as being used as the 'size' argument for `memset()`. The sink snippet is `memset(data, 0, sizeof(*data));`. The third argument to `memset` is `sizeof(*data)`, which is a compile-time constant representing the size of `struct cifs_open_info_data`. It is not derived from any runtime value within `data` and is not tainted. This `memset` operation is always safe as it clears the entire structure using its known compile-time size. No counterexample can cause an OOB.



### <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 a server-supplied reparse point buffer. It relies on internal length fields (`ReparseDataLength`) within nested structures without validating these lengths against the actual received buffer size. This leads to unbounded reads when processing variable-length fields, specifically symlink target paths.

#### 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 (KASAN report) due to out-of-bounds read in `UniStrnlen` or `cifs_utf16_bytes` when processing a maliciously crafted reparse point buffer. Could also lead to excessive memory allocation requests (DoS) or heap corruption if the OOB read goes undetected and influences subsequent operations.

**Fix:** The `parse_reparse_nfs` function, or its caller `parse_reparse_point`, must validate the server-supplied `ReparseDataLength` fields against the actual buffer size received from the network. Specifically:
1. In `parse_reparse_point`, determine the actual length of the `reparse_data_buffer->DataBuffer` segment (let's call it `actual_nfs_payload_len`) by taking the minimum of `plen - offsetof(struct reparse_data_buffer, DataBuffer)` and `le16_to_cpu(buf->ReparseDataLength)` from the top-level `reparse_data_buffer`.
2. Pass this `actual_nfs_payload_len` into `parse_reparse_nfs` as a new parameter (e.g., `max_len`).
3. Inside `parse_reparse_nfs`, after reading `len = le16_to_cpu(buf->ReparseDataLength)` (line 758), add a check: `if (len + sizeof(buf->ReparseDataLength) > max_len) return -EIO;`. This ensures the declared internal length of the `reparse_nfs_data_buffer` structure does not exceed the actual buffer available to `parse_reparse_nfs`.
4. The existing checks on `len` and subsequent operations (like `UniStrnlen` and `cifs_strndup_from_utf16`) will then operate within the validated bounds.

**CVE pattern:** Missing bounds check for server-supplied length field leading to OOB read



### <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

> Both findings stem from arithmetic operations on `ReparseDataLength`, which is read as a `u16` (`le16_to_cpu`). The maximum value this can hold is 0xFFFF (65535). Subsequent multiplications by small constants (e.g., 2 for UTF-8 to UTF-16 conversion, or a maximum NLS character expansion factor of ~3-4 for UTF-16 to UTF-8) result in allocation sizes that are well within the limits of `int` and `size_t` types (typically 32-bit and 64-bit respectively) and also within typical `kmalloc` maximum allocation limits (e.g., a few hundred KB). While `kmalloc` could still return -ENOMEM under extreme memory pressure for these sizes, this is a resource exhaustion scenario rather than an integer overflow leading to an undersized allocation, or a direct memory corruption vector.

#### 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 `ReparseDataLength` (assigned to `len`) is read as a `u16` from the server. Thus, its maximum value is 0xFFFF (65535). `symname_utf8_len` is derived as `len - data_offset`. `data_offset` is a constant (calculated to be 4, as `sizeof(Version)`). So, `symname_utf8_len` can be at most `0xFFFF - 4 = 65531`. The sink `kzalloc` receives `symname_utf8_len * 2`. This calculation would be `65531 * 2 = 131062`. This value fits comfortably within a 32-bit signed integer (max ~2*10^9) and `size_t` (typically 64-bit). There is no integer overflow for this multiplication, and the resulting allocation size (approx 128KB) is a legitimate size for `kzalloc` (though it may fail with -ENOMEM under resource contention, this is not an 'undersized allocation' security vulnerability). Tested counterexample: `buf->ReparseDataLength = 0xffff`. `len = 65535`. `data_offset = 4`. `symname_utf8_len = 65531`. `symname_utf8_len * 2 = 131062`. This value is correctly handled and does not cause overflow.


#### 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` argument to `cifs_strndup_from_utf16` is derived from `ReparseDataLength` (max 0xFFFF). The initial `kzalloc` (Finding #1) creates a buffer of max 131062 bytes for `symname_utf16`. `symname_utf16_len` is then the actual byte length of the UTF-16 string converted from UTF-8, which is bounded by the size of this `kzalloc`'d buffer (max 131062 bytes). Inside `cifs_strndup_from_utf16`, this `symname_utf16_len` (passed as `maxlen`) is used to calculate the final allocation `len` via `cifs_utf16_bytes`. `cifs_utf16_bytes` iterates over the `maxlen` bytes of UTF-16 input and determines the required length in the local NLS codepage. While the NLS conversion can cause some expansion (e.g., UTF-16 to UTF-8 might expand by a factor of up to ~3-4 for some characters), this maximum `len` (e.g., `(131062 / 2) * 4 = 262124` bytes plus null terminator) is still well within `int` and `size_t` limits and is a valid allocation size for `kmalloc`. There is no integer overflow in the `len` calculation or `kmalloc` argument. Tested counterexample: Following the chain from `ReparseDataLength = 0xffff`, `symname_utf8_len = 65531`. `symname_utf16` allocated for `131062` bytes. Assuming conversion to UTF-16 results in `131062` bytes of valid UTF-16 data, `symname_utf16_len` (passed as `maxlen`) is `131062`. If `cifs_utf16_bytes` converts this to UTF-8 with a max 1:4 expansion, `len` could be `(131062 / 2) * 4 = 262124` bytes. Adding null terminator, `262125` bytes. This is a legitimate `kmalloc` size, not an overflow or undersized allocation.



### <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 an SMB_COM_NT_TRANSACT response, which contains a DataOffset field (server-supplied). This DataOffset is used to calculate a pointer `pnotify` into the received buffer. The validation logic for `data_offset` is insufficient, leading to both potential out-of-bounds reads and misinterpretation of header data as payload.

#### 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, info_disclosure (misinterpretation of header data in logs)

**Fix:** Add a lower-bound check for `data_offset` to ensure it points past the fixed-size transaction header. Correct the upper-bound check to account for the base pointer offset. Specifically:
1. Add a check `if (data_offset < <minimum_expected_offset_from_protocol_field>) return true;` where `<minimum_expected_offset_from_protocol_field>` is the size of the fixed `smb_com_transaction_change_notify_rsp` header fields *after* `hdr.Protocol` (e.g., around 49 bytes if `DataOffset` is relative to `hdr.Protocol`).
2. Modify the existing upper-bound check to `if (4 + data_offset > len - sizeof(struct file_notify_information)) return true;` (to properly include the `+4` from `&pSMBr->hdr.Protocol` in the buffer boundary check).

**CVE pattern:** SMB DataOffset OOB



### <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 static analysis findings flag `le32_to_cpu(ea->next_entry_offset)` as a taint source. However, `ea` points into `data->wsl.eas`, which is a locally allocated and zero-initialized buffer (`struct cifs_open_info_data query_data = {};`). The `next_entry_offset` field within `struct smb2_file_full_ea_info` is either zero-initialized or written by the kernel using locally defined constant values (e.g., `SMB2_WSL_XATTR_NAME_LEN`, `SMB2_WSL_XATTR_MODE_SIZE`). Therefore, the values used for pointer arithmetic are locally controlled, not server-supplied. This falls under false positive pattern #1.

#### 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 `data->wsl.eas` buffer is locally allocated and zero-initialized. The `do-while` loop at lines 657-660 terminates immediately because `ea->next_entry_offset` is 0. Consequently, the `if (le16_to_cpu(ea->ea_value_length))` condition at line 661 evaluates to false, as `ea->ea_value_length` is also 0. Therefore, the code block containing the flagged taint source at line 665 is unreachable. Even if it were reached, the value written to `ea->next_entry_offset` at line 662 is derived from local constants or zero-initialized fields, making it locally controlled, not server-supplied.


#### 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:* Same as finding #1. The code path to the taint source at line 665 and its subsequent sink at line 676 is unreachable due to zero-initialization of the `data->wsl.eas` buffer and an early conditional check (line 661).


#### 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 `ea` pointer here refers to an EA entry that was previously populated with constant values in lines 671-678 (e.g., `ea->next_entry_offset = cpu_to_le32(0);`, `ea->ea_name_length = SMB2_WSL_XATTR_NAME_LEN;`, `ea->ea_value_length = cpu_to_le16(SMB2_WSL_XATTR_MODE_SIZE);`). The `do-while` loop at lines 702-705 finds this entry and `ea` points to it. The `if (le16_to_cpu(ea->ea_value_length))` condition at line 707 is true because `ea->ea_value_length` was set to a constant `SMB2_WSL_XATTR_MODE_SIZE`. At line 708, `ea->next_entry_offset` is *assigned* a new value computed using local constants. The `le32_to_cpu()` at line 711 then reads this locally computed constant. Thus, the value used for pointer arithmetic to advance `ea` is locally controlled and not server-supplied.


#### 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:* Same as finding #3. The pointer advancement at line 711 is based on a locally computed constant value. Therefore, the subsequent `memcpy()` at line 722, which uses this advanced `ea` pointer, is not affected by server-supplied taint in this context.



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

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

> The function `sess_auth_kerberos` receives an SMB response and processes variable-length data following a security blob. The total length of variable data is determined by `get_bcc(smb_buf)` and the security blob length by `pSMB->resp.SecurityBlobLength`. A critical validation at line 628 (`if (blob_len > bytes_remaining)`) ensures that the reported security blob length does not exceed the total available variable data. The remaining bytes and pointer are then passed to `decode_ascii_ssetup` (or `decode_unicode_ssetup`). The `decode_ascii_ssetup` function uses `strnlen` with the remaining buffer size (`bleft`) as its limit, and an additional check (`if (len >= bleft)`) handles cases where a null terminator is not found within the expected bounds. This validation chain effectively prevents out-of-bounds access.

#### 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 scanner incorrectly flags `bcc_ptr` as having the role of `size_mul_overflow` for `kmalloc` and `memcpy`. `bcc_ptr` is the base pointer for string operations in `decode_ascii_ssetup()`, not a size. The actual size `len` is derived from `strnlen(bcc_ptr, bleft)`, where `bleft` (derived from server-supplied `bytes_remaining`) correctly limits the string length scan. A subsequent check `if (len >= bleft)` (line 265 in `decode_ascii_ssetup()`) ensures that if `strnlen` consumes all `bleft` bytes without finding a null terminator, the function returns early, preventing `kmalloc(bleft + 1)` and subsequent potential OOB write (`ses->serverOS[bleft] = 0`). The `memcpy` also uses this safe `len`. Thus, the operations are sufficiently guarded by the callee's logic. Counterexample values: `get_bcc(smb_buf) = 100`, `pSMB->resp.SecurityBlobLength = 10` (so `bytes_remaining = 90`). If `bcc_ptr` points to 90 bytes of 'A' characters (no null), `strnlen` returns 90. The condition `if (90 >= 90)` is true, and the function returns, avoiding OOB. If `bcc_ptr` points to 'A','B','C','\0',..., `strnlen` returns 3. `if (3 >= 90)` is false. `kmalloc(3+1)` is safe, `memcpy(..., 3)` is safe, `ses->serverOS[3]=0` is safe.


#### 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:* The `bytes_remaining` variable is indeed server-supplied (derived from `get_bcc(smb_buf)` and `pSMB->resp.SecurityBlobLength`). This value is passed as `bleft` to `decode_ascii_ssetup()`. Inside `decode_ascii_ssetup()`, `bleft` is correctly used as the maximum length argument for `strnlen(bcc_ptr, bleft)`. The resulting `len` (string length) is then used for `kmalloc(len + 1)` and `memcpy(..., len)`. The explicit check `if (len >= bleft)` (line 265 in `decode_ascii_ssetup()`) is crucial: if `strnlen` returns `bleft` (indicating no null terminator was found within the available `bleft` bytes), the function returns, preventing an OOB allocation (`bleft + 1`) and subsequent write (`ses->serverOS[bleft] = 0`). Otherwise, if `len < bleft`, the string is null-terminated within the buffer, and `len + 1` bytes are safely allocated and copied. The overall validation chain from `sess_auth_kerberos` and within `decode_ascii_ssetup` is sufficient. Counterexample values: same as Finding #1. The validation in `decode_ascii_ssetup` is robust for all string lengths up to `bleft`.



### <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 `sess_auth_rawntlmssp_authenticate` function processes a server-supplied SMB response. Fields like `get_bcc(smb_buf)` (Byte Count) and `pSMB->resp.SecurityBlobLength` are derived from this response and are therefore server-controlled. The function performs an initial bounds check on `blob_len` against `bytes_remaining` (derived from BCC). The remaining `bcc_ptr` and `bytes_remaining` (which becomes `bleft`) are passed to `decode_ascii_ssetup` for parsing string fields (serverOS, serverNOS). The `decode_ascii_ssetup` function includes robust internal validation using `strnlen` and a subsequent check (`if (len >= bleft)`). This internal validation ensures that any allocations (`kmalloc`) and copies (`memcpy`) based on the extracted string lengths (`len`) are correctly bounded by the provided `bleft` value, which itself is already validated against the SMB message's byte count. The return guard `if (len >= bleft)` prevents any operations if a null terminator is not found within the specified `bleft`, effectively treating such strings as invalid or empty for allocation purposes. This makes the operations safe.

#### 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 `bcc_ptr` is initially derived from `pByteArea(smb_buf)` and then advanced by `blob_len`. Both `get_bcc(smb_buf)` (which initializes `bytes_remaining`) and `blob_len` (`le16_to_cpu(pSMB->resp.SecurityBlobLength)`) are server-supplied. A critical check `if (blob_len > bytes_remaining)` at line 880 ensures that the `blob_len` (used to advance `bcc_ptr` and reduce `bytes_remaining`) does not exceed the total available bytes from the server's `BCC`. The `bcc_ptr` parameter to `decode_ascii_ssetup` is therefore guaranteed to point within the valid server response buffer, and the remaining `bleft` (`bytes_remaining`) is a correct representation of the maximum readable bytes. Inside `decode_ascii_ssetup`, `len = strnlen(bcc_ptr, bleft)` correctly caps `len` to `bleft`. The subsequent `if (len >= bleft)` check (line 265) ensures that if a null terminator is not found within `bleft` bytes (meaning `len == bleft`), the function returns, preventing any allocation or copy. If `len < bleft`, then `kmalloc(len + 1)` allocates exactly `len` bytes for the string plus a null terminator, and `memcpy(ses->serverOS, bcc_ptr, len)` copies `len` bytes. Both operations are safe under these conditions. The integer addition `len + 1` does not overflow `size_t` as `len` is capped by `__u16_MAX`.


#### 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:* This finding tracks the taint from `bytes_remaining` (which becomes `bleft` in `decode_ascii_ssetup`). The `bytes_remaining` value is server-influenced, derived from `get_bcc(smb_buf)` minus `blob_len`. The initial check `if (blob_len > bytes_remaining)` at line 880 is crucial for ensuring `bytes_remaining` remains a valid and non-negative length. This `bytes_remaining` (passed as `bleft`) correctly represents the maximum number of bytes that can be safely read from `bcc_ptr`. The internal validation in `decode_ascii_ssetup` (using `strnlen` to derive `len` within `bleft` bounds, and the `if (len >= bleft)` guard at line 265) makes the `kmalloc` and `memcpy` operations safe. The `kmalloc(len + 1)` and `memcpy(..., len)` only proceed if `len < bleft`, guaranteeing that enough memory is allocated and that the copy operation remains within the valid `bleft` bounds, and thus within the underlying server response buffer. No counterexample is possible where `kmalloc` is called with insufficient size relative to the subsequent `memcpy` or where `memcpy` reads OOB, given the internal checks.



### <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` merges two server-supplied SMB transaction 2 responses. It performs comprehensive bounds checks on both the source and destination buffers before performing a `memcpy`. Specifically, it checks that the calculated destination pointer (`data_area_of_tgt`) and the total length to be copied (`total_in_src`) fit within the target buffer's maximum allowed size, and that the pointer is past the fixed header. Similarly, it checks that the calculated source pointer (`data_area_of_src`) and `total_in_src` fit within the actual size of the source buffer (determined by `smbCalcSize`), and that the pointer is past the fixed header. These checks cover all parameters of the `memcpy` for potential out-of-bounds access.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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` variable, derived from `pSMBs->t2_rsp.DataCount` (server-supplied), is used as the size argument to `memcpy`. The code explicitly checks its bounds against both the source buffer (`second_buf`) and the destination buffer (`target_hdr`):
1.  **Source buffer check (OOB read):** Lines 395-400 check `data_area_of_src + total_in_src > second_buf + smbCalcSize((struct smb_hdr *)second_buf)`. `smbCalcSize` calculates the actual PDU length, providing a valid upper bound for `second_buf`. This ensures `total_in_src` does not cause an OOB read from `second_buf`.
2.  **Destination buffer check (OOB write):** Lines 388-394 check `data_area_of_tgt + total_in_src > (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE`. This ensures `total_in_src` does not cause an OOB write into `target_hdr`.

Counterexample test: 
-   If `total_in_src` is very large (e.g., 65535), `data_area_of_src + total_in_src` would likely exceed `second_buf + smbCalcSize(...)`, triggering the check at line 397 and returning `-EPROTO`.
-   Similarly, `data_area_of_tgt + total_in_src` would likely exceed `(char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE`, triggering the check at line 391 and returning `-EPROTO`.
Both bounds are correctly checked.


#### 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` (server-supplied). It is used as the destination pointer for `memcpy`. Lines 388-394 provide comprehensive bounds checking for this pointer:
1.  **Lower bound check:** `data_area_of_tgt < (char *)target_hdr + sizeof(struct smb_t2_rsp) + sizeof(__le16)` ensures that `data_area_of_tgt` points past the fixed-size header of the `target_hdr` structure, preventing it from overwriting critical header fields. This addresses missing lower-bound check issues.
2.  **Upper bound check:** `data_area_of_tgt + total_in_src > (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE` ensures that the starting address of the copy, combined with its length, does not exceed the overall capacity of the `target_hdr` buffer.

Counterexample test:
-   If `DataOffset` from `pSMBt->t2_rsp.DataOffset` is 0, `data_area_of_tgt` would point to `&pSMBt->hdr.Protocol + total_in_tgt`. The lower bound check at line 388 would catch this if `data_area_of_tgt` is less than the fixed header length, returning `-EPROTO`.
-   If `DataOffset` is excessively large (e.g., beyond `CIFSMaxBufSize`), then `data_area_of_tgt` would cause the upper bound check at line 391 to trigger, returning `-EPROTO`.


#### 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` (server-supplied). It is used as the source pointer for `memcpy`. Lines 395-400 provide comprehensive bounds checking for this pointer:
1.  **Lower bound check:** `data_area_of_src < second_buf + sizeof(struct smb_t2_rsp) + sizeof(__le16)` ensures that `data_area_of_src` points past the fixed-size header of the `second_buf` structure, preventing attempts to read from header fields as if they were data. This addresses missing lower-bound check issues.
2.  **Upper bound check:** `data_area_of_src + total_in_src > second_buf + smbCalcSize((struct smb_hdr *)second_buf)` ensures that the starting address of the copy, combined with its length, does not exceed the actual received size of the `second_buf` (as calculated by `smbCalcSize`).

Counterexample test:
-   If `DataOffset` from `pSMBs->t2_rsp.DataOffset` is 0, `data_area_of_src` would point to `&pSMBs->hdr.Protocol`. The lower bound check at line 395 would catch this if `data_area_of_src` is less than the fixed header length, returning `-EPROTO`.
-   If `DataOffset` is excessively large (e.g., beyond the actual size of `second_buf`), then `data_area_of_src` would cause the upper bound check at line 397 to trigger, returning `-EPROTO`.



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

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

> The function performs comprehensive bounds checking for the `smb2_error_context_rsp` structures and their associated data. The `while` loop condition `(u8 *)p + sizeof(*p) <= end` ensures that the fixed header portion of the current `p` is entirely within the received buffer `iov`. Subsequent checks at lines 65 and 68 (`if (len > end - ((u8 *)p + sizeof(*p)))`) ensure that the variable-length `ErrorDataLength` (including padding/alignment) associated with the current context does not extend beyond the buffer's end. These combined checks guarantee that `p` and any derived pointers for the next iteration remain within the valid buffer bounds.

#### 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 pointer `p` (referring to `struct smb2_error_context_rsp`) is initialized from `err->ErrorData`, which itself is part of the server-supplied `smb2_err_rsp` structure. The `while` loop condition `(u8 *)p + sizeof(*p) <= end` (line 56) ensures that `p` itself, including the fixed-size fields like `ErrorDataLength` and the offset to `ErrorContextData`, is within the received buffer. Therefore, the reads of `p->ErrorDataLength` (line 64) and the address calculation of `p->ErrorContextData` (line 71) are safe. The subsequent checks at lines 65 and 68 (`if (len > end - ((u8 *)p + sizeof(*p)))`) validate that the `len` (derived from `p->ErrorDataLength` and aligned) does not cause the pointer `p` to advance beyond `end` for the next iteration. If these checks pass, `(u8 *)p + sizeof(*p) + len` (which becomes the new `p`) is guaranteed to be less than or equal to `end`. The next iteration's `while` loop condition will then re-validate the new `p`'s header against `end`. No counterexample can be constructed where `p->ErrorContextData` (as an address or part of the `+ len` calculation) causes an OOB access, as all relevant components are checked against the `end` pointer.



### <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 performs comprehensive bounds checking on the server-supplied EA data. It first validates the overall `OutputBufferLength` (outlen) and ensures the derived EA data block (`ea` to `ea_end`) fits within the received `rsp_iov` buffer. Inside the loop, it validates each `ea` entry's header (`sizeof(*ea)`), and critically, checks that the combined length of `ea_name_length`, a null terminator, and `ea_value_length` does not exceed `ea_end`. The `ea_name_length` (nlen) is also constrained to `SMB2_WSL_XATTR_NAME_LEN` by an explicit check, further securing `strncmp` calls. Pointer advancement (`next_entry_offset`) is guarded by `check_add_overflow` and the subsequent loop iteration's `sizeof(*ea)` check.

#### 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 `ea` pointer is derived from `rsp_iov->iov_base` and `rsp->OutputBufferOffset` (line 136). The total length of the EA data (`outlen`) is validated against min/max sizes (line 131) and the `ea_end` boundary is checked against the actual received buffer length `iov_end` (line 139): `if (ea_end > iov_end) return -EINVAL;`. This ensures that the entire EA block (`ea` to `ea_end`) is within `rsp_iov->iov_len`. Inside the loop, before dereferencing `ea`, there is a check `if ((u8 *)ea > ea_end - sizeof(*ea)) return -EINVAL;` (line 143). This guarantees that there is at least `sizeof(struct smb2_file_full_ea_info)` bytes available from the current `ea` pointer up to `ea_end`. Since `ea->ea_name_length` is a field within this fixed-size structure, its access is guaranteed to be within bounds. No counterexample is possible given these checks. For example, if `rsp_iov->iov_base=0x1000`, `iov_len=0x100`, `OutputBufferOffset=0x20`, `OutputBufferLength=0x50`, then `ea=0x1020`, `ea_end=0x1070`. `sizeof(*ea)` (fixed header) is small, let's say 9 bytes. Line 139 passes. In the loop, line 143 becomes `0x1020 > 0x1070 - 9` (i.e., `0x1020 > 0x1067`), which is false, so it passes. The access `ea->ea_name_length` at `0x1020 + offsetof(ea_name_length)` is safely within `0x1070`.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `le16_to_cpu()` line 146 |
| Taint snippet | `nlen = ea->ea_name_length;` |
| 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 `nlen` variable is `ea->ea_name_length` (line 146), which is server-supplied. It is used as the length argument in `strncmp()` at line 154. A crucial validation exists at line 148-149: `if (nlen != SMB2_WSL_XATTR_NAME_LEN || (u8 *)ea->ea_data + nlen + 1 + vlen > ea_end) return -EINVAL;`. This check ensures two things: 1) `nlen` must exactly match the expected constant `SMB2_WSL_XATTR_NAME_LEN` (e.g., 3 or 4 bytes for WSL xattr names), otherwise an error is returned. 2) If `nlen` matches, then the total size of the name, plus a null byte, plus the value length (`vlen`) must fit within the `ea_end` boundary. Because `nlen` is either rejected or validated to be a small constant length and to fit within `ea_end` (relative to `ea->ea_data`), the `strncmp()` operation will not read out of bounds. The SMT result of 'PROVED - negative' only states `nlen` cannot be negative, which is trivial for a `u8` type; the upper bound is handled by the explicit code check. For example, if `nlen=5` (and `SMB2_WSL_XATTR_NAME_LEN` is 3 or 4), the condition `nlen != SMB2_WSL_XATTR_NAME_LEN` would be true, leading to `-EINVAL` at line 149. If `nlen=3` and `ea->ea_data + 3 + 1 + vlen` would exceed `ea_end`, the check also catches it. Thus, no counterexample exists where `strncmp` reads OOB without the function returning an error.



### <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 operates on a server response buffer (rsp_iov). Critical validation is performed by the caller, smb2_compound_op, which calls smb2_validate_and_copy_iov. This helper ensures that qi->OutputBufferOffset and qi->OutputBufferLength (server-supplied fields) define a region that fully fits within the received rsp_iov->iov_len. This guarantee establishes that sidsbuf_end (calculated as qi->iov_base + offset + length) will be within the valid bounds of the response buffer. Inside parse_posix_sids, sidsbuf is derived from this validated offset. Subsequent reads for owner_len and group_len are guarded by posix_info_sid_size(), which takes sidsbuf_end as an upper bound, ensuring that each SID read operation stays within the valid sidsbuf to sidsbuf_end range. Finally, the destination buffers (&data->posix_owner, &data->posix_group) are sufficiently large (struct cifs_sid is typically 70 bytes) to hold the maximum possible SID size (68 bytes) returned by posix_info_sid_size.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 size argument 'owner_len' is returned by posix_info_sid_size(). This helper function is called with (sidsbuf, sidsbuf_end) which correctly bounds the read length against the available server-supplied buffer segment. The caller function (smb2_compound_op) ensures that sidsbuf_end itself is within the actual received network buffer. Therefore, the source buffer read is safe. For the destination buffer, 'data->posix_owner' is a struct _SID (struct cifs_sid), which is typically 70 bytes. The maximum value returned by posix_info_sid_size (when SubAuthorityCount is 15) is 68 bytes. Thus, 68 <= 70, making the destination buffer write safe. Counterexample test: If sidsbuf_end - sidsbuf = 10 bytes available for the SID, and posix_info_sid_size tries to read a SID that requires 12 bytes, posix_info_sid_size will return -1, causing an early return. If a valid owner_len is returned, it is guaranteed to fit within sidsbuf_end - sidsbuf.


#### 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 `qi->OutputBufferOffset`. This offset, along with `qi->OutputBufferLength`, is validated by `smb2_validate_and_copy_iov` in the caller `smb2_compound_op` before `parse_posix_sids` is even called. This validation guarantees that the entire region described by `OutputBufferOffset` and `OutputBufferLength` is within `rsp_iov->iov_len`. Since `sidsbuf = (u8 *)qi + offset + qi_len` (where `qi_len` is a fixed positive constant `sizeof(data->posix_fi)`), `sidsbuf` will always point to a valid location within the overall received buffer. The subsequent `owner_len` validation (from finding #1) ensures that reading from `sidsbuf` for `owner_len` bytes is safe.


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 finding #1, 'group_len' is returned by `posix_info_sid_size()`, this time called with `(sidsbuf + owner_len, sidsbuf_end)`. This correctly bounds `group_len` against the remaining portion of the server-supplied buffer segment starting after the first SID (`owner_len`). The `owner_len` itself has been validated. For the destination buffer, `data->posix_group` is also a `struct _SID` (70 bytes), and the maximum `group_len` (68 bytes) fits safely. Counterexample test: If (sidsbuf_end - (sidsbuf + owner_len)) = 5 bytes are remaining, and posix_info_sid_size tries to read a SID that requires 8 bytes, it returns -1, preventing an OOB read.


#### 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 base pointer `sidsbuf + owner_len` is safe. `sidsbuf` is validated as per finding #2. `owner_len` is validated by the first call to `posix_info_sid_size`, which ensures that `sidsbuf + owner_len` does not exceed `sidsbuf_end`. Since `sidsbuf_end` is guaranteed to be within the valid `rsp_iov` buffer (due to caller validation), `sidsbuf + owner_len` will also point to a valid memory location. The subsequent `group_len` validation (from finding #3) ensures that reading from this starting point for `group_len` bytes is safe.



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

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

> The function performs comprehensive bounds checks on the server-supplied 'OutputOffset' and 'OutputCount' before deriving the 'buf' pointer and accessing its fields. The checks ensure that the requested region (offset + count) fits within the received buffer, and that the count itself is at least the size of the reparse data buffer header, which contains the 'ReparseDataLength' field. If these conditions are not met, the function returns an error, preventing out-of-bounds access.

#### 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 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 |

*Dismissed:* The taint source `le32_to_cpu(io->OutputOffset)` at line 37 is derived from `io->OutputOffset`, which is part of the `smb2_ioctl_rsp` structure received from the server. Thus, the taint is genuinely server-supplied. 

However, there are sufficient bounds checks in place:
1. Line 38: `if (check_add_overflow(off, count, &len) || len > iov->iov_len)`: This critical check ensures that the entire range starting at `off` with a length of `count` (i.e., `off + count`) does not exceed the total received buffer length (`iov->iov_len`). This prevents the `buf` pointer (derived at line 42 as `io + off`) from pointing past the end of the `iov` buffer and ensures that any access within the `count` bytes from `off` would be within `iov->iov_len`.
2. Line 44: `if (count < len)` (where `len` is `sizeof(*buf)`): This check verifies that the reported `OutputCount` (representing the length of the reparse data) is at least the size of the `reparse_data_buffer` header itself (which is 8 bytes). The `ReparseDataLength` field is located at offset 4 within this header. If `count` is less than `sizeof(*buf)`, an error is returned at line 45, preventing the access.

Combined, these checks guarantee that if `buf->ReparseDataLength` is accessed, the memory region from `io + off` up to at least `io + off + sizeof(*buf)` (and therefore `io + off + 4` for `ReparseDataLength`) is within the bounds of `iov->iov_len`.

Counterexample test:
- `iov->iov_len = 20`
- `off = 10` (server-supplied `OutputOffset`)
- `count = 3` (server-supplied `OutputCount`)
1. `off` (10) and `count` (3) are read.
2. `check_add_overflow(10, 3, &len)` results in `len = 13`. `13 > 20` is false. This check passes.
3. `buf` is derived as `io + 10`.
4. `len = sizeof(*buf)` (8 bytes).
5. `if (count < len)` (`3 < 8`) is true. The function `return ERR_PTR(...)` at line 45.
Result: The OOB dereference `buf->ReparseDataLength` at line 47 is not reached. The error path is correctly taken.



### <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_compound_op function calls smb2_validate_and_copy_iov, which itself calls smb2_validate_iov to perform bounds checking before the memory copy. This is a common pattern for validation helpers.

#### 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 tainted value `le16_to_cpu(qi_rsp->OutputBufferOffset)` is indeed server-supplied, as `qi_rsp` points to a server response buffer. However, the sink is in `smb2_validate_and_copy_iov()`. This function explicitly calls `smb2_validate_iov(offset, buffer_length, iov, minbufsize)` at line 3896, *before* performing the `memcpy` at line 3900. If `smb2_validate_iov` returns an error, `smb2_validate_and_copy_iov` returns immediately, preventing the `memcpy`. This means `smb2_validate_iov` acts as a guard. Per guideline 4, 'when a cross-function finding reports a sink inside a helper, the helper may validate its argument internally before operating on it.' The structure of `smb2_validate_and_copy_iov` clearly shows that the `memcpy` is guarded by `smb2_validate_iov`. Therefore, the `memcpy` is only reached if the offset and length have been validated. No counterexample exists because `smb2_validate_iov` is expected to catch any out-of-bounds `offset + minbufsize` condition against `iov->iov_len`.



### <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` performs multiple validation checks on the received SMB2 header and PDU fields. Specifically, the `command` field is validated against an upper bound, and its unsigned nature provides the lower bound, making array accesses safe.

#### 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:* The `command` variable is derived from `shdr->Command`, which is part of the server-supplied network buffer. This makes `command` server-supplied.

However, there is an explicit bounds check at line 224: `if (command >= NUMBER_OF_SMB2_COMMANDS)`. If this condition is true, the function returns 1, preventing the out-of-bounds access. If the code proceeds past this check, `command` is guaranteed to be less than `NUMBER_OF_SMB2_COMMANDS`.

Furthermore, `command` is an `int` which is assigned `le16_to_cpu(shdr->Command)`. `le16_to_cpu` returns an `unsigned short` (or `__u16`), which is then implicitly converted to `int`. As an unsigned value, it cannot be negative, so the lower bound of 0 is implicitly guaranteed. Combined with the explicit upper bound check, `command` is guaranteed to be `0 <= command < NUMBER_OF_SMB2_COMMANDS` before being used as an array index for `smb2_rsp_struct_sizes` and `smb2_min_pdu_len`.

Counterexample test: Let `NUMBER_OF_SMB2_COMMANDS` be N. The valid indices for `smb2_rsp_struct_sizes` are `0` to `N-1`. If `command` were, for instance, `N`, the check at line 224 (`N >= N`) would be true, and the function would return. If `command` were `N-1`, the check (`N-1 >= N`) would be false, and the code would proceed to use `smb2_rsp_struct_sizes[N-1]`, which is a valid access. If `command` were `-1` (if it were signed), `le16_to_cpu` would convert it to a large positive value, which would be caught by the upper bound check. As `command` is effectively unsigned, a negative value is impossible. Therefore, no counterexample exists where `command` can be out of bounds after the validation.



### <a name="smb2-tcon-find-pending-open-lease--fs-smb-client-smb2misc-c"></a>smb2_tcon_find_pending_open_lease() — `fs/smb/client/smb2misc.c`

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

> The function processes a server-supplied SMB2 lease break notification. It extracts various fields, including a 32-bit lease state, and uses it to update a local `cifs_pending_open` structure. The core issue is the implicit truncation of a 32-bit server-supplied value to an 8-bit kernel variable, which can lead to misinterpretation of the lease state.

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

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le32_to_cpu()` line 625 |
| Taint snippet | `__u8 lease_state = le32_to_cpu(rsp->NewLeaseState);` |
| Tainted var | `lease_state` |
| Truncation | line 625: 32-bit → 8-bit `__u8` |
| Sink snippet | `__u8 lease_state = le32_to_cpu(rsp->NewLeaseState);` |
| Possibly guarded | no |
| SMT | **witness**: `truncation` fails here — 32-bit value does not survive 8 bits *(a scenario, not a claim that a caller produces it)* |
| SMT witness | `le32_to_cpu_val=0xffffff00, value=0xffffff00` |
| SMT witness (LLM) | **reachable** — see notes |
| Server-supplied | yes |
| Check present | no |
| Check sufficient | no |

**Symptom:** Incorrect caching behavior, potential for stale data, or unexpected lease state transitions on the client.

**Fix:** Mask the `NewLeaseState` value with `& 0xFF` before assigning it to the `__u8 lease_state` variable to explicitly signify that only the lower 8 bits are relevant, or change the `open->oplock` type to `__u32` if the full 32-bit value is semantically meaningful. Given current protocol specifications, masking is likely the intended fix.

**CVE pattern:** Integer truncation leading to incorrect state management or information integrity issues.



### <a name="smb2-tcon-has-lease--fs-smb-client-smb2misc-c"></a>smb2_tcon_has_lease() — `fs/smb/client/smb2misc.c`

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

> The finding flags a truncation of a 32-bit server-supplied value (`NewLeaseState`) to an 8-bit local variable (`lease_state`). This `lease_state` is then assigned to a `__u8` field (`cfile->oplock_level`). While a truncation technically occurs, analysis of the SMB2 protocol indicates that `NewLeaseState` values are expected to be small (e.g., combinations of 0x01, 0x02, 0x04), generally fitting within an 8-bit unsigned integer. Any value exceeding 255 would be a protocol violation from the server. The truncation itself does not lead to out-of-bounds memory access, allocations, or array indexing, as the final destination is also an 8-bit field. Therefore, it is considered a semantic error for malformed packets rather than a memory corruption vulnerability.

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

| Field | Value |
|---|---|
| Category | Cat H — server value → narrow integer type (silent truncation) |
| Taint source | `le32_to_cpu()` line 591 |
| Taint snippet | `lease_state = le32_to_cpu(rsp->NewLeaseState);` |
| Tainted var | `lease_state` |
| Truncation | line 591: 32-bit → 8-bit `u8` |
| Sink snippet | `lease_state = le32_to_cpu(rsp->NewLeaseState);` |
| Possibly guarded | no |
| SMT | **witness**: `truncation` fails here — 32-bit value does not survive 8 bits *(a scenario, not a claim that a caller produces it)* |
| SMT witness | `le32_to_cpu_val=0xffffff00, value=0xffffff00` |
| SMT witness (LLM) | **reachable** — see notes |

*Dismissed:* The taint source `rsp->NewLeaseState` is indeed server-supplied. The finding identifies a silent truncation from 32-bit to 8-bit (`lease_state = le32_to_cpu(rsp->NewLeaseState)`). However, `lease_state` is subsequently assigned to `cfile->oplock_level`, which is also a `__u8`. The SMB2 protocol defines `NewLeaseState` values (e.g., SMB2_LEASE_READ_CACHING, SMB2_LEASE_HANDLE_CACHING, SMB2_LEASE_WRITE_CACHING) as small bit flags, whose combinations typically fit within a single byte (max 0x07). Therefore, a server sending a value that would cause actual truncation (i.e., > 255) would be violating the protocol. While the SMT witness (`0xffffff00`) is technically reachable if a malicious server sends it, the resulting `lease_state` of `0x00` (SMB2_LEASE_NONE) is a valid, albeit potentially incorrect, lease state. This does not lead to any memory safety issues (OOB read/write, integer overflow for size calculations, etc.). The issue is a loss of information for a protocol field that should already be constrained, not a vulnerability related to bounds checking or memory access.



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

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

> The static analysis finding misinterprets the data flow and types involved. The `le64_to_cpu(tr_hdr->SessionId)` expression results in a `u64` value, which is then correctly passed as a `u64` argument to the `smb2_get_enc_key` function. The return value of `smb2_get_enc_key` is an `int`, and this `int` is assigned to `rc`, which is also an `int`. There is no truncation of a 64-bit value to a 32-bit `rc` variable as described by the scanner. The `rc` variable stores the `int` return code (e.g., error codes), not the `u64` session ID.

#### 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 expression `le64_to_cpu(tr_hdr->SessionId)` is indeed a server-supplied 64-bit value when `crypt_message` is called from `decrypt_raw_data`. However, this `u64` value is passed as the `session_id` argument to `smb2_get_enc_key`, which expects a `u64`. Therefore, no truncation occurs for the session ID itself. The `rc` variable is declared as `int` and receives the `int` return value of `smb2_get_enc_key`. This is a standard assignment of an integer return code to an integer variable and does not involve the truncation of a 64-bit source. The static analyzer seems to have incorrectly identified `rc` as the target of the 64-bit source truncation.



### <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 function `move_smb2_ea_to_cifs` meticulously validates both the source buffer (`src`) and the destination buffer (`dst`) before performing any `memcpy` operations. The `src` buffer is initially validated by the caller `smb2_query_eas` using `smb2_validate_iov` to ensure the overall response buffer bounds. Inside `move_smb2_ea_to_cifs`, a loop processes individual EA entries. For each entry, the total required length (`8 + name_len + 1 + value_len`) is checked against the remaining `src_size` before accessing name and value pointers. Additionally, the destination buffer `dst_size` is checked against `value_len` (for the `if (ea_name)` path) or `user_name_len` (for the `else` path) before copying data.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 indeed server-supplied. However, its use as a size argument to `memcpy` at line 1085 is sufficiently guarded by two independent checks:

1.  **Source Buffer Bounds**: The check at line 1065 `if (src_size < 8 + name_len + 1 + value_len)` ensures that the entire EA entry, including the `value_len` bytes, fits within the remaining `src_size`. If this condition is true (meaning an overrun), the function bails out via `goto out;` before the `memcpy` is reached. This prevents an OOB read from the `src` buffer.
2.  **Destination Buffer Bounds**: The checks at lines 1079-1084 explicitly compare `dst_size` with `value_len`. If `dst_size` is zero or less than `value_len`, the function sets `rc = -ERANGE` and bails out via `goto out;`. This prevents an OOB write to the `dst` buffer.

**Counterexample Test:**
*   **Scenario 1: `src` buffer overrun.** Let `src_size = 10`, `src->ea_name_length = 1` (`name_len = 1`), and `src->ea_value_length = 0xFFFF` (`value_len = 65535`).
    *   Line 1065: `if (10 < 8 + 1 + 1 + 65535)` evaluates to `if (10 < 65545)`, which is true.
    *   The code enters the `if` block, sets `rc = smb_EIO2(...)`, and `goto out;`. The `memcpy` at line 1085 is not reached.
*   **Scenario 2: `dst` buffer overrun.** Let `src_size = 100` (large enough), `name_len = 1`, `value_len = 10`. And `dst_size = 5`.
    *   Line 1065: `if (100 < 8 + 1 + 1 + 10)` evaluates to `if (100 < 20)`, which is false. The code proceeds.
    *   Line 1081: `if (5 < 10)` evaluates to true.
    *   The code enters the `if` block, sets `rc = -ERANGE`, and `goto out;`. The `memcpy` at line 1085 is not reached.

In both scenarios, the necessary bounds checks correctly prevent the `memcpy` from leading to an OOB access. Therefore, no counterexample exists where the `memcpy` at line 1085 would cause an OOB read or write.



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

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

> The function `parse_server_interfaces` iterates through a series of `network_interface_info_ioctl_rsp` structures received from the server. It uses `next = le32_to_cpu(p->Next)` to advance the pointer `p` to the next structure. The `next` value is validated at lines 788-793 to ensure it's within the remaining buffer (`next < sizeof(*p) || next > bytes_left`). The `bytes_left` variable is correctly updated by subtracting the consumed `next` offset. The finding flags an access to `p->Next` at line 807, which occurs after the main parsing loop terminates. This `p` points to the last struct that was considered (either successfully parsed, or the one that caused the loop to terminate due to insufficient remaining bytes).

#### 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 tainted variable `p` is derived from `buf`, which is populated by a server response via `SMB2_ioctl` (see `SMB3_request_interfaces` caller). The `p->Next` field is read from this server-supplied buffer. 

The scanner flags `p->Next` at line 807: `if ((bytes_left > 8) || (bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(p->Next) && p->Next))`.
This `if` condition itself provides sufficient bounds checking due to C's short-circuit evaluation:
1. If `(bytes_left > 8)` is true, the entire `||` expression is true, and the right side (including `p->Next`) is *not* evaluated. Therefore, `p->Next` is not accessed.
2. If `(bytes_left > 8)` is false, then the right side `(bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(p->Next) && p->Next))` is evaluated.
3. The left operand of the `&&` operator, `bytes_left >= offsetof(struct network_interface_info_ioctl_rsp, Next) + sizeof(p->Next)`, explicitly checks if the `Next` field (including its size) fits within the `bytes_left` remaining in the buffer. If this condition is false, the `&&` expression short-circuits, and `p->Next` is *not* evaluated.
4. Only if `bytes_left` is sufficient to contain the `Next` field will `p->Next` actually be accessed (for its boolean value check).

Counterexample test: 
Let `sizeof(struct network_interface_info_ioctl_rsp)` be 24 bytes. Let `offsetof(..., Next) + sizeof(p->Next)` be 24 bytes (i.e., `Next` is the last field and takes 4 bytes at offset 20).
- Scenario A: `bytes_left = 10` at line 807. The condition `(10 > 8)` is true. The right side of `||` is skipped. `p->Next` is not accessed.
- Scenario B: `bytes_left = 6` at line 807. The condition `(6 > 8)` is false. The right side of `||` is evaluated. The sub-condition `(6 >= 24)` (for `offsetof(...) + sizeof(...)`) is false. The `&&` short-circuits. `p->Next` is not accessed.
In both cases where `bytes_left` is too small for a full struct or for the `Next` field, the access to `p->Next` at line 807 is prevented by the `if` condition's short-circuiting logic. Thus, the dereference is sufficiently guarded.



### <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` performs robust validation of the server-supplied `NextCommand` field (`next_cmd`) before its use in `memcpy`. The `if (next_cmd)` block (lines 5472-5481) contains three critical checks:
1. `next_cmd < MID_HEADER_SIZE(server)`: Ensures `next_cmd` is not too small, preventing `buf + next_cmd` from pointing into the fixed header of the current PDU.
2. `next_cmd > pdu_length`: Ensures `next_cmd` does not exceed the total length of the current PDU, preventing `buf + next_cmd` from being an OOB read beyond the current buffer's bounds.
3. `pdu_length - next_cmd < MID_HEADER_SIZE(server)`: Ensures that the remaining data (`pdu_length - next_cmd`) is at least large enough to contain the header of the *next* command. This prevents processing truncated compound PDUs and ensures the length argument to `memcpy` (`pdu_length - next_cmd`) is sane.

Combined with the caller's (`smb3_receive_transform`) validation of `pdu_length` (line 5559) against `CIFSMaxBufSize`, and the conditional allocation of `next_buffer` (small or large) based on `pdu_length`, both the source and destination buffers for `memcpy` are adequately protected.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 `next_cmd` variable is indeed server-supplied, derived from `shdr->NextCommand`, which is part of the network-received `smb2_hdr`. However, extensive bounds checks are performed before its use in `memcpy`.

**Source buffer (`buf`) checks:**
- `next_cmd < MID_HEADER_SIZE(server)` (line 5473): Prevents `buf + next_cmd` from pointing before the expected start of a subsequent command, ensuring `next_cmd` is a valid offset *after* the current header.
- `next_cmd > pdu_length` (line 5474): Prevents `buf + next_cmd` from going past the end of the `pdu_length` buffer.
- These checks ensure that `buf + next_cmd` is a valid starting address within `buf`.

**Size argument (`pdu_length - next_cmd`) checks:**
- The checks at lines 5473-5475 collectively guarantee that `pdu_length - next_cmd` is a non-negative value and that `next_cmd + (pdu_length - next_cmd)` (i.e., `pdu_length`) does not exceed the original buffer size. This ensures the `memcpy` does not read OOB from `buf`.

**Destination buffer (`next_buffer`) checks:**
- The maximum value of `pdu_length` (after line 5459, which subtracts `sizeof(struct smb2_transform_hdr)`) is constrained by the caller `smb3_receive_transform` (line 5559) to approximately `CIFSMaxBufSize`. 
- `next_buffer` is allocated via `cifs_buf_get()` or `cifs_small_buf_get()`. `cifs_buf_get()` allocates `CIFSMaxBufSize`, while `cifs_small_buf_get()` allocates `MAX_CIFS_SMALL_BUFFER_SIZE`. The choice between small and large allocation is determined by `pdu_length` itself (line 5442), ensuring the allocated buffer is large enough for the *original* `pdu_length`.
- The maximum `length` copied is `pdu_length - next_cmd`, which is bounded by the original `pdu_length` (approximately `CIFSMaxBufSize`). Therefore, the destination buffer `next_buffer` will always be large enough to receive the copied data.

**Counterexample Test:**
- **`pdu_length = 100`, `MID_HEADER_SIZE(server) = 64` (example values):**
  - If `next_cmd = 0`: Caught by `next_cmd < 64`. Returns -1.
  - If `next_cmd = 60`: Caught by `next_cmd < 64`. Returns -1.
  - If `next_cmd = 101`: Caught by `next_cmd > 100`. Returns -1.
  - If `next_cmd = 80`: `pdu_length - next_cmd = 20`. Caught by `20 < 64`. Returns -1.
  - If `next_cmd = 64`: `pdu_length - next_cmd = 36`. Not caught by any check. `memcpy(next_buffer, buf + 64, 36)` is safe. The source is `buf + 64` (within `buf[0..99]`), copying 36 bytes, ending at `buf[99]`. The destination `next_buffer` is large enough (e.g., 64KB or 1MB).
- All tested values are either caught by existing guards or result in safe operations.

The SMT result `PROVED — negative: value is unsigned at the sink` confirms that `pdu_length - next_cmd` cannot become negative due to the unsigned types and the `next_cmd > pdu_length` check, preventing potential wrap-around issues, which is consistent with the manual analysis.



### <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 `qi.input_buffer_length` field is initially user-supplied via `copy_from_user` at line 1604. This value is subsequently capped by a server-supplied length field (either `io_rsp->OutputCount` or `qi_rsp->OutputBufferLength`) before being used as the size argument to `copy_to_user`. Crucially, the kernel also performs a bounds check to ensure that the kernel-side source buffer (`rsp_iov[1].iov_base`) contains enough data for the copy (lines 1783-1785 and 1806-1808). Finally, the destination of `copy_to_user` is user space (`pqi` is derived from `p`, an `unsigned long` argument, which is cast to `__user` pointers). According to analysis rule #11, `copy_to_user` inherently protects against kernel OOB writes to user space by returning -EFAULT if the user's buffer is not adequately mapped or sized. Therefore, both the kernel-side source and the user-side destination are sufficiently protected.

#### 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 user-supplied (from `copy_from_user` into `qi` at line 1604). Before the `copy_to_user` at line 1797, it is capped at line 1782 by `le32_to_cpu(io_rsp->OutputCount)`, which is a server-supplied value. This ensures the copied length doesn't exceed what the server actually returned. Further, lines 1783-1785 check if the derived source buffer range (`io_rsp->OutputOffset` + `qi.input_buffer_length`) fits within `rsp_iov[1].iov_len` (the actual size of the kernel-allocated response buffer). This prevents kernel OOB reads from `io_rsp`. The destination is user space (`pqi + sizeof(struct smb_query_info)`). Per rule #11, `copy_to_user` itself validates the user-space destination buffer and will return -EFAULT on short user buffers, preventing kernel OOB writes. No kernel memory corruption can occur.


#### 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 user-supplied. In this branch, it is capped at line 1805 by `le32_to_cpu(qi_rsp->OutputBufferLength)`, a server-supplied value. Lines 1806-1808 use `struct_size` to check if the combined size of `qi_rsp` plus the `Buffer` part (of length `qi.input_buffer_length`) fits within `rsp_iov[1].iov_len`, preventing kernel OOB reads from `qi_rsp->Buffer`. The destination `pqi + 1` is user space. As per rule #11, `copy_to_user` inherently protects against kernel OOB writes to user space by returning -EFAULT if the destination buffer is too small or invalid. Thus, both the kernel-side source and the user-side destination are sufficiently validated.



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

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

> Both findings relate to the processing of server-supplied EA (Extended Attribute) information. The `smb2_query_eas` function receives a response from `smb2_query_info_compound`, which is then validated by `smb2_validate_iov`. This validation ensures that the `OutputBufferOffset` and `OutputBufferLength` fields refer to a region within the received network buffer. The `move_smb2_ea_to_cifs` function then further processes this EA data, applying additional internal bounds checks. The key to both findings being false positives is the combination of the initial `smb2_validate_iov` call and the subsequent internal length checks within `move_smb2_ea_to_cifs`.

#### 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 variable `info` is derived from `rsp->OutputBufferOffset` (server-supplied). However, before `info` is passed to `move_smb2_ea_to_cifs`, the `smb2_validate_iov` function is called at line 1172. This validator ensures that `OutputBufferOffset + OutputBufferLength` fits within the `rsp_iov` buffer, and specifically that the size of `smb2_file_full_ea_info` (the header) fits at `OutputBufferOffset`. This guarantees `info` points to a valid struct within the buffer.

Inside `move_smb2_ea_to_cifs`, the sink `&src->ea_data[src->ea_name_length + 1]` depends on `src->ea_name_length` and the base `src` (which is `info`). The `smb2_file_full_ea_info` struct has a fixed header size (typically 8 bytes: 4 for next_entry_offset, 1 for flags, 1 for ea_name_length, 2 for ea_value_length), followed by `ea_data[1]` (a flexible array member).

The crucial bounds check occurs at line 1065: `if (src_size < 8 + name_len + 1 + value_len)`. Here, `src_size` is `OutputBufferLength` (already bounded by `smb2_validate_iov`), `name_len` is `src->ea_name_length`, and `value_len` is `le16_to_cpu(src->ea_value_length)`. This check explicitly ensures that the combined length of the fixed header (8 bytes), the name (including null terminator, `name_len + 1`), and the value (`value_len`) does not exceed the `src_size` (the `OutputBufferLength`). If this check passes, then `value = &src->ea_data[src->ea_name_length + 1]` (equivalent to `src + 8 + name_len + 1`) and subsequent accesses like `memcpy` using `value_len` or `name_len` are guaranteed to be within the `src` buffer of `src_size` length. Thus, the access is sufficiently guarded.

Counterexample test: 
Assume `rsp_iov.iov_len = 100`, `sizeof(struct smb2_file_full_ea_info) = 8`. 
Server provides `OutputBufferOffset = 0`, `OutputBufferLength = 10`. 
`smb2_validate_iov(0, 10, ...)` passes. `info` points to `rsp_iov.iov_base`, `src_size = 10`. 
Inside `move_smb2_ea_to_cifs`:
`while (10 >= 8)` is true.
Server provides `src->ea_name_length = 5`, `src->ea_value_length = 0`. (`name_len=5`, `value_len=0`).
Check `if (10 < 8 + 5 + 1 + 0)` => `if (10 < 14)` which is `true`. The code enters the `if` block, sets `rc = smb_EIO2` and `goto out;`. The problematic `value = &src->ea_data[src->ea_name_length + 1]` is not reached. The check at 1065 correctly prevents the OOB access.


#### Finding #2 — Category F — cross-function via `move_smb2_ea_to_cifs()` — ~~false positive~~

| 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 |

*Dismissed:* The tainted variable `src_size` (derived from `rsp->OutputBufferLength`) is indeed server-supplied. It is used as the loop bound in `while (src_size >= sizeof(*src))` at line 1058.

However, this `src_size` is first validated by `smb2_validate_iov` (line 1172). The postcondition of `smb2_validate_iov` guarantees that `OutputBufferOffset + OutputBufferLength` (which dictates the range for `src` and `src_size`) is within the overall received buffer `rsp_iov.iov_len`. Therefore, the *initial* value of `src_size` is correctly bounded by the actual received network data.

Furthermore, the loop condition `src_size >= sizeof(*src)` is the *correct* way to guard a loop that processes structures of a minimum fixed size. As per the prompt's guideline #6, a check `remaining_size >= sizeof(*ptr)` is sufficient, unlike `remaining_size > 0`. This loop guard properly terminates when there isn't enough data for even the fixed header of an `smb2_file_full_ea_info` structure.

While the provided snippet of `move_smb2_ea_to_cifs` is incomplete regarding the advancement of `src` and reduction of `src_size` using `next_entry_offset` (which is present in the `smb2_file_full_ea_info` struct and typically used for traversing EA lists), the finding specifically targets `src_size` as the loop bound in the `while` condition. The `src_size` itself, as initially bounded and used in this specific condition, does not lead to an OOB. Any potential OOB due to an improperly validated `next_entry_offset` that causes `src` to advance beyond `src_size` or `src_size` to become negative would be a different bug, with `next_entry_offset` as the taint source and the pointer/size arithmetic as the sink, not the `while` loop condition itself.

Counterexample test: 
Assume `sizeof(struct smb2_file_full_ea_info) = 8`. 
Server provides `OutputBufferOffset = 0`, `OutputBufferLength = 7`. 
`smb2_validate_iov(0, 7, ...)` would fail because `0 + 8` (min_len) is not `<= 7`. So, `move_smb2_ea_to_cifs` would not be called with an `src_size` too small to even contain the header. 
If `OutputBufferLength` was initially 10, then `src_size = 10`. The loop `while (10 >= 8)` proceeds. If `src_size` were to be decremented by an unvalidated `next_entry_offset` (not shown) to, for example, 7, the next iteration `while (7 >= 8)` would be false, terminating the loop safely. The issue here isn't the loop guard itself, but rather if the advancement logic (missing from snippet) improperly calculated `src_size` or `src` based on `next_entry_offset`.



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

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

> The function handles snapshot enumeration for SMB3. It performs an `SMB2_ioctl` call to retrieve snapshot data from the server. The `ret_data_len` variable is crucial as it represents the size of the data returned by the `SMB2_ioctl` and subsequently copied to user space. The core logic involves two rounds of interaction: an initial query to get the required buffer size (where `ret_data_len` is often 0 or a small value from user space), and a subsequent query with a larger buffer. The value of `ret_data_len` at the `copy_to_user` sink is carefully controlled to prevent out-of-bounds access.

#### 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 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 |

*Dismissed:* The `ret_data_len` variable at line 2487, used as the size argument for `copy_to_user`, originates from two primary sources and undergoes subsequent validation/capping:

1.  **From `SMB2_ioctl` (server-supplied):** After the `SMB2_ioctl` call at line 2440-2445, `ret_data_len` holds the actual length of the data returned by the server and allocated into `retbuf`. The `SMB2_ioctl` postcondition guarantees that `retbuf` is exactly `ret_data_len` bytes long and that this length has been validated against various internal limits. Let's call this value `K_len` (Kernel-determined length).

2.  **From user space (`snapshot_in.snapshot_array_size`):** The `snapshot_in` struct is copied from the user's `ioc_buf` at line 2453. Its `snapshot_array_size` field is user-controlled (let's call it `U_cap`). This `U_cap` is later used to cap `ret_data_len`.

Now, let's trace `ret_data_len` leading up to the `copy_to_user` sink:

a.  **Initial `ret_data_len` from user space (line 2425):** This value is used to determine `max_response_size` for `SMB2_ioctl`. While user-controlled, its purpose is to influence the *kernel's request* size, not directly the `copy_to_user` size.

b.  **`ret_data_len` after `SMB2_ioctl` (line 2445):** This is `K_len`, the actual size of the kernel source buffer `retbuf`.

c.  **First capping (lines 2468-2475):**
    `if (snapshot_in.snapshot_array_size < GMT_TOKEN_SIZE)`
        `if (ret_data_len < sizeof(struct smb_snapshot_array)) { rc = -EIO; return rc; }` (This branch handles cases where `K_len` is too small even for the header, indicating an error.)
        `ret_data_len = sizeof(struct smb_snapshot_array);` (Here, `ret_data_len` is *reduced* to a fixed kernel constant if `U_cap` is too small and `K_len` is sufficiently large).
	d.  **Second capping (lines 2482-2485):**
    `if (ret_data_len > (snapshot_in.snapshot_array_size + sizeof(struct smb_snapshot_array)))`
        `ret_data_len = snapshot_in.snapshot_array_size + sizeof(struct smb_snapshot_array);` (Here, `ret_data_len` is *reduced* again if `K_len` (potentially modified by the first cap) is larger than the `U_cap` plus header size.

At the `copy_to_user` call (line 2487), the `ret_data_len` argument is the result of these two capping operations. In essence, the final `ret_data_len` will be `min(K_len, MaxCopySize)`, where `MaxCopySize` is derived from user-supplied `U_cap` and `sizeof(struct smb_snapshot_array)`.

Since `ret_data_len` is always less than or equal to `K_len` (the true size of the kernel source buffer `retbuf`), there is no possibility of an out-of-bounds read from `retbuf`.

Regarding the destination buffer `ioc_buf` (user space), the `ret_data_len` value is explicitly capped by a value (`snapshot_in.snapshot_array_size`) that the user supplied from their own buffer. As per Rule 11, `copy_to_user` itself performs checks on the user's destination buffer, and if the user provides a `U_cap` that would exceed their allocated `ioc_buf` size, `copy_to_user` will fail with `-EFAULT` without the kernel writing out of bounds into user memory. Therefore, this is a false positive.



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

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

> The finding points to a truncation of the return value of `fiemap_fill_next_extent` when assigned to `rc`. However, `fiemap_fill_next_extent` is defined to return an `int` (typically 0, 1, or negative error codes), which fits perfectly into an `int` variable. The actual server-supplied 64-bit values (file_offset, length) are passed as `u64` arguments to `fiemap_fill_next_extent`, where they are correctly handled without truncation. The scanner has likely misidentified the return type or purpose of `rc` in this context.

#### 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 values `le64_to_cpu(out_data[i].file_offset)` and `le64_to_cpu(out_data[i].length)` are indeed server-supplied and 64-bit. However, they are passed as `u64` arguments to `fiemap_fill_next_extent`, which correctly accepts them as `u64`. The variable `rc` is an `int`, and the scanner flags the assignment `rc = fiemap_fill_next_extent(...)`. The `fiemap_fill_next_extent` function, as typically defined in the kernel, returns an `int` (0 for success, 1 for termination, or negative error codes). These return values are always within the range of a 32-bit signed integer. Therefore, there is no silent truncation of a meaningful 64-bit value to a narrower `int` for `rc`. No counterexample can be constructed where `fiemap_fill_next_extent` would return a value outside the `int` range that would then be truncated. The scanner's warning is a false positive based on a misinterpretation of the function's return value semantics.



### <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 `smb3_simple_fallocate_range` retrieves file allocated ranges from the server using `SMB2_ioctl`. It then iterates through these ranges, performing zero-fills in unallocated sections. The parsing of server-supplied `file_offset` and `length` fields (into `range_start` and `range_len`) is guarded by `check_add_overflow` to prevent 64-bit integer overflows when calculating `range_end`. The loop correctly bounds `tmp_data` accesses against `out_data_len`, which is validated by `SMB2_ioctl`. The primary issue in the finding report is a misunderstanding of variable types and assignments.

#### 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 static analysis finding claims a 64-bit value (`l`) is silently truncated to a 32-bit `rc` at line 3835. This is a misinterpretation of the code:

1.  **Taint Source and `l`**: `range_start` and `range_len` are indeed server-supplied 64-bit values derived from `tmp_data` (which comes from `SMB2_ioctl`). `l` is calculated as `range_start - off` and is of type `loff_t` (signed 64-bit). This `l` is also capped by the `len` parameter (also `loff_t`), so `l` itself correctly maintains its 64-bit precision.
2.  **Use of `l`**: `l` is passed as the `len` argument to `smb3_simple_fallocate_write_range`. The `len` parameter in `smb3_simple_fallocate_write_range` is also `loff_t`. Therefore, `l` is passed as a 64-bit value to a 64-bit parameter without truncation.
3.  **Assignment to `rc`**: `rc` is an `int` variable, used for storing return codes. Line 3835 is `rc = smb3_simple_fallocate_write_range(...)`. The function `smb3_simple_fallocate_write_range` returns an `int`. The assignment `rc = (int)return_value` is a standard assignment of an `int` to an `int`. There is no implicit or explicit truncation of the 64-bit value `l` into `rc`. `rc` receives the 32-bit integer return code from the function, not the 64-bit length `l`.

Therefore, the premise of the finding (truncation of `l` to `rc`) is incorrect. No counterexample can be constructed for the described truncation because it does not occur. The underlying `range_start` and `range_len` values are checked for overflow via `check_add_overflow` before `l` is computed.



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

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

> All three findings are false positives. The `smb2_validate_iov()` function, called at line 6314, effectively validates the server-supplied `OutputBufferLength` (rsp_len) and `OutputBufferOffset` (offset) against the actual received buffer length (`rsp_iov.iov_len`) and the minimum expected size (`min_len`).

Specifically, `smb2_validate_iov()` performs two key checks:
1.  `buffer_length < min_buf_size`: Ensures the server-provided data length is at least the minimum required for the expected structure type (`min_len`). If not, it returns -EINVAL, preventing subsequent operations.
2.  `end_of_buf > end_of_smb`: This translates to `offset + buffer_length <= iov->iov_len`. This ensures that the entire region described by `offset` and `buffer_length` (i.e., the data payload reported by the server) fits completely within the actually received network buffer (`iov->iov_base` to `iov->iov_base + iov->iov_len`).

These combined checks guarantee that any subsequent accesses using `offset` and `rsp_len` (or `min_len`) as bounds will not go out-of-bounds relative to the received network buffer. The initial `rsp` pointer (pointing to `rsp_iov.iov_base`) is assumed to be valid for reading `OutputBufferLength` and `OutputBufferOffset`, a common assumption for the initial SMB2 header.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 `rsp_len` value is server-supplied. The `smb2_validate_iov(offset, rsp_len, &rsp_iov, min_len)` call at line 6314 validates `rsp_len` (passed as `buffer_length`).

The `memcpy` source buffer is `offset + (char *)rsp`, and the size is `min_t(unsigned int, rsp_len, min_len)`. For this `level` (`FS_ATTRIBUTE_INFORMATION`), `min_len` is `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)`. `smb2_validate_iov` guarantees `rsp_len >= min_len`. Therefore, `min_t(unsigned int, rsp_len, min_len)` simplifies to `min_len` (i.e., `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)`).

`smb2_validate_iov` ensures `offset + rsp_len <= rsp_iov.iov_len`. Since `min_len <= rsp_len`, it implies `offset + min_len <= offset + rsp_len <= rsp_iov.iov_len`. This guarantees that the read from the source buffer `offset + (char *)rsp` for `min_len` bytes is within `rsp_iov.iov_len`.

The destination `&tcon->fsAttrInfo` is a `FILE_SYSTEM_ATTRIBUTE_INFO` struct, so a copy of `sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)` bytes fits perfectly. Both source read and destination write are safe.

Counterexample Test:
- `rsp_iov.iov_len = 100` (actual received bytes).
- `min_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) = 20`.
- If `rsp_len = 10` (server reports less than `min_len`): `smb2_validate_iov` returns `-EINVAL` because `10 < 20`, so `memcpy` is not reached.
- If `rsp_len = 30`, `offset = 0`: `smb2_validate_iov` passes. `memcpy` copies `min_t(30, 20) = 20` bytes from `rsp` (start of buffer), which is within the 30 bytes guaranteed by `rsp_len` and the 100 bytes of `iov_len`. Safe.
- If `rsp_len = 30`, `offset = 80`: `smb2_validate_iov` returns `-EINVAL` because `80 + 30 (110) > 100`. `memcpy` is not reached. Safe.


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

| 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 |

*Dismissed:* The `offset` value is server-supplied. The pointer `ss_info` is derived from `offset` at line 6326. The dereferences are `ss_info->Flags` and `ss_info->PhysicalBytesPerSectorForPerf` within `struct smb3_fs_ss_info`.

The `smb2_validate_iov(offset, rsp_len, &rsp_iov, min_len)` call at line 6314 validates `offset` and `rsp_len`. For this `level` (`FS_SECTOR_SIZE_INFORMATION`), `min_len` is `sizeof(struct smb3_fs_ss_info)`.

`smb2_validate_iov` guarantees two things:
1.  `rsp_len >= sizeof(struct smb3_fs_ss_info)` (from `buffer_length < min_buf_size` check).
2.  `offset + rsp_len <= rsp_iov.iov_len` (from `end_of_buf > end_of_smb` check).

Combining these, it implies `offset + sizeof(struct smb3_fs_ss_info) <= offset + rsp_len <= rsp_iov.iov_len`. This ensures that the entire `struct smb3_fs_ss_info` starting at `offset + (char *)rsp` fits within the `rsp_iov.iov_len` received buffer, making the dereferences safe.

Counterexample Test:
- `rsp_iov.iov_len = 100` (actual received bytes).
- `min_len = sizeof(struct smb3_fs_ss_info) = 24` (example size).
- If `rsp_len = 10` (server reports less than `min_len`): `smb2_validate_iov` returns `-EINVAL` because `10 < 24`, so the dereferences are not reached.
- If `rsp_len = 30`, `offset = 70`: `smb2_validate_iov` passes. `offset + sizeof(struct smb3_fs_ss_info)` becomes `70 + 24 = 94`. This is `<= 100` (`rsp_iov.iov_len`). The dereferences are safe.
- If `rsp_len = 30`, `offset = 80`: `smb2_validate_iov` returns `-EINVAL` because `80 + 30 (110) > 100`. The dereferences are not reached. Safe.


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

| 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 |

*Dismissed:* This finding is analogous to Finding #2.
The `offset` value is server-supplied. The pointer `vol_info` is derived from `offset` at line 6332. The dereferences are `vol_info->VolumeSerialNumber` and `vol_info->VolumeCreationTime` within `struct filesystem_vol_info`.

The `smb2_validate_iov(offset, rsp_len, &rsp_iov, min_len)` call at line 6314 validates `offset` and `rsp_len`. For this `level` (`FS_VOLUME_INFORMATION`), `min_len` is `sizeof(struct filesystem_vol_info)`.

`smb2_validate_iov` guarantees two things:
1.  `rsp_len >= sizeof(struct filesystem_vol_info)` (from `buffer_length < min_buf_size` check).
2.  `offset + rsp_len <= rsp_iov.iov_len` (from `end_of_buf > end_of_smb` check).

Combining these, it implies `offset + sizeof(struct filesystem_vol_info) <= offset + rsp_len <= rsp_iov.iov_len`. This ensures that the entire `struct filesystem_vol_info` starting at `offset + (char *)rsp` fits within the `rsp_iov.iov_len` received buffer, making the dereferences safe.

Counterexample Test:
- `rsp_iov.iov_len = 100` (actual received bytes).
- `min_len = sizeof(struct filesystem_vol_info) = 16` (example size).
- If `rsp_len = 10` (server reports less than `min_len`): `smb2_validate_iov` returns `-EINVAL` because `10 < 16`, so the dereferences are not reached.
- If `rsp_len = 30`, `offset = 80`: `smb2_validate_iov` passes. `offset + sizeof(struct filesystem_vol_info)` becomes `80 + 16 = 96`. This is `<= 100` (`rsp_iov.iov_len`). The dereferences are safe.
- If `rsp_len = 30`, `offset = 85`: `smb2_validate_iov` returns `-EINVAL` because `85 + 30 (115) > 100`. The dereferences are not reached. Safe.



### <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 responsible for initializing an SMB2 *request* buffer, which is then sent to the server. The `smb2_command` parameter passed to this function (and subsequently processed by `le16_to_cpu`) represents the type of SMB2 command that the kernel *intends to send*. It is a kernel-controlled constant (e.g., `SMB2_IOCTL`, `SMB2_SET_INFO`), not a value received from a server response. Therefore, `com_code` is not server-supplied.

#### 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 specifies which SMB2 command the kernel is preparing to send. It is always a kernel-defined constant (e.g., `SMB2_IOCTL`, `SMB2_SET_INFO`). The `le16_to_cpu` conversion is performed on this kernel-defined constant. The `com_code` will thus always be a valid, known SMB2 command code. The array `tcon->stats.smb2_stats.smb2_com_sent` is sized to accommodate all valid SMB2 command codes, meaning any valid `SMB2_COMMAND_*` constant will be within its bounds. No server-supplied input can cause an OOB access. Counterexample test: if `smb2_command` is `SMB2_IOCTL` (value `0x000B`), `le16_to_cpu(0x000B)` results in `com_code = 11`. This is a small, positive integer well within typical array bounds for SMB2 command statistics (e.g., `SMB2_COMMAND_COUNT` is usually around 50). This value is expected to be a valid index. No counterexample with server-supplied input is possible as the input is kernel-controlled.



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

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

> The `smb2_compression_capabilities_context` structure's `DataLength` field (`len`) is validated against the minimum required size to hold the `CompressionAlgorithmCount` (`count`) and the fixed header portion (`len < 8 + count * sizeof(__le16)`). More critically, the calling function `smb311_decode_neg_context` ensures that the total declared size of the current negotiate context (`sizeof(struct smb2_neg_context) + pctx->DataLength`) fits within the received SMB response buffer. This two-stage validation guarantees that any access to `ctxt->CompressionAlgorithms[i]` for `i < count` will remain within the bounds of the server-supplied buffer segment allocated for this context. The `ARRAY_SIZE` check, while potentially restrictive if `CompressionAlgorithms` is a flexible array member (`[]`), would only cause an early return, thus preventing potential OOB access rather than enabling it.

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

| 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) |

*Dismissed:* The variable `count` is derived from `ctxt->CompressionAlgorithmCount`, which is part of a server-supplied negotiate context. Therefore, it is server-supplied. The loop at line 867 iterates `count` times, accessing `ctxt->CompressionAlgorithms[i]`. The base of the `CompressionAlgorithms` array is at `(char *)ctxt + 12`. The extent of the data within the context, as declared by the server's `DataLength` field (variable `len`), is `(char *)ctxt + 4 + len`. The code performs two key validations:
1. In `decode_compress_ctx`, line 856: `if (len < 8 + count * sizeof(__le16))` checks if the declared `DataLength` is sufficient for `count` algorithms plus the fixed 8 bytes of `Reserved`, `CompressionAlgorithmCount`, and `Flags` fields. If this check passes, it means `len >= 8 + count * 2`.
2. In the caller `smb311_decode_neg_context`, line 1004: `if (clen > len_of_ctxts) break;` where `clen = sizeof(struct smb2_neg_context) + le16_to_cpu(pctx->DataLength)`. This ensures the entire context, including its variable `DataLength` payload, fits within the overall received buffer slice (`len_of_ctxts`).

Combining these: The array access `ctxt->CompressionAlgorithms[i]` is at address `(char *)ctxt + 12 + i * 2`. The maximum address accessed for `i = count - 1` is `(char *)ctxt + 12 + (count - 1) * 2`. The end of the valid region for this context is `(char *)ctxt + 4 + len`. Since `len >= 8 + count * 2`, we have `4 + len >= 4 + (8 + count * 2) = 12 + count * 2`. Thus, `12 + (count - 1) * 2 = 10 + 2 * count < 12 + 2 * count <= 4 + len`. This proves the access is in bounds.

Counterexample test:
Assume `len_of_smb = 100`, `offset = 20`, so `len_of_ctxts = 80`.
Caller's check: `clen = 8 + ctxt->DataLength_val`. `clen <= 80` implies `ctxt->DataLength_val <= 72`. So `len` (inside `decode_compress_ctx`) is at most 72.

If `count = 32`:
- `len < 10` (line 849) passes if `len >= 10`.
- `count > ARRAY_SIZE(ctxt->CompressionAlgorithms)`: If `ARRAY_SIZE` is, say, 1, this would cause an early return, preventing an OOB. If `ARRAY_SIZE` is ineffective or large enough, the check proceeds.
- `len < 8 + count * sizeof(__le16)` becomes `len < 8 + 32 * 2 = 8 + 64 = 72`. If `len < 72`, it returns. So `len` must be at least 72.
- So, `len = 72` and `count = 32` is a passing case. The loop runs for `i = 0` to `31`.
- The maximum access is `ctxt->CompressionAlgorithms[31]` which is at offset `12 + 31 * 2 = 12 + 62 = 74` from `ctxt`.
- The total size available for the context is `4 + len = 4 + 72 = 76` from `ctxt`.
- `74 < 76`, so the access is within bounds.



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

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

> The `fill_small_buf` function, and its caller `__smb2_plain_req_init`, are used to construct SMB2 *client requests*, not to parse server responses. The `smb2_command` argument passed to these functions is a kernel-controlled constant (e.g., `SMB2_QUERY_INFO`, `SMB2_SET_INFO`), representing the command the client *intends* to send. While `le16_to_cpu()` is used, this is a round-trip conversion of a kernel-defined constant, not an extraction of a server-supplied value. Therefore, the index used for `smb2_req_struct_sizes` is always a known, compile-time constant value, not an attacker-controlled input.

#### 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 originates from a kernel-defined constant, as seen in the call sites for `__smb2_plain_req_init` (e.g., `SMB2_SET_INFO`, `SMB2_QUERY_INFO`). These functions build client requests. When `le16_to_cpu(smb2_command)` is performed, it's effectively converting a known, constant kernel value. The kernel developers ensure that these constants correspond to valid indices within the `smb2_req_struct_sizes` array. An out-of-bounds access would imply a kernel programming error in defining the constants or the array, not an attacker-induced vulnerability via network input. No counterexample can be constructed because `smb2_command` is not attacker-controlled; it will always be one of the valid `SMB2_COMMAND_XXX` constants defined by the kernel.



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

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

> The function `parse_posix_ctxt` operates on a `create_context` structure (`cc`) which is passed from the caller `smb2_parse_contexts`. The caller performs robust validation of `cc->DataOffset` and `cc->DataLength` against the overall `create_context` block size (`cc_len`). Inside `parse_posix_ctxt`, the `posix_info_sid_size` helper function is used to determine the length of SIDs and is explicitly designed to perform bounds checking against the provided `(beg, end)` pointers. This layered validation covers both the pointer (`sid`) and the size (`sid_len`) for the `memcpy` operations.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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` is the return value of `posix_info_sid_size(sid, end)`. The source code for `posix_info_sid_size` clearly shows it performs multiple checks (`beg + 2 > end`, `subauth < 1 || subauth > 15`, `beg + total > end`) to ensure the calculated `total` (which becomes `sid_len`) does not exceed the `(end - beg)` boundary. Thus, the `memcpy` source read (`sid_len` bytes from `sid`) is protected from OOB reads. For the destination buffer, `posix->owner` and `posix->group` are `char[SMB_MAX_SID_SIZE]` (68 bytes). The maximum `sid_len` returned by `posix_info_sid_size` (when `subauth` is 15) is 68 bytes. Therefore, the `memcpy` destination write is also protected from OOB writes. Both source and destination bounds are sufficiently checked.


#### 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` (`sid = beg + 12`). The `beg` pointer is `(u8 *)cc + le16_to_cpu(cc->DataOffset)`. The caller function `smb2_parse_contexts` (lines 2477-2479) performs the following crucial validations: `doff < sizeof(*cc)` (ensuring `DataOffset` is past the header) and `check_add_overflow(doff, dlen, &len) || len > cc_len` (ensuring `DataOffset + DataLength` fits within the `create_context` block). This establishes that the `(beg, end)` range (where `end = beg + dlen`) is valid within the overall `create_context` buffer. Subsequently, `posix_info_sid_size(sid, end)` is called before the `memcpy`. As detailed in finding #1, `posix_info_sid_size` validates that `sid` itself and the data to be read from `sid` fits within the `(sid, end)` range. This layered validation prevents any OOB access through the `sid` pointer.



### <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 `parse_query_id_ctxt` function is a static helper that processes a `create_context` structure. Its sole call site in `smb2_parse_contexts` performs comprehensive bounds checking on the `DataOffset` and `DataLength` fields derived from the `create_context` structure. This validation ensures that the subsequent memory access in `parse_query_id_ctxt` is safe.

#### 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` (derived from `cc->DataOffset`) and `dlen` (derived from `cc->DataLength`) are genuinely server-supplied values as `cc` points into a network response buffer. However, the caller function `smb2_parse_contexts` (lines 2433-2496) performs critical bounds validation *before* calling `parse_query_id_ctxt`. Specifically, at lines 2477-2479, it checks:
1. `doff < sizeof(*cc)`: This ensures that the `DataOffset` is at least the size of the `create_context` header itself, preventing `beg` from pointing into the header unnecessarily or before it.
2. `check_add_overflow(doff, dlen, &len) || len > cc_len`: This ensures that the sum of `DataOffset` and `DataLength` does not overflow and that the entire data payload (`doff + dlen`) fits within the current `create_context` block, whose total length is `cc_len`. The `cc_len` itself is validated against the overall response buffer length (`rsp_iov->iov_len`).

Inside `parse_query_id_ctxt`, there's an additional check `dlen < sizeof(__le64)` (line 2386) which ensures the `DataLength` is at least 8 bytes, the size required for the `memcpy` sink. 

Combining these validations:
- The caller guarantees `doff + dlen <= cc_len`.
- `parse_query_id_ctxt` guarantees `dlen >= sizeof(__le64)` (i.e., `dlen >= 8`).
- From these, it can be deduced that `doff + sizeof(__le64) <= doff + dlen <= cc_len`. 

Therefore, the `memcpy` operation at line 2390 (`memcpy(&buf->IndexNumber, beg, sizeof(__le64));`) which reads 8 bytes starting at `cc + doff` is guaranteed to be within the bounds of the current `create_context` block (`cc` up to `cc + cc_len`).

Counterexample test: `sizeof(*cc)` is 30 bytes. Assume `cc_len = 40`. The caller validates `doff >= 30` (from `doff < sizeof(*cc)` check) and `doff + dlen <= 40`. `parse_query_id_ctxt` validates `dlen >= 8`. Let `doff = 30` and `dlen = 8`. These values pass all checks: `30 >= 30`, `30 + 8 = 38 <= 40`, `8 >= 8`. The `memcpy` accesses memory from `cc + 30` to `cc + 30 + 8 - 1 = cc + 37`. The valid range for this context block is `cc` to `cc + 39`. The access `cc + 30` to `cc + 37` is fully within bounds. No set of valid inputs can lead to an OOB access.



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

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

> The `posix_info_parse` function calculates its `end` boundary from a server-supplied `p->NextEntryOffset` when the `end` parameter is not explicitly provided by the caller. If `p->NextEntryOffset` is 0, it further inflates `end` by `0xFFFF`. This means `end` is a tainted trust boundary. While internal validation functions like `posix_info_sid_size` check if data fits within `beg` and this calculated `end`, these checks are insufficient because `end` itself can exceed the actual received network buffer's boundary. This allows for out-of-bounds reads from the source buffer during `memcpy` operations, even if the destination buffer is correctly sized due to internal length caps.

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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 from reading unmapped memory, or reading past allocated buffer into other kernel data. KASAN report if enabled.

**Fix:** Ensure the `end` parameter passed to `posix_info_parse` (or derived internally if `end` is NULL) represents a valid, trustworthy boundary within the actual received network buffer. If `end` is derived from `p->NextEntryOffset`, this value must be validated against the total received message length *before* it is used to define `end`. The `0xFFFF` fallback for `NextEntryOffset == 0` is particularly problematic and should be capped by the actual buffer size, or removed if `posix_info_parse` is not the top-level parser.

**CVE pattern:** Tainted trust boundary / Server-supplied length field leads to OOB


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

| Field | Value |
|---|---|
| Category | Cat B — server value → size/alloc argument |
| Taint source | via `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 from reading unmapped memory, or reading past allocated buffer into other kernel data. KASAN report if enabled.

**Fix:** Ensure the `end` parameter passed to `posix_info_parse` (or derived internally if `end` is NULL) represents a valid, trustworthy boundary within the actual received network buffer. If `end` is derived from `p->NextEntryOffset`, this value must be validated against the total received message length *before* it is used to define `end`. The `0xFFFF` fallback for `NextEntryOffset == 0` is particularly problematic and should be capped by the actual buffer size, or removed if `posix_info_parse` is not the top-level parser.

**CVE pattern:** Tainted trust boundary / Server-supplied length field leads to OOB


#### 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 from reading unmapped memory, or reading past allocated buffer into other kernel data. KASAN report if enabled.

**Fix:** Ensure the `end` parameter passed to `posix_info_parse` (or derived internally if `end` is NULL) represents a valid, trustworthy boundary within the actual received network buffer. If `end` is derived from `p->NextEntryOffset`, this value must be validated against the total received message length *before* it is used to define `end`. The `0xFFFF` fallback for `NextEntryOffset == 0` is particularly problematic and should be capped by the actual buffer size, or removed if `posix_info_parse` is not the top-level parser.

**CVE pattern:** Tainted trust boundary / Server-supplied length field leads to OOB



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

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

> The function `smb2_validate_and_copy_iov` is designed to copy a certain amount of data (`minbufsize`) from a server-supplied buffer (`iov`) at a given `offset`. It first calls `smb2_validate_iov` with the server-supplied `buffer_length` (from `rsp->OutputBufferLength`) and the requested `minbufsize`. The `memcpy` operation then uses `minbufsize` as the copy length.

The vulnerability arises when `minbufsize` (the kernel's requested copy amount, often a `sizeof(struct)`) is larger than `buffer_length` (the server's advertised data length), and `smb2_validate_iov` only validates `offset + buffer_length` against the actual received buffer (`iov->iov_len`). In such a scenario, even if `smb2_validate_iov` returns success, the subsequent `memcpy` (which uses `minbufsize`) could attempt to read past the end of the server's claimed data, leading to an Out-of-Bounds (OOB) read if `offset + minbufsize` exceeds the actual buffer boundary (`iov->iov_len`).

This is specifically an issue when `dlen` is NULL in `query_info`, because then `minbufsize` (passed as the 4th argument to `smb2_validate_and_copy_iov`) defaults to `min_len`, which is a kernel-controlled `sizeof()` value. This `min_len` can be greater than the `rsp->OutputBufferLength` (server-supplied) without being detected by `smb2_validate_iov` if `smb2_validate_iov` primarily relies on `buffer_length` for its bounds check.

#### 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 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 |
| Server-supplied | yes |
| Check present | yes |
| Check sufficient | no |

**Symptom:** Kernel panic from heap corruption (e.g., KASAN report) or information disclosure (reading adjacent kernel memory).

**Fix:** Before calling `smb2_validate_and_copy_iov` at line 4043 in `query_info`, the `minbufsize` argument (which is `dlen ? *dlen : min_len`) should be capped by `le32_to_cpu(rsp->OutputBufferLength)`. This ensures that the kernel never attempts to copy more data than the server claims to have sent.

Modified code in `query_info` around line 4041-4043:
```c
	unsigned int offset_val = le16_to_cpu(rsp->OutputBufferOffset);
	unsigned int output_buf_len_val = le32_to_cpu(rsp->OutputBufferLength);
	unsigned int copy_len = dlen ? *dlen : min_len;

	// Cap the copy length by the server's advertised OutputBufferLength
	if (copy_len > output_buf_len_val) {
		copy_len = output_buf_len_val;
	}

	rc = smb2_validate_and_copy_iov(offset_val, output_buf_len_val,
					&rsp_iov, copy_len, *data);
```
This ensures that `copy_len` passed to `smb2_validate_and_copy_iov` (which becomes `minbufsize` in that function and is used by `memcpy`) is never greater than `output_buf_len_val`. Assuming `smb2_validate_iov` checks `offset + output_buf_len_val <= iov->iov_len`, this makes the `memcpy` safe.

**CVE pattern:** SMB DataOffset OOB Read



### <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 employs a robust, multi-layered validation strategy. Initial validation at lines 2457-2458 ensures the entire block of `CreateContexts` (defined by `CreateContextsOffset` and `CreateContextsLength`) fits within the `rsp_iov` buffer. Inside the `while` loop, `rem` tracks the remaining length of this block. Each iteration ensures `rem >= sizeof(*cc)` before accessing any `cc` fields, guaranteeing the `create_context` header itself is readable. The `cc->Next` field (representing the length of the current context, `cc_len`) is thoroughly validated (lines 2467-2469) against alignment, `rem` (ensuring it doesn't exceed the block's boundary), and `sizeof(*cc)` (ensuring it's at least the header size). Finally, the `DataOffset/Length` and `NameOffset/Length` fields are validated against `cc_len` (lines 2477-2479, 2483-2485), ensuring their payloads stay within the current context's bounds. This cascading validation makes all flagged accesses safe.

#### 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, initialized from `rsp->CreateContextsLength`, is an upper bound on the *total* length of the contexts block. It is initially validated at line 2457-2458 (`len > rsp_iov->iov_len`), ensuring the entire block fits within the received buffer. Inside the loop, `rem` is progressively reduced by `off = le32_to_cpu(cc->Next)`. This `off` is itself validated at line 2468 (`off >= rem`) to prevent an over-large context length from prematurely exhausting `rem` or causing negative `rem`. The loop condition `rem >= sizeof(*cc)` ensures that at least one context header can be read. The combination of these checks means the loop is properly bounded by the overall packet length and the integrity of the context chain. Counterexample test: If `rsp_iov->iov_len = 10`, `rsp->CreateContextsOffset = 0`, `rsp->CreateContextsLength = 100` (server sends too large). Line 2457-2458 will trigger `len > rsp_iov->iov_len` (100 > 10) and return -EINVAL. If `rsp->CreateContextsLength = 8` (smallest), `rem = 8`. Loop `rem >= sizeof(*cc)` (8 >= 8 assuming `sizeof(*cc)=8`) runs. If `cc->Next = 0`, `cc_len = rem = 8`. Validation of `doff/dlen` and `noff/nlen` checks against `cc_len=8`. Then `rem=0` and loop terminates. If `cc->Next=10`, line 2468 `off >= rem` (10 >= 8) is true, returning -EINVAL. The loop iteration count is properly constrained.


#### 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 `rsp` using `CreateContextsOffset`. The initial validation at lines 2457-2458 (`len > rsp_iov->iov_len`) ensures that the entire block of contexts, from `rsp + off` to `rsp + off + rem`, fits within `rsp_iov`. This means the initial `cc` points within bounds. All subsequent accesses to `cc->Next`, `cc->DataOffset`, etc., occur within a `while (rem >= sizeof(*cc))` loop, which ensures that at least the header of `cc` is readable. When `cc` is advanced using `off = le32_to_cpu(cc->Next)`, this `off` value is validated at lines 2467-2469 (`(off & 0x7) || off >= rem || off < sizeof(*cc)`) to ensure it's aligned, doesn't exceed the `rem`aining block length, and is at least `sizeof(*cc)`. This sequence of checks guarantees that `cc` always points to a valid `create_context` header within the allocated buffer. Counterexample test: Assume `sizeof(*cc) = 8`. If a server provides `rsp->CreateContextsOffset = 95` and `rsp->CreateContextsLength = 10` into a `rsp_iov->iov_len = 100` buffer, then `off=95, rem=10, len=105`. The check `len > rsp_iov->iov_len` (105 > 100) at line 2457-2458 would return -EINVAL. If `rsp->CreateContextsOffset = 0`, `rsp->CreateContextsLength = 100`, `rsp_iov->iov_len = 100`. Initial `cc` is at `rsp`. `rem=100`. In the loop, if `cc->Next` is parsed as 5 (misaligned) or 1 (too small), line 2468 would trigger `EINVAL`. If `cc->Next` is parsed as 101, line 2468 `off >= rem` (101 >= 100) is true, triggering `EINVAL`. The access to `cc->Next` at lines 2466 and 2511 are thus guarded.


#### 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` by adding `noff` (`cc->NameOffset`). The `nlen` is `cc->NameLength`, which for this sink is explicitly 16 bytes. The validation at lines 2483-2485 checks `noff < sizeof(*cc)` (ensuring `name` does not point into the `create_context` header), `check_add_overflow(noff, nlen, &len)` (checking for arithmetic overflow), and `len > cc_len` (ensuring `name + nlen` is within the current context's `cc_len`). This sequence of checks guarantees that the `16` bytes read by `memcmp` starting from `name` will be within the valid bounds of the current `create_context` structure. Counterexample test: Let `cc` be at buffer offset 0. Assume `cc_len = 50`. If `cc->NameOffset = 40` and `cc->NameLength = 16`. Then `noff = 40`, `nlen = 16`. `check_add_overflow(40, 16, &len=56)`. Then `len > cc_len` (56 > 50) is true, triggering -EINVAL at line 2484. The `memcmp` will not be reached. If `cc->NameOffset = 7` (less than `sizeof(*cc)`, assuming 8), line 2483 `noff < sizeof(*cc)` (7 < 8) is true, triggering -EINVAL. The `memcmp` is properly guarded.


#### 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 `cc` pointer passed to `parse_query_id_ctxt()` is already validated by the `smb2_parse_contexts()` function's overall logic (see findings #1 and #2). Within `smb2_parse_contexts()`, the `doff` (DataOffset) and `dlen` (DataLength) fields are extracted from `cc` and validated at lines 2477-2479: `doff < sizeof(*cc)` (ensuring `beg` does not point into the header), `check_add_overflow(doff, dlen, &len)` (overflow check), and `len > cc_len` (ensuring `beg + dlen` is within the current context's `cc_len`). Inside `parse_query_id_ctxt()`, before `memcpy` is called, there's an explicit check at line 2386: `if (dlen < sizeof(__le64)) return;`. This ensures that the `dlen` value (which determines the maximum available bytes for `memcpy`) is at least `sizeof(__le64)` (8 bytes). Combined, these checks guarantee that `beg` points to a valid location within the current `create_context`, and there are at least `sizeof(__le64)` bytes available from `beg` within the bounds established by `cc_len`. Counterexample test: Let `cc` be at buffer offset 0, `cc_len = 50`. If `cc->DataOffset = 40` and `cc->DataLength = 7`. Then `doff = 40`, `dlen = 7`. In `smb2_parse_contexts()`, the check `doff < sizeof(*cc)` (40 < 8 assuming `sizeof(*cc)=8`) is false. `check_add_overflow(40, 7, &len=47)`. `len > cc_len` (47 > 50) is false. The call to `parse_query_id_ctxt()` proceeds. Inside `parse_query_id_ctxt()`, the check `dlen < sizeof(__le64)` (7 < 8) is true, causing the function to return before `memcpy` is reached. If `dlen = 8`, `memcpy` will copy 8 bytes from `cc + 40` to `cc + 47`, which is within `cc_len=50`. The access is guarded.



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

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

> The function correctly validates server-supplied offsets and lengths before dereferencing pointers or advancing through contexts. Loop iteration count (ctxt_cnt) is effectively bounded by per-iteration checks against remaining buffer size, and pointer dereferences are guarded by checks ensuring at least the size of the accessed struct header remains in the buffer.

#### 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 loop iteration count `ctxt_cnt` is server-supplied, but the loop body contains sufficient per-iteration bounds checks. Specifically, `if (len_of_ctxts < sizeof(struct smb2_neg_context)) break;` (line 991) ensures that there's always enough space for the next context header before `pctx` is formed and dereferenced. Additionally, `if (clen > len_of_ctxts) break;` (line 1004) ensures the entire context (header + data) fits. If `ctxt_cnt` is excessively large, these checks will cause the loop to terminate early, preventing any out-of-bounds access. This matches pattern (b) described in the finding note. Counterexample test: If `len_of_smb=10` and `ctxt_cnt=1000`, and `sizeof(struct smb2_neg_context)=8`, then `len_of_ctxts` will quickly drop below 8, causing the loop to break safely at line 991 after processing at most one context, without OOB.


#### 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 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 |

*Dismissed:* The pointer `pctx` is derived from `offset`, which is server-supplied. However, validation occurs before `pctx->DataLength` (or `pctx->ContextType`) is accessed. Initial validation: `if (len_of_smb <= offset)` (line 981) ensures the initial offset is not beyond the total SMB message length. Inside the loop, before `pctx` is formed and dereferenced, `if (len_of_ctxts < sizeof(struct smb2_neg_context))` (line 991) explicitly checks that the remaining buffer `len_of_ctxts` is large enough to contain the `smb2_neg_context` header. This guarantees that `offset + sizeof(struct smb2_neg_context)` will not exceed `len_of_smb`, making the subsequent accesses to `pctx->DataLength` and `pctx->ContextType` safe. This addresses both lower and upper bound concerns for accessing the header. Counterexample test: If `len_of_smb=100`, `offset=98`, and `sizeof(struct smb2_neg_context)=8`, then `len_of_ctxts` becomes 2. The check `if (2 < 8)` at line 991 is true, causing a `break` before `pctx` is even assigned, let alone dereferenced. If `offset=92`, `len_of_ctxts` is 8. The check `if (8 < 8)` is false, `pctx` is formed, and `pctx->DataLength` is accessed. This is safe because `sizeof(struct smb2_neg_context)` (8 bytes) exactly fits within `len_of_ctxts` (8 bytes), placing `DataLength` and `ContextType` safely within bounds. Any `DataLength` value that would make the total context length exceed `len_of_ctxts` is caught by `if (clen > len_of_ctxts)` at line 1004.



### <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 analyzer incorrectly identifies `rc` as the variable being truncated. `sid` (a `__u64` representing the SessionId from the server) is passed as an argument to `smb2_get_sign_key`. The `smb2_get_sign_key` function expects a `u64` for its session ID parameter, so no truncation of `sid` occurs when it is passed. The variable `rc` receives the `int` return value of `smb2_get_sign_key`, which is a standard error code and not a truncated version of `sid`.

#### 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 states that the 64-bit `sid` is truncated to the 32-bit `rc`. In the line `rc = smb2_get_sign_key(server, sid, key);`, `rc` receives the integer return value of `smb2_get_sign_key`. The `sid` variable, which is a `__u64`, is passed as an argument. Looking at the signature of `smb2_get_sign_key` (e.g., in `fs/cifs/smb2pdu.c`), it takes a `u64` for the session_id parameter (`int smb2_get_sign_key(struct TCP_Server_Info *server, u64 session_id, u8 *key)`). Therefore, there is no truncation of `sid` to a narrower type, either at the point of assignment to `rc` (as `rc` is the return code, not `sid`) or when `sid` is passed as an argument.



### <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 used to initialize an outgoing SMB2 request header (`shdr`) before it is sent to the server. The `shdr` struct is therefore built by the kernel, not populated from a server response. The `CreditCharge` field within this request header is a kernel-controlled value (typically `1` for initial requests or `0` for some specific messages), set via `cpu_to_le16()` by the kernel code. Therefore, `le16_to_cpu(shdr->CreditCharge)` is converting a value *previously written by the kernel* back to host byte order, making it a locally-controlled value, not server-supplied. Per false positive pattern 1, this makes the finding a false positive.

#### 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 `smb2_hdr *shdr` argument is obtained from `rqst->rq_iov[0].iov_base` in the call sites. Both `smb2_setup_request` and `smb2_setup_async_request` are functions responsible for *constructing* SMB2 requests to be sent to the server. This means `shdr->CreditCharge` is a field that the kernel itself writes, not reads from the server. As such, the value `num` derived from `le16_to_cpu(shdr->CreditCharge)` is kernel-controlled. Typically, for requests, `CreditCharge` is set to `1` (via `cpu_to_le16(1)`), which would result in `num=1`. In this case, the loop `for (i = 1; i < num; i++)` would not execute, as `i < 1` is false. Even if `CreditCharge` were allowed to be larger, the `get_next_mid(server)` function simply increments a message ID counter and does not perform any memory access that would go out of bounds based on the loop iteration count. The finding category 'server-supplied value controls loop iteration count without buffer bounds validation' does not apply because the value is not server-supplied and the loop does not involve buffer bounds access at the sink.



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

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

> The static analysis finding appears to misinterpret the data flow. The `le64_to_cpu(shdr->SessionId)` expression produces a `u64` value, which is correctly passed as a `u64` argument to the `smb3_get_sign_key` function. The `rc` variable is declared as an `int` and stores the `int` return value of `smb3_get_sign_key`. There is no truncation of the 64-bit `SessionId` value into the `rc` variable; `rc` is merely storing the function's status 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 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 `le64_to_cpu(shdr->SessionId)` results in a `u64` value. This `u64` value is then passed as the `sessionId` argument (type `u64`) to `smb3_get_sign_key`. The `rc` variable, which is an `int`, receives the *return value* of `smb3_get_sign_key` (which is also an `int`), not the `SessionId` itself. Therefore, no truncation of the 64-bit `SessionId` to a 32-bit `int` occurs. The finding incorrectly identifies `rc` as the target of the `le64_to_cpu`'s 64-bit value truncation, when `rc` is merely the function's error code container.



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

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

> The `__release_mid` function processes a `mid_q_entry` structure, which contains server-supplied information. The `midEntry->command` field, after `le16_to_cpu` conversion, represents an SMB command. This command is used as an index into various statistics arrays within the `server` structure (e.g., `server->num_cmds`, `server->slowest_cmd`, `server->fastest_cmd`, `server->time_per_cmd`, `server->smb2slowcmd`). Crucially, all uses of this server-supplied `smb_cmd` as an array index are protected by a bounds check: `if (smb_cmd < NUMBER_OF_SMB2_COMMANDS)`. Since `smb_cmd` is an unsigned `__u16`, it cannot be negative, and this upper-bound check is sufficient to prevent out-of-bounds array 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 is populated with data from a received server response. Therefore, `smb_cmd` derived from it is genuinely server-supplied. The array `server->num_cmds` (and other similar arrays like `server->slowest_cmd`, `server->fastest_cmd`, `server->time_per_cmd`, `server->smb2slowcmd`) is indexed by `smb_cmd`. This index is explicitly checked against the array's maximum valid index by `if (smb_cmd < NUMBER_OF_SMB2_COMMANDS)` at lines 68 and 98. Since `smb_cmd` is an unsigned `__u16`, it implicitly satisfies `smb_cmd >= 0`. The guard ensures `smb_cmd` is strictly less than `NUMBER_OF_SMB2_COMMANDS`, covering all valid indices `[0, NUMBER_OF_SMB2_COMMANDS - 1]`. Therefore, the bounds check is both present and sufficient. No counterexample can cause an OOB access past this guard. Tested values: If `NUMBER_OF_SMB2_COMMANDS` is N, `smb_cmd = 0` (in bounds), `smb_cmd = N-1` (in bounds), `smb_cmd = N` (guard prevents access), `smb_cmd = N+k` (guard prevents access). The SMT result correctly indicates `smb_cmd` cannot be negative.


