From nobody Sun Nov 2 17:23:57 2025 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 1527975182763895.254941459438; Sat, 2 Jun 2018 14:33:02 -0700 (PDT) Received: from localhost ([::1]:32845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPE8z-0000gi-TA for importer@patchew.org; Sat, 02 Jun 2018 17:33:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPE70-0007wf-1s for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPE6z-0005oR-80 for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:58 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:40146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPE6z-0005oF-2z for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:57 -0400 Received: by mail-qt0-x242.google.com with SMTP id q6-v6so2611723qtn.7 for ; Sat, 02 Jun 2018 14:30:57 -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 k2-v6sm21366628qkl.95.2018.06.02.14.30.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 02 Jun 2018 14:30:54 -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=viO+UGj1DZ5PdNGzv9PR54c7TzmOc+Q8PpO4HHpL95w=; b=awkqYjf+XFOBsJ7rSu3DaYcXLYUQQG6IeTuxTvBzfIZKLG0lSoiQpAQdcSCpbTsR3v ExThxZ/rjlTRx1gW0yyXHPMYLQWM+hQGqsNiE6Kh23w8nIE8usl01llzwh6bo+cZBb+D 5eCQeRU1P9r41AG2Q8nTY33z1FbvK4h40GTTvSfsBMU8ElKlEShvWZD4rMNEiQLv/rPD +4LBk6wKZLy9u3TmPMb5kqquKgMtjrqjj3I7+MODzQWbnA2ZnASNRVnMrq5OKKp7SJOH GpeDvL4cS+tsHackSXA7bHTUT90RZWmQfNi/k3bIGpFwRqsSpaqtIHsYmCnNEcGqzJuR UEKA== 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=viO+UGj1DZ5PdNGzv9PR54c7TzmOc+Q8PpO4HHpL95w=; b=EQizMPXTYYACETyQ+u06vN3rvf+Z/m4QTEiuDvtUAAihRZMmS/9BjoNLRu/2xYCRac 5EzEHMjYrgw9DDWsyxddfQ0wkMzJUScWB7FWUnpSIttUwfIK01FUdN2Y9BfqUQf64L35 Tj6l2TfQtL5VXu6rmAWtZMYpP6BM8DCgmz9UPC4KSv7iF10EOV12Na+uEcBzF67mI7ln oZljNDigJTC8F9ZLFiGrD0L5ZKZT37he7LhAUnQLpmBZk9qLuqlGAeXF/pf9y4EAmZeU efc6Qh6wuwIukVvCwbSqP75Msx8JWHduM/f+x2SAZtghi36qNXkcQZHq35UPKp9a+Y78 uONA== X-Gm-Message-State: APt69E2Y07dMpxvk5kpXj/akkTyHo37ohSc1659ICiQXD2xkSRLvef3w NYkYVRI6B2tPwbDkb6aGvIPLbIn0yNY= X-Google-Smtp-Source: ADUXVKKBeuSWtdcrxw7x1e6STdlFj0XJNLA9GGgOTeqemttTKfGiA9aZnwspj2A59Hyu70jufh/Hvg== X-Received: by 2002:aed:35f0:: with SMTP id d45-v6mr15112710qte.92.1527975055950; Sat, 02 Jun 2018 14:30:55 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 2 Jun 2018 17:29:38 -0400 Message-Id: <437736e77ecd0d5ecd6bb430319a6b0e2dfb571d.1527973524.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:c0d::242 Subject: [Qemu-devel] [PATCH v3 4/5] 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" The 9p-local 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. 9p-handle did this properly however. Move the translation code to the generic 9p server code and add an error if unrecognized flags are passed. Signed-off-by: Keno Fischer --- Changes since v2: * Remove 9p-handle code that did the same translation and is now incorrect. hw/9pfs/9p-handle.c | 8 +------- hw/9pfs/9p.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c index 4dc0d2b..f3641db 100644 --- a/hw/9pfs/9p-handle.c +++ b/hw/9pfs/9p-handle.c @@ -559,19 +559,13 @@ static int handle_unlinkat(FsContext *ctx, V9fsPath *= dir, { int dirfd, ret; HandleData *data =3D (HandleData *) ctx->private; - int rflags; =20 dirfd =3D open_by_handle(data->mountfd, dir->data, O_PATH); if (dirfd < 0) { return dirfd; } =20 - rflags =3D 0; - if (flags & P9_DOTL_AT_REMOVEDIR) { - rflags |=3D AT_REMOVEDIR; - } - - ret =3D unlinkat(dirfd, name, rflags); + ret =3D unlinkat(dirfd, name, flags); =20 close(dirfd); return ret; diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 4386d69..c842ec5 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