Skip to content

fix(storage): pass unknown --efs-mount-options through, refuse unsafe ones (#1390) - #1401

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1390-efs-mount-options
Oct 28, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1390-efs-mount-options

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1390

storage.ParseCustomOptions dropped every option it had no field for, so --efs-mount-options nconnect=8,timeo=600 mounted with timeo=600 and no nconnect, and nothing said so.

The storage script mounts with mount -t nfs4 (the kernel NFS client, from nfs-utils), not amazon-efs-utils mount -t efs. The kernel client has supported nconnect since Linux 5.3, and AL2023 runs 6.x. So the fix passes options through instead of refusing them:

  • A well-formed option the parser doesn't model (name or name=value, letters/digits/_ . -, plus : / + in a value) is added verbatim to the new EFSMountOptions.Extra and emitted before _netdev. It reaches both mount -t nfs4 -o commands (by mount-target IP and by DNS) and the fstab line.
  • Refused, with an error naming --efs-mount-options and the option:
    • shell/fstab metacharacters or whitespace;
    • a non-numeric value for rsize/wsize/timeo/retrans/actimeo (these used to become 0 without a word);
    • efs-utils-only options (tls, iam, accesspoint, ...), which mount -t nfs4 rejects at boot.
  • runLaunch checks the flag before its first AWS call. A single launch renders the storage script only after creating the key pair, role and security group. The sweep paths already render every member before creating anything.
  • Shell safety still comes from ShellQuote (shellEscape) on the whole option string. The character set exists to keep the fstab line six fields long and the option list a list.

Gates. Each one was watched failing against a compiling revert:

  • TestEFSMountOptionsReachTheMountOnEveryPath covers the single launch (launchStorageScript), the foreground sweep and the detached sweep. With nconnect=4 it checks both mount commands and the fstab line exactly. Against the pkg/storage/efs.go revert, all 3 nconnect=4 subtests fail.
  • TestEFSMountOptionsWithMetacharactersAreRefusedOnEveryPath sends ;, $(...) and ' options down all 3 paths. Against the revert, all 9 subtests fail (the options were accepted).
  • Known options are unchanged:
    • The timeo=150 subtests on all 3 paths and TestParseCustomOptionsKnownOptionsUnchanged pass on the revert, matching the old output exactly.
    • A naive "pass the raw string" mutation makes all 3 timeo=150 subtests fail.
    • Mishandling a user-supplied _netdev makes the storage gate fail.
  • TestParseCustomOptionsPassesUnknownOptionsThrough / ...RefusesWhatItCannotPass fail against the revert.
  • TestValidateEFSMountOptionsFlag fails when the runLaunch call is removed.

User-data size: the template is unchanged. Only the option string grows, by the option itself. TestBareBootstrapFitsItsBudget, the pkg/tasklaunch user-data tests and the pkg/userdata tests all pass.

Checks: make check, make lint (0 issues) and semgrep scan --config=auto --error . are clean. make api-snapshot adds the new Extra field. Help text is unchanged.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_single.go 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

… ones (#1390)

ParseCustomOptions silently dropped every option it had no field for
(nconnect, noac, lookupcache, ...). Well-formed unknown options now reach
the mount -t nfs4 command and the fstab line verbatim via
EFSMountOptions.Extra; malformed/metacharacter options, non-numeric values
for numeric options, and efs-utils-only options (tls, iam, accesspoint, ...)
are refused, and runLaunch refuses them before any AWS call.
@scttfrdmn
scttfrdmn force-pushed the fix/1390-efs-mount-options branch from 4472de6 to 5422dce Compare October 28, 2026 21:34
@scttfrdmn
scttfrdmn merged commit 85ac50f into main Oct 28, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1390-efs-mount-options branch October 28, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--efs-mount-options silently drops options it does not know (nconnect, etc.)

1 participant