From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>
Subject: Re: [PATCH 2/3] 9pfs: capture root stat
Date: Fri, 04 Jun 2021 15:45:58 +0200 [thread overview]
Message-ID: <3855995.j4n3Whajus@silver> (raw)
In-Reply-To: <e6a33f077cf0675f51bff979e976f8472cfe027d.1622135592.git.qemu_oss@crudebyte.com>
On Donnerstag, 27. Mai 2021 19:04:11 CEST Christian Schoenebeck wrote:
> We already capture the QID of the exported 9p root path, i.e. to
> prevent client access outside the defined, exported filesystem's tree.
> This is currently checked by comparing the root QID with another FID's
> QID.
>
> The problem with the latter is that resolving a QID of any given 9p path
> can only be done on 9p server's main thread, that's because it might
> mutate the server's state if inode remapping is enabled.
>
> For that reason also capture the POSIX stat info of the root path for
> being able to identify on any (e.g. worker) thread whether an
> arbitrary given path is identical to the export root.
>
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
> hw/9pfs/9p.c | 10 +++++++++-
> hw/9pfs/9p.h | 1 +
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index 89aa07db78..825de1561d 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -1400,6 +1400,7 @@ static void coroutine_fn v9fs_attach(void *opaque)
> size_t offset = 7;
> V9fsQID qid;
> ssize_t err;
> + struct stat stbuf;
>
> v9fs_string_init(&uname);
> v9fs_string_init(&aname);
> @@ -1422,7 +1423,13 @@ static void coroutine_fn v9fs_attach(void *opaque)
> clunk_fid(s, fid);
> goto out;
> }
> - err = fid_to_qid(pdu, fidp, &qid);
> + err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
> + if (err < 0) {
> + err = -EINVAL;
> + clunk_fid(s, fid);
> + goto out;
> + }
> + err = stat_to_qid(pdu, &stbuf, &qid);
> if (err < 0) {
> err = -EINVAL;
> clunk_fid(s, fid);
> @@ -1455,6 +1462,7 @@ static void coroutine_fn v9fs_attach(void *opaque)
> err += offset;
>
> memcpy(&s->root_qid, &qid, sizeof(qid));
> + memcpy(&s->root_st, &stbuf, sizeof(struct stat));
I'll make that sizeof(stbuf) instead to match with common code style here.
> trace_v9fs_attach_return(pdu->tag, pdu->id,
> qid.type, qid.version, qid.path);
> out:
> diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
> index 00381591ff..6f0b4c78c0 100644
> --- a/hw/9pfs/9p.h
> +++ b/hw/9pfs/9p.h
> @@ -356,6 +356,7 @@ struct V9fsState {
> Error *migration_blocker;
> V9fsConf fsconf;
> V9fsQID root_qid;
> + struct stat root_st;
> dev_t dev_id;
> struct qht qpd_table;
> struct qht qpp_table;
next prev parent reply other threads:[~2021-06-04 13:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 17:13 [PATCH 0/3] 9pfs: Twalk optimization Christian Schoenebeck
2021-05-27 17:03 ` [PATCH 1/3] 9pfs: Twalk benchmark Christian Schoenebeck
2021-05-27 17:04 ` [PATCH 2/3] 9pfs: capture root stat Christian Schoenebeck
2021-06-04 13:45 ` Christian Schoenebeck [this message]
2021-05-27 17:05 ` [PATCH 3/3] 9pfs: reduce latency of Twalk Christian Schoenebeck
2021-05-27 18:24 ` Christian Schoenebeck
2021-06-04 12:14 ` Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3855995.j4n3Whajus@silver \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).