From patchwork Tue Jan 27 21:07:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 43856 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4287E2409D for ; Tue, 27 Jan 2015 21:11:46 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e49sf8939033eek.3 for ; Tue, 27 Jan 2015 13:11:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=UuSBZQCSujuZagtJDnLOpS4thzSSuQbe5hUzK2oaLHY=; b=S+yftXCEewZX7JHq3IIeB+9gpPiIdxVzDJbvX4Hr2/3l1AVPaD18jBjvjfjhTippYf pfjxTKWKuDU2Sq8HEW2/lVteRqgxZStSzyX1fwJZ+8K3h3ByYJittNitVLQ8aU39OqIV 8Tsloe4UWUbNT5eWnOhSlUmbZO2eTr3SgKJn5SIjXaxf+5jgfFwcRMJXff18yK3VoE7I +GAC4IYzf8IEk/V+fvtEHGLBNgEXtpEcBd+ozqN2+h2YI6/2Wkrw10p86lPhN82u3tkc PM8MPnz6o+tvMiG4IH5Kn32kk7I7nmTrnnSoz2+hs9/pi/9F41AQBkOs+yXYVrZgwxQB VACg== X-Gm-Message-State: ALoCoQmPUGOVm3KfnejLVVAFmB7gf/qHibf9zRc7IED/nPCOjNntNAZ80jh0URgA/kOYiWSHt/fX X-Received: by 10.180.93.165 with SMTP id cv5mr14434wib.6.1422393105316; Tue, 27 Jan 2015 13:11:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.6 with SMTP id x6ls90700lag.70.gmail; Tue, 27 Jan 2015 13:11:45 -0800 (PST) X-Received: by 10.112.55.199 with SMTP id u7mr4085110lbp.74.1422393105058; Tue, 27 Jan 2015 13:11:45 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id pe5si2414073lbc.40.2015.01.27.13.11.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 13:11:45 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so15623883lam.2 for ; Tue, 27 Jan 2015 13:11:44 -0800 (PST) X-Received: by 10.112.181.41 with SMTP id dt9mr4125535lbc.56.1422393104937; Tue, 27 Jan 2015 13:11:44 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1227520lbj; Tue, 27 Jan 2015 13:11:44 -0800 (PST) X-Received: by 10.224.12.19 with SMTP id v19mr5951825qav.22.1422393103728; Tue, 27 Jan 2015 13:11:43 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q6si3172611qca.29.2015.01.27.13.11.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 13:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:49989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGDQE-0007eb-OB for patch@linaro.org; Tue, 27 Jan 2015 16:11:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGDMB-00048V-J5 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 16:07:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGDM5-0005n0-LE for qemu-devel@nongnu.org; Tue, 27 Jan 2015 16:07:31 -0500 Received: from afflict.kos.to ([92.243.29.197]:35450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGDM5-0005mc-Ff for qemu-devel@nongnu.org; Tue, 27 Jan 2015 16:07:25 -0500 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 6F0C5264E4; Tue, 27 Jan 2015 22:07:23 +0100 (CET) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 27 Jan 2015 23:07:22 +0200 Message-Id: <30b8b68eb574fd68060eebcc4da790fdfe18d668.1422392096.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: peter.maydell@linaro.org, Alex Suykov Subject: [Qemu-devel] [PULL 11/11] linux-user: support target-to-host SCM_CREDENTIALS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alex Suykov 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 Signed-off-by: Riku Voipio --- 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);