From nobody Mon Nov 16 21:01:16 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 4jT0dm50DQz70wpD for ; Mon, 16 Nov 2026 21:01:16 +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 4jT0dm2HQgz4DKm for ; Mon, 16 Nov 2026 21:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862876; 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=OoVug5yFcLoFSmXBLwokMPhpCHiMHobcfrhvRnt8obE=; b=gUo9iU8CSpBul6mik+KY+OxPnAgcYzI2s+KHF/voir/GtfOVH/7eEZ9nbOP0wgZmLF96EQ wMqz1byvTdMWjp9OTwW1Q/g1g7/Q+fndfZQpCZyyP1GRplwhsq6YoDDoJnsUhup1lFxIVe VPrnS6PrEASitNhdOvN3f0IM3wdxRQvAS6I8YRbNRKgx96IXyqyI7ADv5GxcKCmLYC0b6t 5DjUl8KPNbRpjvrK6NSh6+PNwo5GXyxfeguue/Jeh6trk99PpeafXCQcrd7IehTPLplk0A xWnAD/VD4fFks1T77ZiilPD5mznBV5ey0QdfN2WLZWf4EIoHOPigJiNjY85W3A== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862876; b=L6A81zaUWHPYvnFwQlJ7Qz8nUvpIfBi4uQF9sxMpa5zJHlfLegc4uJPCRnI/i7ibqM4nme lbvA/RHh1zmc9lOWA9GLvaGEewgnm4O7fe5fWiw20dWFgonMMuUIZlSZcmvAGBONzeIJa+ 6Ga2KEzxn7XvL9YtlhUM3gEj6krgXn/b4GHGEZTQ+sV4g9qA14G4g/Hs4XIeneIMusAG2M Ztm8+POa1wsJ/23BGTVF5jOx0aZICpfJ9R70RGgIA3dPQHKfLfv4M8uy148tx1JUfpns0J EX3EumrgWRHFCXqy7PEMrtGkSKr19SnCs8hX2YCbCwz+6/i9pajnxKcCxtFaDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862876; 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=OoVug5yFcLoFSmXBLwokMPhpCHiMHobcfrhvRnt8obE=; b=yjcZvseWfIlYa2jNv7ufSxWp+RqLh+9hw6GdA4+EgTkg7rK0+xXSS39XBoVbwy9c8JnAdy pHu/hnA/QSzVoA+euz0yEtc2W9e/AD9B7uKT5hcM43lnpjh/c5bDmCnO5gA6RzlGe+v/h8 AqAIHgf+YAW9gcBLBYqaXxIXjvifSKbwnhzzxClopsaVQhasTzhAqk+FGKGmTCEjnACQ+0 sz7AW35Yhy+uAS5PbxeXZMKubVh8Q7ZTDulTkKk3V8Ignu3Aga0codqSo6Z/KHI1S5GK1B +kXuMxMi0E47/Gz07W5EUIovtHQ+MuAOfVLCurH3AyYaCRPXaym6Rh98DHHGBw== 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 4jT0dm1XZGz196c for ; Mon, 16 Nov 2026 21:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 9470 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:01:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: 259b3ac4dd08 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 259b3ac4dd0826650d90c4943fa4b734d6812606 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:01:16 +0000 Message-Id: <6afb6f1c.9470.24ce4691@gitrepo.freebsd.org> The branch stable/14 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=259b3ac4dd0826650d90c4943fa4b734d6812606 commit 259b3ac4dd0826650d90c4943fa4b734d6812606 Author: Kenneth D. Merry AuthorDate: 2026-11-10 21:12:21 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 21:00:07 +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 f45bae593354..76816a4a0099 100644 --- a/sbin/nvmecontrol/format.c +++ b/sbin/nvmecontrol/format.c @@ -128,6 +128,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 40a6400515cc..a238cbd0860b 100644 --- a/sbin/nvmecontrol/nvmecontrol.8 +++ b/sbin/nvmecontrol/nvmecontrol.8 @@ -33,7 +33,7 @@ .\" .\" Author: Jim Harris .\" -.Dd May 3, 2024 +.Dd November 10, 2026 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -488,6 +488,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.