[v3,5/5] libcamera: camera: Ensure a request's controls are valid
diff mbox series

Message ID 20251202-cam-control-override-v3-5-eacab052798d@ideasonboard.com
State New
Headers show
Series
  • libcamera: ipc: ControlLists without valid idmap break IPC
Related show

Commit Message

Jacopo Mondi Dec. 2, 2025, 2:49 p.m. UTC
The list of controls part of a Request is initialized with the
ControlInfoMap of the Camera the Request is created from.

Applications can re-assign the controls list in a Request
which could cause issues during serialization.

Validate that the ControlList in a Request is valid when
the Request is queued to the Camera by inspecting the
ControlInfoMap pointer.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/libcamera/camera.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 2e1e146a25b13b94f3a0df5935c0861f78c949ed..93cd4d5f334f982133a12cbc4caec5cdf7bb52c6 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -1345,6 +1345,12 @@  int Camera::queueRequest(Request *request)
 		return -EINVAL;
 	}
 
+	/* Make sure the Request has a valid control list. */
+	if (request->controls().infoMap() != &controls()) {
+		LOG(Camera, Error) << "Invalid control list in the Request";
+		return -EINVAL;
+	}
+
 	/*
 	 * The camera state may change until the end of the function. No locking
 	 * is however needed as PipelineHandler::queueRequest() will handle