From nobody Mon Nov 16 21:01:07 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 4jT0dc2Qm9z70wmF for ; Mon, 16 Nov 2026 21:01:08 +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 4jT0db6gFKz4Cvw for ; Mon, 16 Nov 2026 21:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862867; 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=ZEvegPgxQtq1wrepds09grdmyJw8XMXm11tv0HwnStY=; b=bUDijc+TjpOYCH8NMapeCaO9fRQy4eJQJpz8b9uJRni0oQfzNF3zIYPVchNjP5zgUslIfj R2U9zcg6+f/mjHByGDOTJtL34AdvP+Nn3RTmd+3FU8JBafKR257MF6N+8hRWRMxc4Zo5lJ tAcSp03RwrOG2QtSE6ApyASFki5aBljb1TnEl7QtzzD7HYojpQhzSLKqinHQzFstuJR7EE Oy4CPtVUuF95dXL1dRD3mFeJFXmGLy27UUXa+KQUnJYKz62DWmPtLtcMK+8brExCTUNn4a lQqIj+oLFx20lpsgT15A89Th/NuxGA+cK6JMbfvrEEno5faW/ggY6xwkGjUMIA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862867; b=EFZ/mDx/L+3h+ANWL49J3jAG351nwPLCaDT6mv7vHwSKxn0qRMqy7e/xelkJo+76lzA8Np z/geboU6B5khvjsstE42AA2W08VhWUDtpjBUdQFUjH1NXwZpArFCgNX9WW/xvaTOf5f0uW BJ/XiXQPNZcbt49rBaR+t+UWenzCMe0VQ0BpsT6i26bHJg1iYWCByMHArm0tasTd0tl7yY XRW6kCm3PW0a+6yCkfF1x2Q7jGWzuHqXaXjgjK1pFwJB5+L3WxZi5gkMVZnS/38dndN+qh 54tPU8ksfInOCi89BfZ69fGE9v5N2rqm3Qu3HWOmvK70FTKA4yarrOc76iOW3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862867; 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=ZEvegPgxQtq1wrepds09grdmyJw8XMXm11tv0HwnStY=; b=l+MAhj60oQFrp45sfv72StfDCMgLBVtx6R2fajg3frebWl/tAhgMBoKBFMjqRXuWVNuql/ Tv6UbXwS9GzD9RaFndADNhYw5JO222D4xxpAY7ch9cpFuTeWdcj7ifhNNXFcKX0SMyYT/u 7v5QCTgBIe5hEBnMFc9jIQZTC3Lck+avB9jjuDIEdXsPG3FGh49+jL/cFePch4rxXGA6Vk ytJYh5jNZ2JMmzFTKcM3AM3dJAYMOKJ/6pMlUBYhmgAk/tB7xHqQM7lduX7y+I37sQBr4g g2UMybEIA+XCRZGWRqk2mr85CuYzYhS9meMuX2wBnOr9jAK1WteQ/rmsNGFZ6Q== 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 4jT0db5m6lz191R for ; Mon, 16 Nov 2026 21:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 7e74 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:01:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: 94434cd83c02 - stable/14 - nvme: Mask the fields in the Format NVM command builder 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: 94434cd83c0241bb0611051a34d50152ef109e8b Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:01:07 +0000 Message-Id: <6afb6f13.7e74.419676a5@gitrepo.freebsd.org> The branch stable/14 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=94434cd83c0241bb0611051a34d50152ef109e8b commit 94434cd83c0241bb0611051a34d50152ef109e8b Author: Kenneth D. Merry AuthorDate: 2026-11-09 18:46:57 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 21:00:06 +0000 nvme: Mask the fields in the Format NVM command builder nvme_admin_format_cmd() did not mask any of the fields it composes into cdw10, so an out of range value in one field would corrupt neighboring fields. In particular, an LBA format index greater than 15 would bleed into the metadata settings and protection information fields. It also had no support for LBA format indexes above 15, which NVMe 2.0 encodes via the separate LBAFU field. Mask all of the fields, and encode bits 5:4 of the LBA format index in the LBAFU field (cdw10 bits 13:12). Also reject out of range LBA format indexes in camcontrol's nvformat global (-G) mode, which has no namespace data to validate against. The per-namespace mode already validates the index against NLBAF. sys/dev/nvme/nvme.h: Mask the SES, PIL, PI, MSET and LBAF fields in nvme_admin_format_cmd() and encode the upper two bits of the LBA format index in LBAFU. sbin/camcontrol/nvformat.c: Reject LBA format indexes greater than 63 in -G mode. Reported by: llm-postcr Fixes: 7a9e4375316b Fixes: 80f090111ae4 MFC after: 1 week Sponsored by: Spectra Logic Co-authored-by: Claude Fable 5 (cherry picked from commit 3892a6453fc60e00b0d6cd5c5d7e2606b4b51e7c) --- sbin/camcontrol/nvformat.c | 6 ++++++ sys/dev/nvme/nvme.h | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sbin/camcontrol/nvformat.c b/sbin/camcontrol/nvformat.c index 94af800db422..a41b490d62bc 100644 --- a/sbin/camcontrol/nvformat.c +++ b/sbin/camcontrol/nvformat.c @@ -246,6 +246,12 @@ nvmeformat(struct cam_device *device, int argc, char **argv, char *combinedopt, ses = 0; if (lbaf < 0) lbaf = 0; + else if (lbaf > 63) { + warnx("%s: LBA format %d is out of range", __func__, + lbaf); + error = 1; + goto bailout; + } if (mset < 0) mset = 0; if (pi < 0) diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index 8a37822f841e..658461096b0a 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -2162,8 +2162,9 @@ void nvme_admin_format_cmd(struct nvme_command *cmd, uint32_t nsid, { cmd->opc = NVME_OPC_FORMAT_NVM; cmd->nsid = htole32(nsid); - cmd->cdw10 = htole32((ses << 9) | (pil << 8) | (pi << 5) | (mset << 4) | - lbaf); + cmd->cdw10 = htole32(((lbaf & 0x30) << 8) | ((ses & 0x7) << 9) | + ((pil & 0x1) << 8) | ((pi & 0x7) << 5) | ((mset & 0x1) << 4) | + (lbaf & 0x0f)); } static inline