qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: "misono.tomohiro@fujitsu.com" <misono.tomohiro@fujitsu.com>
Cc: "virtio-fs@redhat.com" <virtio-fs@redhat.com>,
	'Miklos Szeredi' <mszeredi@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Virtio-fs] [PATCH 0/2] virtiofsd: Two fix for xattr operation
Date: Mon, 21 Oct 2019 10:40:47 +0100	[thread overview]
Message-ID: <20191021094047.GF22659@stefanha-x1.localdomain> (raw)
In-Reply-To: <OSBPR01MB37835DC3A2F179AFD3A9074BE56C0@OSBPR01MB3783.jpnprd01.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

On Fri, Oct 18, 2019 at 08:51:20AM +0000, misono.tomohiro@fujitsu.com wrote:
> > Doing unshare(CLONE_FS) after thread startup seems safe, though must be careful to change the working directory to the root of
> > the mount
> > *before* starting any threads.
> 
> I think working directry is changed in setup_sandbox() -> setup_mount_namespace() -> setup_pivot_root().
> So, can we just add unshare(CLONE_FS) in fv_queue_worker()?

fv_queue_worker() is the thread pool worker function that is called for
each request.  Calling unshare(CLONE_FS) for each request is not
necessary and will reduce performance.

A thread-local variable can be used to avoid repeated calls to
unshare(CLONE_FS) from the same worker thread:

  static __thread bool clone_fs_called;

  static void fv_queue_worker(gpointer data, gpointer user_data)
  {
      ...
      if (!clone_fs_called) {
          int ret;

	  ret = unshare(CLONE_FS);
	  assert(ret == 0); /* errors not expected according to man page */

	  clone_fs_called = true;
      }

Another issue is the seccomp policy.  Since worker threads are spawned
at runtime it is necessary to add the unshare(2) syscall to the seccomp
whitelist in contrib/virtiofsd/seccomp.c.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-10-21  9:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 10:37 [PATCH 0/2] virtiofsd: Two fix for xattr operation Misono Tomohiro
2019-10-16 10:37 ` [PATCH 1/2] virtiofsd: Avoid process hang when doing xattr operation to FIFO Misono Tomohiro
2019-10-16 10:37 ` [PATCH 2/2] virtiofsd: Allow setxattr operation to directry Misono Tomohiro
2019-10-17 10:05 ` [Virtio-fs] [PATCH 0/2] virtiofsd: Two fix for xattr operation Stefan Hajnoczi
2019-10-17 11:23   ` Miklos Szeredi
2019-10-17 13:01     ` Miklos Szeredi
2019-10-17 15:25     ` Vivek Goyal
2019-10-17 15:45       ` Miklos Szeredi
2019-10-17 16:09     ` Stefan Hajnoczi
2019-10-17 16:48       ` Miklos Szeredi
2019-10-18  7:16         ` Miklos Szeredi
2019-10-18  8:51           ` misono.tomohiro
2019-10-21  9:40             ` Stefan Hajnoczi [this message]
2019-10-23 11:42               ` misono.tomohiro
2019-10-25 12:54                 ` Stefan Hajnoczi
2019-10-18 10:09           ` Stefan Hajnoczi

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=20191021094047.GF22659@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=misono.tomohiro@fujitsu.com \
    --cc=mszeredi@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=virtio-fs@redhat.com \
    /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).