From nobody Sat Feb 7 09:38:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571919706; cv=none; d=zoho.com; s=zohoarc; b=NIoGgcvJkrg2m1cYUKGaFPQQPTxPHK1xqJt40es3Mk6wIHoQQ28uPuzf/fkJJpc+cnvb7j37rD7LoOxkueqYmiODzV6vDFa3/5PYNMbtrdpi3arP52iIJe0soSAa60xgNLIqWQl+irzTxYxxyBumXUgInv2XnrzPoDBcuWu7tnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571919706; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D7t1G1X4jnXlhZIky824rhlkUN91z35a3M0WZK2OO/I=; b=Kpfsu9hdpI/X6fW107fCcE4Gp1gerR6UByx15kDW9IWwQ1rqhrTVlpfQgFuo2RA8OYNQcdeN47sYa4CEKFHk/RqPlk9i8qidQ9np3r9Vkm2hFCcfMODEPpNrhI92bvMKe2biYzb4IlR6pQ8WyEALDh9vqcmHq0D6OYZrP8VXuq4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157191970664675.17198886812662; Thu, 24 Oct 2019 05:21:46 -0700 (PDT) Received: from localhost ([::1]:40868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNc7d-0004TM-5Q for importer@patchew.org; Thu, 24 Oct 2019 08:21:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39389) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNbI4-0003kJ-K8 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 07:28:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNbI1-0008Vs-CH for qemu-devel@nongnu.org; Thu, 24 Oct 2019 07:28:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23210 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNbI1-0008Vc-6H for qemu-devel@nongnu.org; Thu, 24 Oct 2019 07:28:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-ZckovvnZPMaVJc1wNqGsOA-1; Thu, 24 Oct 2019 07:28:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FA28801E5F; Thu, 24 Oct 2019 11:28:16 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-248.ams2.redhat.com [10.36.117.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id B623F1C93D; Thu, 24 Oct 2019 11:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571916504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D7t1G1X4jnXlhZIky824rhlkUN91z35a3M0WZK2OO/I=; b=ZOd0lvNPCCK1YUb2EX27EQJltR9vMFuN377339jsWn3bLWM05WdAPIuST+qR0Cxi+zmRXf sqyp6KgEcaTwoPmHKT3mRVIn+CQd9J6Q6JXrDDAlPE9CP0wgWpcT+w90+PLFFAAaliy9lf NIYTZ8v5G4NgXgtaA2SBvYThcJsd8Og= From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, renzhen@linux.alibaba.com, eguan@linux.alibaba.com, ganesh.mahalingam@intel.com, m.mizuma@jp.fujitsu.com, mszeredi@redhat.com, misono.tomohiro@jp.fujitsu.com, tao.peng@linux.alibaba.com, piaojun@huawei.com, stefanha@redhat.com, vgoyal@redhat.com, mst@redhat.com, berrange@redhat.com Subject: [PATCH 13/25] virtiofsd: prevent ".." escape in lo_do_lookup() Date: Thu, 24 Oct 2019 12:27:06 +0100 Message-Id: <20191024112718.34657-14-dgilbert@redhat.com> In-Reply-To: <20191024112718.34657-1-dgilbert@redhat.com> References: <20191024112718.34657-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: ZckovvnZPMaVJc1wNqGsOA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi --- contrib/virtiofsd/passthrough_ll.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthr= ough_ll.c index 702fedc38a..7a61bf94fe 100644 --- a/contrib/virtiofsd/passthrough_ll.c +++ b/contrib/virtiofsd/passthrough_ll.c @@ -606,12 +606,17 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t pa= rent, const char *name, int res; int saverr; struct lo_data *lo =3D lo_data(req); - struct lo_inode *inode; + struct lo_inode *inode, *dir =3D lo_inode(req, parent); =20 memset(e, 0, sizeof(*e)); e->attr_timeout =3D lo->timeout; e->entry_timeout =3D lo->timeout; =20 + /* Do not allow escaping root directory */ + if (dir =3D=3D &lo->root && strcmp(name, "..") =3D=3D 0) { + name =3D "."; + } + newfd =3D openat(lo_fd(req, parent), name, O_PATH | O_NOFOLLOW); if (newfd =3D=3D -1) goto out_err; --=20 2.23.0