git: ef69484b4295 - main - camcontrol: Fix swapped protection information defaults in nvformat
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 19:14:11 UTC
The branch main has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=ef69484b4295e84c74877b439db5caf025906b0c
commit ef69484b4295e84c74877b439db5caf025906b0c
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-09 18:59:13 +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>
---
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;