git: b95e2b2ce907 - main - camcontrol: Require a reservation type for reserve, preempt and release
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 19:14:12 UTC
The branch main has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=b95e2b2ce907cde89bc3e7be2ffeae03cfed55ab
commit b95e2b2ce907cde89bc3e7be2ffeae03cfed55ab
Author: Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-09 18:47:00 +0000
Commit: Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-09 18:59:13 +0000
camcontrol: Require a reservation type for reserve, preempt and release
res_type was initialized to 0, but the checks that enforce the -T
argument for the reserve, preempt and release reservation actions
compare it against -1, so they could never fire and camcontrol
silently sent a reservation type of 0, which is invalid.
Initialize res_type to -1 so the checks work, and default the
reservation type to 0 for the release action's clear variant,
which does not take -T and ignores the field.
Reported by: llm-postcr
Fixes: ba75cf05727e
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
---
sbin/camcontrol/nvres.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sbin/camcontrol/nvres.c b/sbin/camcontrol/nvres.c
index ab6132d45fde..1145278356c3 100644
--- a/sbin/camcontrol/nvres.c
+++ b/sbin/camcontrol/nvres.c
@@ -450,7 +450,7 @@ nvmepersist(struct cam_device *device, int argc, char **argv, char *combinedopt,
int eds = 0, cptpl = 0, iekey = 0;
int error = 0;
int in = 0, out = 0;
- int opc = -1, op_action = -1, res_type = 0;
+ int opc = -1, op_action = -1, res_type = -1;
int c;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
@@ -659,6 +659,9 @@ nvmepersist(struct cam_device *device, int argc, char **argv, char *combinedopt,
error = 1;
goto bailout;
}
+ /* The reservation type is ignored for a clear. */
+ if (res_type == -1)
+ res_type = 0;
break;
}