From nobody Mon Nov 16 21:00:48 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jT0dF3Bhgz70wcf for ; Mon, 16 Nov 2026 21:00:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jT0dD6Rd1z4Ckf for ; Mon, 16 Nov 2026 21:00:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rrp3r/5hhJCYWZzAnJOpGm4nWAhW9dMOpLcUACqTpa4=; b=FbonzWmMBc25loVk4GDM4h5qGYB0NB7VNdf2E8SadJETJFqUsU5n63qU2PgkA+Z4bNR3y9 4DjwPa7HfQ1b9SjIPtcWDLtwZpMuQ0tmod/kPjFcHXwurl+nL1TAyjXELvjCVa+yc3rzjm YFI8SXud5/HDY6xtQ/MpeI82J6chaTaEBTy32fr+nr1r/ad7G0mnN5Un12/h4c7rrWq3di 2/98r+CMOpZlieQMIBZCgvH3mCYX3B9+gvrOilxgvta7w1EbJk3R0+PQEOP1lmpyG120SE ES1jJMt06o1wUukvrO2XFx/OTatBiZpdiVlMuDzZl8NfqbfYDQkIT1DRWFmRjA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862848; b=lYAGwrcMMs5S+GaruOxd9mADXGM3VMOjTe2FPJzsrl6eAcKEiwOAVia42JyeagnbKD45tY 6dLJ0bBeI9NnBXk/RQ7qlY9+1CYXSa2yJ3rTT4FKLm/cd76ouq5Mx2rbfGinHnuO3Ewx4G ZnBunYi/EpwjZlsI2nynk3JBx8xmP2T8Q6FvpH1/Z4ZMlLLGT1ekw79AQFRcMNr6gW4FgR YpOadmMcGTqoCwI963IuMhj05Av777viU3hejBMHxwx08OGhnAMYbaLrrRS1rcdNmyA0JB rR9naCi6Efdn23PY2JHnVivIqemXtXI3qSSMWarFNyoQATmiB8tNBkxaEKoFAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rrp3r/5hhJCYWZzAnJOpGm4nWAhW9dMOpLcUACqTpa4=; b=jNIoFtsm7V9n7H/UMj86WmzMCcZxjypxRvDF3GQQUVrOip5qxAxJizYNMVf8cJ4dcYoj/s 6LpRtjBOwUubwG5IIokNUfTlLs+mDZPZwwCqCOOn9Vs1U9W+AG72kxYbJ97lV84V4f4n98 8LNpEUEYzjw90OwHEeFvVpYQ5SnUrPAR2bk19U0MdJ786Q/PvSUtmwPR2jlG8ZKY+6FVF5 iKYOn4IVgY1sDn74HzDh1Sn7WWRhZBbtrf7tfdXO9pTP7N5QeBEp9N0RMKfAaFSVC8KTyY Iq6skyT1Tm9R7XaFxclDmOPURdUDWi/Vpd0MYi58lRuZLp3fbYkoE9fWVp6C+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jT0dD5qvjz19Z7 for ; Mon, 16 Nov 2026 21:00:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 7c74 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:00:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: e02aae338b1b - stable/15 - nvmecontrol: Range-check the format command's field values List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ken X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e02aae338b1bc52426dd055b34979eda7a353d47 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:00:48 +0000 Message-Id: <6afb6f00.7c74.30d92d80@gitrepo.freebsd.org> The branch stable/15 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=e02aae338b1bc52426dd055b34979eda7a353d47 commit e02aae338b1bc52426dd055b34979eda7a353d47 Author: Kenneth D. Merry AuthorDate: 2026-11-10 21:12:21 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 16:14:21 +0000 nvmecontrol: Range-check the format command's field values The format command accepted any 32-bit value for -m, -p, -l and --ses and passed it into the Format NVM command. Before eae727676169 an out-of-range value spilled into the adjacent cdw10 fields, which usually drew an error from the controller; after it, the value is masked to the field width, so a mistyped value is silently accepted with a different meaning. Most seriously, --ses 8 masked to SES=0 and performed a plain format with no erase at all, exiting 0. A value like --ses 10 masked to a cryptographic erase while bypassing the FNA cryptographic erase capability check, which compares the unmasked value. Reject values outside the ranges nvmecontrol.8 documents, which are the values the spec defines: 0-1 for -m and -l, 0-3 for -p, and 0-2 for --ses. The checks run at option validation time, before the device is opened, and the capability check now only ever sees valid values. While here, document --ses in nvmecontrol.8; it was missing from the format subcommand's option list. Reported by: llm-postcr Reviewed by: imp Fixes: eae727676169 MFC after: 1 week Sponsored by: Spectra Logic Assisted-by: Claude Fable 5 Differential Revision: https://reviews.freebsd.org/D61406 (cherry picked from commit 3d6f886151f9ee6f3bf16ea3367a4b540df3f911) --- sbin/nvmecontrol/format.c | 10 ++++++++++ sbin/nvmecontrol/nvmecontrol.8 | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sbin/nvmecontrol/format.c b/sbin/nvmecontrol/format.c index 741a69412e58..c88192e5d01e 100644 --- a/sbin/nvmecontrol/format.c +++ b/sbin/nvmecontrol/format.c @@ -127,6 +127,16 @@ format(const struct cmd *f, int argc, char *argv[]) "Only one of -E, -C or -s may be specified\n"); arg_help(argc, argv, f); } + if (opt.ms != NONE && opt.ms > 1) + errx(EX_USAGE, "metadata setting must be 0 or 1"); + if (opt.pi != NONE && opt.pi > 3) + errx(EX_USAGE, + "protection information type must be between 0 and 3"); + if (opt.pil != NONE && opt.pil > 1) + errx(EX_USAGE, + "protection information location must be 0 or 1"); + if (opt.ses > SES_CRYPTO) + errx(EX_USAGE, "secure erase setting must be between 0 and 2"); target = opt.dev; lbaf = opt.lbaf; diff --git a/sbin/nvmecontrol/nvmecontrol.8 b/sbin/nvmecontrol/nvmecontrol.8 index 4497263d5873..5fbc5f4a08f6 100644 --- a/sbin/nvmecontrol/nvmecontrol.8 +++ b/sbin/nvmecontrol/nvmecontrol.8 @@ -33,7 +33,7 @@ .\" .\" Author: Jim Harris .\" -.Dd July 31, 2026 +.Dd November 10, 2026 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -545,6 +545,24 @@ physically erase the underlying media. Enables Cryptographic Erase during format. All user data is erased cryptographically by deleting the encryption key, rendering it unintelligible. +.It Fl Fl ses Ar ses +Secure Erase Settings. +.Bl -tag -compact -width 6n +.It Dv 0 +Do not perform a secure erase. +.It Dv 1 +User Data Erase, as with +.Fl E . +.It Dv 2 +Cryptographic Erase, as with +.Fl C . +.El +Only one of +.Fl E , +.Fl C , +or +.Fl Fl ses +may be specified. .El .Pp When formatting specific namespace, existing values are used as defaults.