[libcamera-devel] [PATCH] libcamera: ipc_unixsocket: Don't send uninitialized bytes over the socket

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Jan 4 06:41:27 CET 2020


IPCUnixSocket::send() sends a IPCUnixSocket::Header allocated on the
stack. All the fields of the header are initialized, but the padding
bytes are not. This results in random data being sent over the UNIX
socket, potentially leaking information.

Fix this by initializing the whole header to 0.

Fixes: 13dd7a01ecbe ("libcamera: ipc: unix: Add a IPC mechanism based on Unix sockets")
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/libcamera/ipc_unixsocket.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp
index def08eef00f8..eb1a50239188 100644
--- a/src/libcamera/ipc_unixsocket.cpp
+++ b/src/libcamera/ipc_unixsocket.cpp
@@ -172,7 +172,7 @@ int IPCUnixSocket::send(const Payload &payload)
 	if (!isBound())
 		return -ENOTCONN;
 
-	Header hdr;
+	Header hdr = {};
 	hdr.data = payload.data.size();
 	hdr.fds = payload.fds.size();
 
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list