Repository navigation
storage: mount SMB ISO images with on-demand CIFS and hardware AES - #492
dormancygrace wants to merge 7 commits into
Conversation
Build outputsCompared with the build of main at 58bdc0d; codex/remote-http-iso is at 14f72ee, so outputs changed since then are listed too. 26 changed, 155 added, 144 removed of 581 outputs.
|
There was a problem hiding this comment.
The security-relevant parts hold up.
- Credentials: they travel over a socketpair and become separate
fsconfigstrings. They never appear in argv, the environment, a file or an API response, and an empty username is rejected. - No option injection: nothing goes through a comma-separated mount string. The path parser rejects
..,\,:and control characters, and the file is opened withopenat2(RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS)on a read-only, nosuid, nodev, noexec detached mount. - Protocol: SMB1 is not built, and
sec=ntlmsspirequires signing. - 0052 and 0053: both match v7.3, and the
-EBADMSGhandling is a real fix.
go vet and go test for ./remotemedia ./service/storage pass on the host.
Two general notes:
dormancygrace
left a comment
There was a problem hiding this comment.
Reviewed source validation, private helper/relay lifetime, detached read-only mounts, required signing, CMAC/CCM request handling and CIFS signature-error propagation. Fixed deadline/UI diagnostics and added independent client signing-policy coverage in 143bad7, incorporating the HTTP and browser read fixes from #491/#486. Host Go race/vet, the real Samba source/service suite, signing negative control, web tests/typecheck/lint and zero-fuzz Linux 7.3 CIFS patch application pass. SG2002 crypto and patched-kernel signature-corruption qualification were not rerun here. Security regression coverage and inherited runtime fixes are substantive; this PR remains open.
Adds read-only
smb://server/share/path/image.isomounting to the main server and the existing Images → From URL flow, without copying the ISO to the SD card. This PR is stacked on #491, which retains #486's browser prefetch implementation.The Linux CIFS client ships as a module and loads when SMB is first requested. SMB2.1/3 uses NTLMv2 with required signing and supports shares requiring encryption. Credentials pass through private IPC and separate
fsconfigvalues, never command arguments or credential files. The detached mount is read-only/noexec/nodev/nosuid; the ISO is opened beneath it with symlinks disabled. A bounded helper and a single-use splice TCP relay enforce the 10-second open/read deadline and cancellation. Disconnect releases the helper, connection and mount. Reads retain the adaptive 1 MiB RAM window and size/mtime checks.SG2002 now supplies hardware AES-CMAC signing and full hardware CCM encryption through the Linux Crypto API. CMAC uses hardware subkey derivation and CBC; CCM uses hardware CBC-MAC and CTR. Both share the existing engine with GCM, limit DMA chunks to 4 KiB, and preserve the hardware-AES setting and software fallback. GCM continues to combine hardware CTR with optimized CPU GHASH. Cipher negotiation is unchanged.
CIFS CMAC calculations own their transform/key, allowing signing and verification to run concurrently without a key race. The kernel patch also preserves verification failures through synchronous and compound-response handling: an invalid metadata signature can no longer be overwritten by a successful wire status. SMB2.1 HMAC signing is unchanged. The accompanying NLS cleanup fix releases references after failed mounts.
Measured on SG2002, 100 Mbit/s Ethernet
Matched 64 MiB source and read pattern; hardware disabled for the first three rows:
The complete server reader, including cancellation relay and IPC, reaches 8.65–8.72 MiB/s with hardware CMAC, versus about 5.8 MiB/s with software signing (about 50% faster). For encrypted shares it reaches 7.97–8.03 MiB/s with CCM against 6.81–7.04 MiB/s with GCM (about 15% faster).
Software/hardware sessions were alternated, with two sequential rounds each. All full-image SHA-256 checks match. Samba negotiation confirms the intended signing/encryption; DMA counters confirm hardware CMAC use and no DMA in software controls. Raw 64 KiB CMAC measures 131.4 versus 15.0 MiB/s; CCM/GCM decryption measures 61.8 versus 28.9 MiB/s. At 64-byte CMAC messages DMA overhead makes hardware slower than software. Random-read latency varied, so no latency improvement is claimed.
These are source measurements, not USB throughput guarantees. Unsigned mode is benchmark-only; production requires signing/authenticated encryption. Reproduction details and limits are in
platform/modules/sg2002-aes/test/README.md.A three-run CMAC crossover sweep finds the first consistent DMA win at 304 bytes including a new transform/key per message as in CIFS. CIFS now selects CPU CMAC below 320 bytes and the highest-priority provider (normally SG2002 DMA) from 320 bytes upwards. It counts every header vector and payload byte, and selects before key setup so short signatures submit no DMA. Larger messages still work on software when hardware AES is disabled.
The actual production selector passed fragmented-message/tag, length-overflow and provider-boundary tests with and without hardware. Isolated 319-byte signatures submit zero DMA operations; 320-byte signatures submit three. In three matched sessions per implementation, automatic selection reduced AES submissions from 51,374 to 50,258 (about 2.2%); all six full-image checksums match. Median sequential reader throughput is unchanged within measurement noise: 8.72 MiB/s before versus 8.71 MiB/s after. The real SMB suite, including corrupted READ and metadata signatures, passes with automatic selection.
Validation
SMB requires the accompanying kernel modules from an OS update; a server-only update on an older kernel reports unavailable CIFS support. No boot-time CIFS service is added.
Review corrections: actionable timeout/server errors; CMAC preload declaration; an optional-signing Samba fixture that verifies the client requirement and signed READ packets. Host race/vet, real Samba source/service tests and the signing negative control pass, as do web type/lint/error/lifecycle/i18n tests and zero-fuzz CIFS patch application.