From nobody Mon Apr 29 04:38:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495204380303148.90074274340498; Fri, 19 May 2017 07:33:00 -0700 (PDT) Received: from localhost ([::1]:59065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBixe-00013Z-Ca for importer@patchew.org; Fri, 19 May 2017 10:32:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBiw2-00008L-L7 for qemu-devel@nongnu.org; Fri, 19 May 2017 10:31:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBivR-0005FK-Gk for qemu-devel@nongnu.org; Fri, 19 May 2017 10:31:18 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBivR-0005EE-4r for qemu-devel@nongnu.org; Fri, 19 May 2017 10:30:41 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4JET707127505 for ; Fri, 19 May 2017 10:30:40 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ahwn9x5er-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 May 2017 10:30:39 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 May 2017 10:30:38 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 May 2017 10:30:36 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4JEUSES33161302; Fri, 19 May 2017 14:30:36 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04C89112065; Fri, 19 May 2017 10:30:45 -0400 (EDT) Received: from bahia.lan (unknown [9.164.171.209]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 650DC112051; Fri, 19 May 2017 10:30:44 -0400 (EDT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 16:30:34 +0200 User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 17051914-0040-0000-0000-000003433375 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007085; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00862626; UDB=6.00428026; IPR=6.00642376; BA=6.00005358; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015510; XFM=3.00000015; UTC=2017-05-19 14:30:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051914-0041-0000-0000-000007376409 Message-Id: <149520423435.7495.2756710723268429379.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705190092 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] fsdev: fix virtfs-proxy-helper cwd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Since chroot() doesn't change the current directory, it is indeed a good practice to chdir() to the target directory and then then chroot(), or to chroot() to the target directory and then chdir("/"). The current code does neither of them actually. Let's go for the latter. This doesn't fix any security issue since all of this takes place before the helper begins to process requests. Signed-off-by: Greg Kurz Reviewed-by: Eric Blake --- fsdev/virtfs-proxy-helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 54f7ad1c48f0..4c4238f62e53 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -1129,14 +1129,14 @@ int main(int argc, char **argv) } } =20 - if (chdir("/") < 0) { - do_perror("chdir"); - goto error; - } if (chroot(rpath) < 0) { do_perror("chroot"); goto error; } + if (chdir("/") < 0) { + do_perror("chdir"); + goto error; + } =20 get_version =3D false; #ifdef FS_IOC_GETVERSION