From nobody Tue Nov 10 21:23:21 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 4jPKQ16GSqz6xhm3 for ; Tue, 10 Nov 2026 21:23:21 +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 4jPKQ15WGFz4Nbx for ; Tue, 10 Nov 2026 21:23:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794345801; 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=tjKidYakqfITSugAU3cVbB2cXXk7+AP96XKKa7g3p8E=; b=IfEMNkr2vayVP3j3MsfhBcjZSPllFStNPHvGPPmCwirhFsbOql/RpY/CVWqIAQgsHxyz+t DeGI4bOEpqmw34iSaoVPjTQ9OEtOP0UIAxN3N7mvxKK/+dWxBiwCwJbZf2L6BgF/CSMIDg bigrzwff3g+854ppK26SQvOIZyPYSmp9U58c4+Ovyr1DFzD5yQQPRXH0VMvdimT5RqYyqQ 0rMogg+5YRnvssNjMwkpOg/KbwuflmPfEPfAj3zmJVbRVL69w6xjQ6SVay3FzenjjrDUKS fyMnYYhNo5gI8SkDORstuOkxD4xUrbO5CoDMlKGCUwKhfi+pj/ticxyGnV2TnQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794345801; b=DnheHS/8WTvEk6LUaTWbNQok70JZ3T3G4o4ZuY7SUGznW/HuZRtqlE2DNKAIkkxbHrlCWT 9EA32Ld1cKceD+WvkezU1I0DltAnnzyqc+v0rKgYdCIvD/NsYuPBQRVQpYK0iANmPttm0R VWa2U0HAMSDFrKMY7nvhG5vl1ZOV4bpr3Yqn3iITKir4DE15rXVKjj3hh02y5s1YtH9qVv l3MNSQNihXxRwFfjTZFJymzCXc8pV6/cM4BbbqcH3cvc7bND9uKpaGWYEq7hlPXVipOtox awuCEG6iE1VrQKUytcg5NX+svBcrXz5ozgyq7BFpbw5kO1eG00Tp0lPfGz4/KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794345801; 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=tjKidYakqfITSugAU3cVbB2cXXk7+AP96XKKa7g3p8E=; b=TVpEHvghfWYJYFvQp1s3WVJ37sAhTvrmeM1WTVNcUo1qmfRuBw+bZ/P4qbUHDdcFQ66wed 5mTz86xu1YMqbvmGSHYxXoN1PlWwhUBt1hVIJ3O5PuxxTm4RpL/PzklotADPEi5Q5nGuis FsVxFdEbWe2yLO1dKveZKvheJ951U1RYXYQQBmyM1ykYiyCKYPERbMdv30C162/MHIYeoS 2lDt7GyYC9LadB45NFe1faHDgmeeZ7VBJAV+K9Rjo/IvgMo3YOUD7/VmMAcK0eyqYQhgAM PwGCD+x79VmkeFQlZTmP8DCQsASHVHsQKoTjwMOYuW5vF85i9oleg38nrEoTrg== 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 4jPKQ14tkKzmL2 for ; Tue, 10 Nov 2026 21:23:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id c725 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Nov 2026 21:23:21 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kenneth D. Merry Subject: git: 3d6f886151f9 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 3d6f886151f9ee6f3bf16ea3367a4b540df3f911 Auto-Submitted: auto-generated Date: Tue, 10 Nov 2026 21:23:21 +0000 Message-Id: <6af38b49.c725.3bfb9bd1@gitrepo.freebsd.org> The branch main has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=3d6f886151f9ee6f3bf16ea3367a4b540df3f911 commit 3d6f886151f9ee6f3bf16ea3367a4b540df3f911 Author: Kenneth D. Merry AuthorDate: 2026-11-10 21:12:21 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-10 21:23:19 +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 --- 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 62dd56a5a81e..102da0d245e8 100644 --- a/sbin/nvmecontrol/format.c +++ b/sbin/nvmecontrol/format.c @@ -204,6 +204,16 @@ format(const struct cmd *f, int argc, char *argv[]) "Only one of -E, -C or --ses 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 76646a578e3b..1c92eb6af43b 100644 --- a/sbin/nvmecontrol/nvmecontrol.8 +++ b/sbin/nvmecontrol/nvmecontrol.8 @@ -33,7 +33,7 @@ .\" .\" Author: Jim Harris .\" -.Dd September 21, 2026 +.Dd November 10, 2026 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -573,6 +573,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.