From nobody Mon Nov 16 21:01:15 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 4jT0dl3mSxz70wXd for ; Mon, 16 Nov 2026 21:01:15 +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 4jT0dl1p2rz4D6q for ; Mon, 16 Nov 2026 21:01:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862875; 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=Z6v4jbryTi3GaT7kCv6E9L2zutIM6lAjZwvNsuUi+70=; b=QLo83LM8zCqG+9AfgRMcg4ypxqfL5b2izEYEhvW6FDyyeyG4g8q4gw0NNBMwbtqgS77mtx 7LNnBBMmID99s9LjdNJUGYTjf5I7oqBN/DAv4M/bt6Nbo/Moq0l6M4sMni6Yg0AJzn4irg gYhyXJAZMHCo9mhXQS75P+Di+uYAsXMN3Oe3ErS7/cjNuTPKVYujOGcA7tdESanRxy7dYG UWkehidGQnlOSRzCE16W72Hm40sCGKD55qpXza0oMon6QpSiWwwClo1y1QhDBHZ3If4L+s LAjMDiwGsnL/01V13PkiKbJN/PuP9D0Jm+kZuZRZlXqI+YxFk+dyExtlKPsplQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862875; b=GQkBAPdxJRYwuipNbjYOLao1M2nScsVqlSTIH3PWDh/E6oW+08rqsnPy1SoJxtqn9AHA88 XdDjQzS0Gml6HBGI5OxREBAQ2ulbmJU2dywIAB0K9mmTGfjOhbEiEkLzjAok9Sl3Wg2iz8 DMeVNHw8yD1kS2nMP7PctOqmvRabB7bebJsq72Ei+Dvzk6VjPbnNwXUkN2XCWzoIliBc1x cXfmjrqierjyJ3Mw7O/6sNxE/Bv8aWxxktgZAqf3wUGYW4AZQzD0R4AEQv5v+qE7ObqusM m9mBOAkcI6fJNa7P1a+0JRhiUw0vJouovzTvJHWhtsWms+dH+3qFUCBREscUgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862875; 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=Z6v4jbryTi3GaT7kCv6E9L2zutIM6lAjZwvNsuUi+70=; b=RVKDClQJRVAoSH3jxlewCj+ADWZenEeIrjrVH8VxtvSu85gr6vY+37c1LRYVhJL/iSNCRP qUgiCiVm4RLlC2ZmYpGbUInSmPvgca/4Izi3sc4VLat4nCBDUb2Rs5gIpHiJSOuIpwmMkG CavAYHF7yWVE8HaKdm6AYfF9Zy99QMGtS1BdFxMCzDpB5ayesYqjf2z/h9zDVrhCDtGY0M kQyAq6qETjlR7Wm7FVQvgPVC+dS1elAJeX4VmlA4aL5jdT2feFFyxxhtEueNhm82n+thbe n/ejqKuWazqMPTWz2kauCenreONKd9IDqJBRbE2Muh8iGJ82SoKa5J/LdDmtHg== 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 4jT0dl17YNz19Qh for ; Mon, 16 Nov 2026 21:01:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 9691 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:01:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: 7b1763b4ee6c - stable/14 - nvmecontrol: Mask the fields in the Format NVM command 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: 7b1763b4ee6c8ea03e21add2121a7f001d612629 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:01:15 +0000 Message-Id: <6afb6f1b.9691.7ca2ff9f@gitrepo.freebsd.org> The branch stable/14 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=7b1763b4ee6c8ea03e21add2121a7f001d612629 commit 7b1763b4ee6c8ea03e21add2121a7f001d612629 Author: Kenneth D. Merry AuthorDate: 2026-11-09 19:35:00 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 21:00:07 +0000 nvmecontrol: Mask the fields in the Format NVM command The format command composed cdw10 by hand without masking any of the fields and with no support for the LBAFU field. Since commit 2c41f7d8a034 the LBA format index defaulted from FLBAS can exceed 15 on an NVMe 2.0 namespace using FIDXU, and such an index would bleed into the MSET and PI fields. An out of range index supplied with -f for a whole-controller format was not caught either. Build the command with nvme_admin_format_cmd(), which masks all of the fields and encodes LBA format indexes above 15 in LBAFU, and reject LBA format indexes greater than 63 for whole-controller formats. Per-namespace formats already validate the index against NLBAF. This is the same problem that llm-postcr reported in camcontrol's copy of this code, fixed in 3892a6453fc6; the unmasked composition originated here (635c517ae9ca). Reported by: llm-postcr Reviewed by: imp Fixes: 2c41f7d8a034 MFC after: 1 week Sponsored by: Spectra Logic Assisted-by: Claude Fable 5 Differential Revision: https://reviews.freebsd.org/D61356 (cherry picked from commit eae727676169de58052fd512ebb0ee565ad6e246) --- sbin/nvmecontrol/format.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sbin/nvmecontrol/format.c b/sbin/nvmecontrol/format.c index a507ddd78ffb..f45bae593354 100644 --- a/sbin/nvmecontrol/format.c +++ b/sbin/nvmecontrol/format.c @@ -192,6 +192,8 @@ format(const struct cmd *f, int argc, char *argv[]) /* We have no previous parameters, so default to zeroes. */ if (lbaf < 0) lbaf = 0; + else if (lbaf > 63) + errx(EX_USAGE, "LBA format is out of range"); if (ms < 0) ms = 0; if (pi < 0) @@ -201,10 +203,7 @@ format(const struct cmd *f, int argc, char *argv[]) } memset(&pt, 0, sizeof(pt)); - pt.cmd.opc = NVME_OPC_FORMAT_NVM; - pt.cmd.nsid = htole32(nsid); - pt.cmd.cdw10 = htole32((ses << 9) + (pil << 8) + (pi << 5) + - (ms << 4) + lbaf); + nvme_admin_format_cmd(&pt.cmd, nsid, ses, pil, pi, ms, lbaf); if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) err(EX_IOERR, "format request failed");