git: 0ca07b1df2bc - stable/14 - camcontrol: Require a reservation type for reserve, preempt and release
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Nov 2026 21:01:12 UTC
The branch stable/14 has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=0ca07b1df2bc27d99b38a179d9c23db2c3b7b36c
commit 0ca07b1df2bc27d99b38a179d9c23db2c3b7b36c
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-16 21:00:06 +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>
(cherry picked from commit b95e2b2ce907cde89bc3e7be2ffeae03cfed55ab)
---
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 dc36954f1fe9..ab9ac5b30607 100644
--- a/sbin/camcontrol/nvres.c
+++ b/sbin/camcontrol/nvres.c
@@ -446,7 +446,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) {
@@ -655,6 +655,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;
}