# SCSI VERIFY: audit the reference and the submitted range

Observed 29 November 2026. Author-verified research, not hardware certification.

## Finding

A verification utility's successful exit is not a completion receipt. With only
three input bytes for a requested 1,536-byte reference, the tested sg_verify
clients returned exit 0 after an input error, before opening the device.
This also happened without the capture library, using a nonexistent device path.
Complete input with that same path returned 52 (file not found).

A separate client-call capture contradicts the versioned manual's single-command
description: count=3, bpc=1 and ndo=1536 produced three one-block VERIFY calls,
each carrying the entire same 1,536-byte reference. The client printed that bpc
was ignored. Setting bpc=3 produced one three-block call. No device accepted or
rejected these calls: the harness supplied their return statuses.

These findings connect three separate contracts: bytes acquired from the
reference input, command construction by the client, and checks performed by
the target. A successful check at one boundary does not establish the others.

## Evidence and version scope

The installed Ubuntu package was sg3-utils 1.46-3ubuntu4.1, reporting client
version 1.27 20201029. The unmodified v1.48 sg_verify.c was compiled at -O0 and
-O2, reporting 1.30 20230623. Both source builds use v1.48 headers and the installed
1.46 shared helper library. This is not a full v1.48 distribution build.
The three clients have the same scenario outcomes; they are not three independent
implementations or populations.

There are 12 deliberately chosen scenarios per client, plus a short/complete
input pair per client without LD_PRELOAD. observations.json retains argv, full
input and reference bytes, output, statuses, hashes and environment. replay.json
is a separate rerun. summary.json is generated by verify.py, not hand-transcribed.

| Boundary | Selected observation | What remains unknown |
| --- | --- | --- |
| Medium-only range | 257 blocks split 128, 128, 1 | Device checks and physical access |
| Per-block reference | Three one-block calls reuse all 1,536 bytes | Transport/target handling of mismatched length |
| Aligned control | One three-block call with 1,536 bytes | Actual comparison result |
| Repeated-block mode | BYTCHK=3 reuses one 512-byte reference | Device support and protection configuration |
| Reserved mode | BYTCHK=2 reaches the intercepted library call | Device acceptance; not a valid-mode guarantee |
| Legacy spelling | --bytchk=3 means three reference bytes, mode 1 | It is not --ebytchk=3 |
| Short input | Exit 0, input diagnostic, no open or VERIFY call | Behavior when a different prior errno is present |
| Injected failure | Return 14 on call two stops before call three | No real medium error was induced |

All numerical outcomes are constructed client tests, not a rate of field failures.
The comparison fixture uses distinct A, B and C blocks, so full-buffer reuse
cannot be mistaken for advancing to the next block's reference.

## Mechanism and source synthesis

The pinned manual promises a single command when ndo is supplied. The client
prints an override message but never assigns count to bpc in that branch.
Its loop advances LBA while passing the same reference pointer and length.
This explains the captured difference; it does not predict a particular
device's response to an oversized buffer.

On short input, read returns zero at EOF. The error branch converts errno
rather than establishing an EOF-specific error. EOF need not set errno;
zero maps to success in the linked helper. The unmocked controls delimit the
claim: zero was observed here, not guaranteed under every process state.

The newer command reference distinguishes no host reference (BYTCHK=0),
per-block reference (1), and one repeated block (3). A repeated-pattern check
cannot certify arbitrary per-LBA contents. Mode 2 being accepted by the
utility parser does not remove its reservation in the cited SBC-3 revision.
Protection information and unmapped-LBA behavior add conditions; these were
not exercised. DPO concerns cache priority, not proof of a physical read.
[manual, command-reference, driver]

The installed client's legacy --bytchk spelling is a byte-count alias. The
mode selector is --ebytchk. Similar names are not evidence of equivalent
command fields. [client]

## Relation to Hesela

This extends the existing [SCSI VERIFY term](https://hesela.dev/terms/scsi-verify/)
and [HDD write-verification analysis](https://hesela.com/analyses/hdd-write-verification-iraw/).
The existing distinction between persistence, readability and payload comparison
remains correct. The new missing layer is evidence that the intended range and
reference reached the command boundary at all. No new article or glossary ID
is needed.

For an auditable verification record, retain the exact binary, complete reference
length/hash, submitted ranges, individual statuses and diagnostic output.
Use an independent acceptance condition for reference completeness and coverage.
These are reporting requirements, not a ready-to-run command against a disk.
Do not run the deliberately inconsistent fixtures on production devices.

## Reproduction and safety

Run from the repository root, with Linux, a C compiler, Python standard library,
sg_verify and libsgutils2-1.46.so.2 available. No package install is performed.

```sh
python3 -B content/research/scsi-verify-reference/run.py --upstream content/research/scsi-verify-reference/upstream --output /tmp/scsi-verify-fresh.json
python3 -B content/research/scsi-verify-reference/verify.py /tmp/scsi-verify-fresh.json
python3 -B -m unittest discover -s content/research/scsi-verify-reference -p test_verify.py -v
```

The fake device name must not exist. Interposition replaces device open, close,
VERIFY(10) and VERIFY(16); unexpected ioctl or do_scsi_pt terminates the process.
Temporary executables are removed automatically. The unmocked controls use only
the nonexistent filename, never /dev paths. The source fetcher refuses to
overwrite retained snapshots and is unnecessary for offline replay.

This is capture at the client/library boundary, not CDB or kernel tracing.
Return 0/14 from the mock is injected. No physical drive, firmware, bridge,
actual medium comparison, fault injection into storage, persistence or timing
was tested. No security-vulnerability or first-discovery claim is made.
The upstream-current source hash comparison is source-only, not execution of
a complete current release.

## Sources and reuse

[Download the evidence packet](https://hesela.dev/research/scsi-verify-reference/evidence.zip).
[Raw observations](observations.json), [separate replay](replay.json),
[generated summary](summary.json), and [source ledger](sources.json) are also available individually.

See sources.json for exact URLs, revisions, locations and the evidence each
supports. Upstream snapshots retain their BSD-2-Clause license. New capture and
validation code is MIT licensed (LICENSE). The restricted vendor manual is
linked, not redistributed. The public packet excludes exploratory observations;
the final two captures are retained without rewriting.
