From nobody Mon Feb 9 06:33:57 2026 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.zohomail.com; dkim=fail; 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 152781711638193.23344657526536; Thu, 31 May 2018 18:38:36 -0700 (PDT) Received: from localhost ([::1]:46937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOZ1W-0002KC-9s for importer@patchew.org; Thu, 31 May 2018 21:38:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOYr3-00033n-3n for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOYqz-000333-L5 for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:45 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:42727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOYqz-00032X-GU for qemu-devel@nongnu.org; Thu, 31 May 2018 21:27:41 -0400 Received: by mail-qk0-x241.google.com with SMTP id j80-v6so16999940qke.9 for ; Thu, 31 May 2018 18:27:41 -0700 (PDT) Received: from localhost.localdomain (96-86-104-61-static.hfc.comcastbusiness.net. [96.86.104.61]) by smtp.gmail.com with ESMTPSA id o68-v6sm2003842qkc.19.2018.05.31.18.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 18:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=uFwA25ae3YVoMkhsDHZIq6dK58QiW7McLaLJNiZgJrc=; b=Mn2CGYZtEibKqpmlQjnLJYaEUr9xO975g16ndO7+BY4jDxlk29lzbviXpkAwepJmHa Z2WIXAy28WW1dUX/u/ECFjGDZAUz+r5iJQoQCeMYUJ6n7Z8C25KxpJG2ZO8Kd9tjKJM3 3WKeO6E0Fd7wuL0pbDZOzFlLe8lWwr4MR0JWaxY2U6PXYWH4OreQhL/sgtduAv1nGd1H CeM30CZ2DZtwK1puaHXDeGMwhCy8xcUFipwrfceHDKs/2Z5JWSkdHl/rftYKWwudfzsV MChhbntQFh363+2avOY8mC6QFPyfs9Z9j1wzsM2QrK93exn7lNgnCfXu2FUPSssXzucH S4EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=uFwA25ae3YVoMkhsDHZIq6dK58QiW7McLaLJNiZgJrc=; b=caTzjBdZf3Vv1tqfZv7HEB6oMXuGWiOjwHvwSwF9Llht7kMTyJXszlmLeeHcnoLtwm e+tqPnfgaQ+K/1aKfQK8FnXXRd2NEKM4MRMzUIQZkFRrw1Knuxk/UVUZWT8+f7BOFt+t XHNtCdHk1ljPBhTKlwB06G+nJ65mLhH72TZZcU+ddf1Vdga5s4IU4eTLORIKZqlH6iZf 5gV6WssfBrWSfE8n9Ujt7xw/fgdG8uOlQJLPDb7UC89iA/XjaTs7cbssxzGICxUy8sff nXf/TttVxWfbsG3BOskj4SsPNIAdKkCCgVyyNNsY6FQ3pB8R9zntzqFWDBaF8pbbnwg3 2l6A== X-Gm-Message-State: APt69E14cjVmNs90x3+kgfQ8v7afnpN8/CERyAGNSA+zelG1qsyIj3Ay +9kNxL8RVupbjwh4lTUX4bC+yvIi84g= X-Google-Smtp-Source: ADUXVKKScA2BX51wlSOJWdUD1kE5JwwtUtKzdjqXgueGYnQ5LBDBLqNFeXGoCEMaxiVrwpy44KheNQ== X-Received: by 2002:a37:a8ce:: with SMTP id r197-v6mr8172141qke.93.1527816460607; Thu, 31 May 2018 18:27:40 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 21:26:04 -0400 Message-Id: <21ef05f216f09056c252d2d23a18dd75008e8c72.1527814874.git.keno@juliacomputing.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v2 09/20] 9p: Properly check/translate flags in unlinkat 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: Keno Fischer , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This code previously relied on P9_DOTL_AT_REMOVEDIR and AT_REMOVEDIR having the same numerical value and deferred any errorchecking to the syscall itself. However, while the former assumption is true on Linux, it is not true in general. Thus, add appropriate error checking and translation to the 9p unlinkat server code. Signed-off-by: Keno Fischer --- Changes since v1: * Code was moved from 9p-local.c to server entry point in 9p.c hw/9pfs/9p.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index b80db65..a757374 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2522,7 +2522,7 @@ static void coroutine_fn v9fs_unlinkat(void *opaque) { int err =3D 0; V9fsString name; - int32_t dfid, flags; + int32_t dfid, flags, rflags =3D 0; size_t offset =3D 7; V9fsPath path; V9fsFidState *dfidp; @@ -2549,6 +2549,15 @@ static void coroutine_fn v9fs_unlinkat(void *opaque) goto out_nofid; } =20 + if (flags & ~P9_DOTL_AT_REMOVEDIR) { + err =3D -EINVAL; + goto out_nofid; + } + + if (flags & P9_DOTL_AT_REMOVEDIR) { + rflags |=3D AT_REMOVEDIR; + } + dfidp =3D get_fid(pdu, dfid); if (dfidp =3D=3D NULL) { err =3D -EINVAL; @@ -2567,7 +2576,7 @@ static void coroutine_fn v9fs_unlinkat(void *opaque) if (err < 0) { goto out_err; } - err =3D v9fs_co_unlinkat(pdu, &dfidp->path, &name, flags); + err =3D v9fs_co_unlinkat(pdu, &dfidp->path, &name, rflags); if (!err) { err =3D offset; } --=20 2.8.1