From nobody Mon Nov 16 21:01:07 2026 X-Original-To: dev-commits-src-branches@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 4jT0dc2RmWz70wmG 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 4jT0db6fd2z4D5h 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=1794862868; 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=ykyvxdjhfV6pqB+NvQcDBdpkCXZzsMXK7bDxXi0V7nMqZ4UZlqnlxUafXt4N68Zy2KShfl qvsVzKAQxDf3x0DOV6xbCzxx0UvDQF/KZIc9UUgPkcPqAMA8ryvibS2nhJKpPDHpgSRif0 uBXEEci9RyvizvqM7IdHS02I4P2KKL2F4k8IKrZ7l6/rd1uoYBoMRl4l9x5UuFQoq8AKJJ JJc1o0OHjx/8Vpb6t5YbFYJNEsQ7X/wAZEPNtx3s4TXfGlgeFYSA3BLx36EZfXZUlUpFPz 4MM4bwOCITloSthRb0lY2C4qRzNS8IAm8JmqxEEKdwQb5IwELvPH33GRJDdjAQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862868; b=fmD5ENLeUsff7m4AGDBgiW+ZYOQUHkTsEWSRvW/HDsmnw5dCwy+ULJrVQ/cYuvPt9jCAZQ oIe83ZE7touEBc2yt8NDRLmLWAxUGtvK3wj+gRfq/hWNYdYrFP8PGbobjfvksMuZg3jzrr i1O0/pyPCRy/g0+4zaP+l6GqM32jF0UEC8ZwkAnNoGQcSisB7WHuaKzmOfzDS0CWI5Deps fOlGwf+gWkxWgH5gw0gmQES4tXLW5HOTVoEi3k8oehYWjydJ250OnWiuRg1QFuZgxVkViR yE3aIcz2lyDCW7BfTR4BMFoDsedj1P4XwZkqRKnKgEOEShF0G2j7ITyPRvx14w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862868; 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=pjOo7CYAC1Tcttlw3m8ZZqrXeNU1HjuXzkuMha5fovHV98CHozVSubBqQcbuRz5xwn01ee ofnfkU3jrYPKtjcpOZay27cvsA3jXNHfDnxIAttVs2YGomgDPy7ygxG0ELi4csikxBu5wI J08HSKztBftcJts1IZTTBnrIzxcnboso6p8Qog2wzyBTqXr7fc9H49U75x1ZT+rgVDcALu 1cvsHaLuDuz0xhhayzEDx9A16Ajmac0aArWUQcFqtCkCVhjrLRWj/rpShhJ3MqxxaWfu56 dgzf0qbSZf/WA/f0mul4F3vNtu7GE+jENJR3/pyEM77y1gdqL/HtZmY+6P+yXg== 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 4jT0db5lwGz19ZG 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-branches X-BeenThere: dev-commits-src-branches@freebsd.org List-Id: Commits to the stable branches of the FreeBSD 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