From patchwork Sat Jun 2 21:29:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keno Fischer X-Patchwork-Id: 924606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=juliacomputing.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=juliacomputing-com.20150623.gappssmtp.com header.i=@juliacomputing-com.20150623.gappssmtp.com header.b="ZBI0+K8V"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40yvZ72kpwz9s0W for ; Sun, 3 Jun 2018 07:33:03 +1000 (AEST) Received: from localhost ([::1]:32843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPE8y-0000aO-V5 for incoming@patchwork.ozlabs.org; Sat, 02 Jun 2018 17:33:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPE71-0007xr-Kl for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:31:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPE70-0005pQ-M6 for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:59 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:40148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPE70-0005pG-Hb for qemu-devel@nongnu.org; Sat, 02 Jun 2018 17:30:58 -0400 Received: by mail-qt0-x244.google.com with SMTP id q6-v6so2611766qtn.7 for ; Sat, 02 Jun 2018 14:30:58 -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=2lVGDeuS5rQOtCR6f/x1d+TXu6O90X6nTjdRqW5XFC4=; b=ZBI0+K8Ve/L6JA0gLL8FCFNOlppdJGYYPZY/3GDziC+gBHdXRzOBDKmi2VCkUBG/bK 7nSfnT/uKfyM4Yr+6BF2f/TIu077YVq/khkTyn18HglHgPcXz/zBFSO+Rnqgv7oeJybm 3iOC2VP3NOem3ZjW21yNoMOP3fwFT2Wo84dDJqdwRZWI8yrzx3eWyn906F3SmhJRHtcz Sl200PI5TFBWSBIHKa1QBOtQmc+245NL61ontdsnVEo/mvtjgKL+HPeMutC/cjGydO1Q 796pmvRkEtylqgyc37SwLBKbqbpeEs0Z7Irm//8JGZVDorSbJFlviaLA5to5sRnuBKqz uejQ== 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=2lVGDeuS5rQOtCR6f/x1d+TXu6O90X6nTjdRqW5XFC4=; b=cMXTf8rPnzw2L+WyehUNxJKJzC7E/fI36XexqS3Wyp/TJHZbHSjTak1osJwTdCV50e cwnNirJUvHkJi9oIL3OK7RvHRAYkoZCHNv/iIzrAaUWJ8ulFXVfMtDSxwQO29Py2MS8+ nWkmHsedOapIHM/eMtAs2Xm3SGYUCCEchvs6Pm/pdM3rPKrjJc3KaD/xubZU3iCZwrwe rAGceUOa8ezjb0XI/DNPIq6Zw7/1rZQnNpV2cIF0CDScD1iFg5j3uBKOlcZHSg0yhwlb NSWrOcdx2/PW1+FnytqFx7L7ZVXFTfO/lDmCJ/cvS9l+CNrlDzLBwL/y4WxS5rAKdG2b 97Dg== X-Gm-Message-State: APt69E3diylkgJh8oetBt7R94JRhr/jRPDFVRrhvEunXYhQaBXo3eS2P csaMrkD54fXblVlodTuWJSvFMKQz/LI= X-Google-Smtp-Source: ADUXVKL0afCFzfzqrfUUcO33QO/5mFACy09Aj6akb0Q9Byhb4yULu7SLCjuQR8m8rOqsxdfpo6U1+g== X-Received: by 2002:ac8:2d6c:: with SMTP id o41-v6mr15723923qta.107.1527975057449; 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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 02 Jun 2018 14:30:56 -0700 (PDT) From: Keno Fischer To: qemu-devel@nongnu.org Date: Sat, 2 Jun 2018 17:29:39 -0400 Message-Id: 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::244 Subject: [Qemu-devel] [PATCH v3 5/5] 9p: xattr: Properly translate xattrcreate flags 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" As with unlinkat, these flags come from the client and need to be translated to their host values. The protocol values happen to match linux, but that need not be true in general. Signed-off-by: Keno Fischer --- Changes since v2: New patch hw/9pfs/9p.c | 17 +++++++++++++++-- hw/9pfs/9p.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index c842ec5..eef289e 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3327,7 +3327,7 @@ out_nofid: static void coroutine_fn v9fs_xattrcreate(void *opaque) { - int flags; + int flags, rflags = 0; int32_t fid; uint64_t size; ssize_t err = 0; @@ -3344,6 +3344,19 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) } trace_v9fs_xattrcreate(pdu->tag, pdu->id, fid, name.data, size, flags); + if (flags & ~(P9_XATTR_CREATE | P9_XATTR_REPLACE)) { + err = -EINVAL; + goto out_nofid; + } + + if (flags & P9_XATTR_CREATE) { + rflags |= XATTR_CREATE; + } + + if (flags & P9_XATTR_REPLACE) { + rflags |= XATTR_REPLACE; + } + if (size > XATTR_SIZE_MAX) { err = -E2BIG; goto out_nofid; @@ -3365,7 +3378,7 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) xattr_fidp->fs.xattr.copied_len = 0; xattr_fidp->fs.xattr.xattrwalk_fid = false; xattr_fidp->fs.xattr.len = size; - xattr_fidp->fs.xattr.flags = flags; + xattr_fidp->fs.xattr.flags = rflags; v9fs_string_init(&xattr_fidp->fs.xattr.name); v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name); xattr_fidp->fs.xattr.value = g_malloc0(size); diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index bad8ee7..6081b0d 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -169,6 +169,10 @@ typedef struct V9fsConf char *fsdev_id; } V9fsConf; +/* 9p2000.L xattr flags (matches Linux values) */ +#define P9_XATTR_CREATE 1 +#define P9_XATTR_REPLACE 2 + typedef struct V9fsXattr { uint64_t copied_len;