git: 8678bd6e2e50 - stable/14 - camcontrol: Fix swapped protection information defaults in nvformat
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Nov 2026 21:01:10 UTC
The branch stable/14 has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=8678bd6e2e508584978ff6952eff26d6dc3ce046
commit 8678bd6e2e508584978ff6952eff26d6dc3ce046
Author: Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-09 18:46:59 +0000
Commit: Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-16 21:00:06 +0000
camcontrol: Fix swapped protection information defaults in nvformat
When no -p or -l arguments are given, the nvformat subcommand fills
in the protection information type and location from the
namespace's current settings. The two were swapped: pi was taken
from the DPS metadata location bit and pil from the protection
information type field. Formatting a namespace with protection
information enabled would therefore silently change its PI
settings, and before the Format NVM command builder masked its
fields, a namespace with PI type 2 enabled would set bit 9 of
cdw10, turning the format into a user data erase.
Reported by: llm-postcr
Fixes: 80f090111ae4
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit ef69484b4295e84c74877b439db5caf025906b0c)
---
sbin/camcontrol/nvformat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sbin/camcontrol/nvformat.c b/sbin/camcontrol/nvformat.c
index a41b490d62bc..777035812e6b 100644
--- a/sbin/camcontrol/nvformat.c
+++ b/sbin/camcontrol/nvformat.c
@@ -232,12 +232,12 @@ nvmeformat(struct cam_device *device, int argc, char **argv, char *combinedopt,
& NVME_NS_DATA_FLBAS_EXTENDED_MASK;
}
if (pi < 0) {
- pi = (nsdata.dps >> NVME_NS_DATA_DPS_MD_START_SHIFT)
- & NVME_NS_DATA_DPS_MD_START_MASK;
+ pi = (nsdata.dps >> NVME_NS_DATA_DPS_PIT_SHIFT) &
+ NVME_NS_DATA_DPS_PIT_MASK;
}
if (pil < 0) {
- pil = (nsdata.dps >> NVME_NS_DATA_DPS_PIT_SHIFT) &
- NVME_NS_DATA_DPS_PIT_MASK;
+ pil = (nsdata.dps >> NVME_NS_DATA_DPS_MD_START_SHIFT)
+ & NVME_NS_DATA_DPS_MD_START_MASK;
}
if (ses < 0)
ses = 0;