Skip to contentSkip to conversation

um: Fix FD copy size in os_rcv_fd_msg()

PATCH New Tiwei Bie 1 participant 1 message Sep 1, 2025 User-mode Linux (UML)

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 um: Fix FD copy size in os_rcv_fd_msg()

From: Tiwei Bie <[email protected]>

When copying FDs, the copy size should not include the control message header (cmsghdr). Fix it.

Fixes 5cde6096a4dd ("um: generalize os_rcv_fd")
---
 arch/um/os-Linux/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/os-Linux/file.c +1 -1
index 617886d1fb1e..21f0e50fb1df 100644
@@ -535,7 +535,7 @@ ssize_t os_rcv_fd_msg(int fd, int *fds, unsigned int n_fds,
 	    cmsg->cmsg_type != SCM_RIGHTS)
 		return n;
 
-	memcpy(fds, CMSG_DATA(cmsg), cmsg->cmsg_len);
+	memcpy(fds, CMSG_DATA(cmsg), cmsg->cmsg_len - CMSG_LEN(0));
 	return n;
 }
 
Signature · 1 line
2.34.1