From nobody Mon Nov 16 21:00:40 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 4jT0d45077z70wTK for ; Mon, 16 Nov 2026 21:00:40 +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 4jT0d43X4Vz4Bs8 for ; Mon, 16 Nov 2026 21:00:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862840; 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=MgwwhmSjm6KBnbMrR20pjnXAgWEmP18PCBmdWckDoA0=; b=L6ni7HM48nRp3QgJ6iMaAABrv4wRvHaMEFNqU6bs9kWEKcxnVpsJsF6JFB675VCbCOXsmW U1oRjS3m0UVdVQF0foEUsZ5pbR0KmOmTI9DEeubqGWvS1LXGvXmITHIyJDj1yExIt5tbZX +5Plnlpj2E308mIMsaVL7kPex+DcdAPH73sQYCZpz59Ek8cibTQ0T5SQqr27j6+OEyvBwl TD1xhAff8GOcRGNoitQ3++TaZdUfomiVFErRuTGKplJOXk45pnuzuTWtGA2cK+qIXHL2or 7COparGobWRybSDjvhLSogiFGOwILDg+HfuyeJpklsQu99mCL/621IiTU8htYA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862840; b=KjHxA2/019lTevyO2EjzvQ9NeYX069nzh0sk5dWMA+QEKYIS4/UCgEEnINZCpHnqPSHDsq KJgkkH2ELy0LlFqQPNrfzlbjPxE917W+TsIx1hFn+m43enytW04w5JSjmu2OwHRJ9r54wC RdH/JiWAxMlDXZUIvUWB1yTVF7uVI3ywX0l6T59rfuR6b5GMFhJITHRaX7b76vxnGR0115 A1iumCjOjLN4CVhW/6pLANshUKHhU7P7mpQhc2V2cj0RvVgtI4oZJ1jyYDDnhkjr+Thv9f fSWFv1DPkcVPDpWNwzCLdiCvNCWMBilkoTENRYKng9efzH3CYTp+7exztnS+jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862840; 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=MgwwhmSjm6KBnbMrR20pjnXAgWEmP18PCBmdWckDoA0=; b=D9TeSC6Aa2Liji/tRMOCxkMYyVOIuAoAd0elOBg7yXt+nAxYKPLdsK8MTiWrQ+fNccdMBR 96GYnYb5Rcr8Fgdl9WbI0YlnL92X4x/l42N8fw0IjtRMO6TSvQJJ5fCdjXW7cllPunQRkp nyxCk5DunLlCxD9Qe+8/pcotF6NmdjTdffsDH/7P3mzqK5qqHam0XAnfKjQ4iH7WFE1qdq sgn56d1E6I4WqO7FtdbIwjY2DanvoBhbwGOZuBJ0ZAG3bdiDVG+pgoCCQeu3zAX+fB7k4s Ey7Oye7OYZQ6BKHGoQsQNytjKOdr051rDom7nsqY/HJTiwoXDTzJIsXbbn4+bg== 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 4jT0d42vpDz1937 for ; Mon, 16 Nov 2026 21:00:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 970d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:00:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: f03c774fb5c4 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: f03c774fb5c4dcf44590f0df4e7eeb0f0876e56e Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:00:40 +0000 Message-Id: <6afb6ef8.970d.2f2eeae@gitrepo.freebsd.org> The branch stable/15 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=f03c774fb5c4dcf44590f0df4e7eeb0f0876e56e commit f03c774fb5c4dcf44590f0df4e7eeb0f0876e56e Author: Kenneth D. Merry AuthorDate: 2026-11-09 18:46:57 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 16:12:35 +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 b5f2815eeff3..0c6886fde275 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -2246,8 +2246,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