[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/11] linux-user: support target-to-host SCM_CREDENT
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 11/11] linux-user: support target-to-host SCM_CREDENTIALS |
Date: |
Tue, 27 Jan 2015 23:07:22 +0200 |
From: Alex Suykov <address@hidden>
When passing ancillary data through a unix socket, handle
credentials properly instead of doing a simple copy and
issuing a warning.
Signed-off-by: Alex Suykov <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 683f8cc..d4398b9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1214,16 +1214,26 @@ static inline abi_long target_to_host_cmsg(struct
msghdr *msgh,
cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type);
cmsg->cmsg_len = CMSG_LEN(len);
- if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
- gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level,
cmsg->cmsg_type);
- memcpy(data, target_data, len);
- } else {
+ if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
int *fd = (int *)data;
int *target_fd = (int *)target_data;
int i, numfds = len / sizeof(int);
for (i = 0; i < numfds; i++)
fd[i] = tswap32(target_fd[i]);
+ } else if (cmsg->cmsg_level == SOL_SOCKET
+ && cmsg->cmsg_type == SCM_CREDENTIALS) {
+ struct ucred *cred = (struct ucred *)data;
+ struct target_ucred *target_cred =
+ (struct target_ucred *)target_data;
+
+ __put_user(target_cred->pid, &cred->pid);
+ __put_user(target_cred->uid, &cred->uid);
+ __put_user(target_cred->gid, &cred->gid);
+ } else {
+ gemu_log("Unsupported ancillary data: %d/%d\n",
+ cmsg->cmsg_level, cmsg->cmsg_type);
+ memcpy(data, target_data, len);
}
cmsg = CMSG_NXTHDR(msgh, cmsg);
--
2.1.4
- [Qemu-devel] [PULL 00/11] linux-user-updates, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 03/11] linux-user/arm/nwfpe: Delete unused aCC array, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 04/11] linux-user/main.c: Call cpu_exec_start/end on all target archs, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 08/11] linux-user: Fix ioctl cmd type mismatch on 64-bit targets, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 01/11] linux-user/signal.c: Remove current_exec_domain_sig(), riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 09/11] mips64-linux-user: Fix definition of struct sigaltstack, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 06/11] linux-user/signal.c: Remove unnecessary wrapper copy_siginfo_to_user, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 11/11] linux-user: support target-to-host SCM_CREDENTIALS,
riku . voipio <=
- [Qemu-devel] [PULL 07/11] linux-user: translate resource also for prlimit64, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 05/11] linux-user/main.c: Mark end_exclusive() as possibly unused, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 10/11] linux-user: Fix broken m68k signal handling on 64 bit hosts, riku . voipio, 2015/01/27
- [Qemu-devel] [PULL 02/11] linux-user/alpha: Add define for NR_shmat to enable shmat syscall, riku . voipio, 2015/01/27
- Re: [Qemu-devel] [PULL 00/11] linux-user-updates, Peter Maydell, 2015/01/27