Skip to content
Snippets Groups Projects
  1. May 11, 2022
  2. May 07, 2022
  3. May 03, 2022
  4. Apr 21, 2022
  5. Mar 02, 2022
  6. Feb 17, 2022
  7. Feb 16, 2022
    • Sebastian Hasler's avatar
      virtiofsd: Do not support blocking flock · 41af4459
      Sebastian Hasler authored
      
      With the current implementation, blocking flock can lead to
      deadlock. Thus, it's better to return EOPNOTSUPP if a user attempts
      to perform a blocking flock request.
      
      Signed-off-by: default avatarSebastian Hasler <sebastian.hasler@stuvus.uni-stuttgart.de>
      Message-Id: <20220113153249.710216-1-sebastian.hasler@stuvus.uni-stuttgart.de>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      41af4459
    • Paolo Bonzini's avatar
      meson: use .require() and .disable_auto_if() method for features · a436d6d4
      Paolo Bonzini authored
      
      The method is now in 0.59, using it simplifies some conditionals.
      
      There is a small change, which is to build virtfs-proxy-helper in a
      tools-only build.  This is done for consistency with other tools,
      which are not culled by the absence of system emulator binaries.
      
      .disable_auto_if() would also be useful to check for packages,
      for example
      
      -linux_io_uring = not_found
      -if not get_option('linux_io_uring').auto() or have_block
      -  linux_io_uring = dependency('liburing', required: get_option('linux_io_uring'),
      -                              method: 'pkg-config', kwargs: static_kwargs)
      -endif
      +linux_io_uring = dependency('liburing',
      +  required: get_option('linux_io_uring').disable_auto_if(not have_block),
      +  method: 'pkg-config', kwargs: static_kwargs)
      
      This change however is much larger and I am not sure about the improved
      readability, so I am not performing it right now.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a436d6d4
  8. Feb 14, 2022
  9. Jan 26, 2022
  10. Oct 25, 2021
  11. Sep 16, 2021
    • Sergio Lopez's avatar
      virtiofsd: Reverse req_list before processing it · 046d91c8
      Sergio Lopez authored
      
      With the thread pool disabled, we add the requests in the queue to a
      GList, processing by iterating over there afterwards.
      
      For adding them, we're using "g_list_prepend()", which is more
      efficient but causes the requests to be processed in reverse order,
      breaking the read-ahead and request-merging optimizations in the host
      for sequential operations.
      
      According to the documentation, if you need to process the request
      in-order, using "g_list_prepend()" and then reversing the list with
      "g_list_reverse()" is more efficient than using "g_list_append()", so
      let's do it that way.
      
      Testing on a spinning disk (to boost the increase of read-ahead and
      request-merging) shows a 4x improvement on sequential write fio test:
      
      Test:
      fio --directory=/mnt/virtio-fs --filename=fio-file1 --runtime=20
      --iodepth=16 --size=4G --direct=1 --blocksize=4K --ioengine libaio
      --rw write --name seqwrite-libaio
      
      Without "g_list_reverse()":
      ...
      Jobs: 1 (f=1): [W(1)][100.0%][w=22.4MiB/s][w=5735 IOPS][eta 00m:00s]
      seqwrite-libaio: (groupid=0, jobs=1): err= 0: pid=710: Tue Aug 24 12:58:16 2021
        write: IOPS=5709, BW=22.3MiB/s (23.4MB/s)(446MiB/20002msec); 0 zone resets
      ...
      
      With "g_list_reverse()":
      ...
      Jobs: 1 (f=1): [W(1)][100.0%][w=84.0MiB/s][w=21.5k IOPS][eta 00m:00s]
      seqwrite-libaio: (groupid=0, jobs=1): err= 0: pid=716: Tue Aug 24 13:00:15 2021
        write: IOPS=21.3k, BW=83.1MiB/s (87.2MB/s)(1663MiB/20001msec); 0 zone resets
      ...
      
      Signed-off-by: default avatarSergio Lopez <slp@redhat.com>
      Message-Id: <20210824131158.39970-1-slp@redhat.com>
      Reviewed-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      046d91c8
    • Thomas Huth's avatar
      tools/virtiofsd: Add fstatfs64 syscall to the seccomp allowlist · 8cfd339b
      Thomas Huth authored
      The virtiofsd currently crashes on s390x when doing something like
      this in the guest:
      
       mkdir -p /mnt/myfs
       mount -t virtiofs myfs /mnt/myfs
       touch /mnt/myfs/foo.txt
       stat -f /mnt/myfs/foo.txt
      
      The problem is that the fstatfs64 syscall is called in this case
      from the virtiofsd. We have to put it on the seccomp allowlist to
      avoid that the daemon gets killed in this case.
      
      Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2001728
      
      
      Suggested-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20210914123214.181885-1-thuth@redhat.com>
      Reviewed-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: default avatarSergio Lopez <slp@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      8cfd339b
  12. Sep 15, 2021
  13. Jul 09, 2021
  14. Jul 05, 2021
    • Vivek Goyal's avatar
      virtiofsd: Add an option to enable/disable posix acls · 65a820d2
      Vivek Goyal authored
      
      fuse has an option FUSE_POSIX_ACL which needs to be opted in by fuse
      server to enable posix acls. As of now we are not opting in for this,
      so posix acls are disabled on virtiofs by default.
      
      Add virtiofsd option "-o posix_acl/no_posix_acl" to let users enable/disable
      posix acl support. By default it is disabled as of now due to performance
      concerns with cache=none.
      
      Currently even if file server has not opted in for FUSE_POSIX_ACL, user can
      still query acl and set acl, and system.posix_acl_access and
      system.posix_acl_default xattrs show up listxattr response.
      
      Miklos said this is confusing. So he said lets block and filter
      system.posix_acl_access and system.posix_acl_default xattrs in
      getxattr/setxattr/listxattr if user has explicitly disabled
      posix acls using -o no_posix_acl.
      
      As of now continuing to keeping the existing behavior if user did not
      specify any option to disable acl support due to concerns about backward
      compatibility.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20210622150852.1507204-8-vgoyal@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      65a820d2
    • Vivek Goyal's avatar
      virtiofsd: Switch creds, drop FSETID for system.posix_acl_access xattr · f1aa1774
      Vivek Goyal authored
      
      When posix access acls are set on a file, it can lead to adjusting file
      permissions (mode) as well. If caller does not have CAP_FSETID and it
      also does not have membership of owner group, this will lead to clearing
      SGID bit in mode.
      
      Current fuse code is written in such a way that it expects file server
      to take care of chaning file mode (permission), if there is a need.
      Right now, host kernel does not clear SGID bit because virtiofsd is
      running as root and has CAP_FSETID. For host kernel to clear SGID,
      virtiofsd need to switch to gid of caller in guest and also drop
      CAP_FSETID (if caller did not have it to begin with).
      
      If SGID needs to be cleared, client will set the flag
      FUSE_SETXATTR_ACL_KILL_SGID in setxattr request. In that case server
      should kill sgid.
      
      Currently just switch to uid/gid of the caller and drop CAP_FSETID
      and that should do it.
      
      This should fix the xfstest generic/375 test case.
      
      We don't have to switch uid for this to work. That could be one optimization
      that pass a parameter to lo_change_cred() to only switch gid and not uid.
      
      Also this will not work whenever (if ever) we support idmapped mounts. In
      that case it is possible that uid/gid in request are 0/0 but still we
      need to clear SGID. So we will have to pick a non-root sgid and switch
      to that instead. That's an TODO item for future when idmapped mount
      support is introduced.
      
      This patch only adds the capability to switch creds and drop FSETID
      when acl xattr is set. This does not take affect yet. It can take
      affect when next patch adds the capability to enable posix_acl.
      
      Reported-by: default avatarLuis Henriques <lhenriques@suse.de>
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20210622150852.1507204-7-vgoyal@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      f1aa1774
    • Vivek Goyal's avatar
      virtiofsd: Add capability to change/restore umask · 227e5d7f
      Vivek Goyal authored
      
      When parent directory has default acl and a file is created in that
      directory, then umask is ignored and final file permissions are
      determined using default acl instead. (man 2 umask).
      
      Currently, fuse applies the umask and sends modified mode in create
      request accordingly. fuse server can set FUSE_DONT_MASK and tell
      fuse client to not apply umask and fuse server will take care of
      it as needed.
      
      With posix acls enabled, requirement will be that we want umask
      to determine final file mode if parent directory does not have
      default acl.
      
      So if posix acls are enabled, opt in for FUSE_DONT_MASK. virtiofsd
      will set umask of the thread doing file creation. And host kernel
      should use that umask if parent directory does not have default
      acls, otherwise umask does not take affect.
      
      Miklos mentioned that we already call unshare(CLONE_FS) for
      every thread. That means umask has now become property of per
      thread and it should be ok to manipulate it in file creation path.
      
      This patch only adds capability to change umask and restore it. It
      does not enable it yet. Next few patches will add capability to enable it
      based on if user enabled posix_acl or not.
      
      This should fix fstest generic/099.
      
      Reported-by: default avatarLuis Henriques <lhenriques@suse.de>
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20210622150852.1507204-6-vgoyal@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      227e5d7f
    • Vivek Goyal's avatar
      virtiofsd: Add umask to seccom allow list · 6d0028b9
      Vivek Goyal authored
      
      Patches in this series  are going to make use of "umask" syscall.
      So allow it.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20210622150852.1507204-5-vgoyal@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      6d0028b9
    • Vivek Goyal's avatar
      virtiofsd: Add support for extended setxattr · c46ef954
      Vivek Goyal authored
      
      Add the bits to enable support for setxattr_ext if fuse offers it. Do not
      enable it by default yet. Let passthrough_ll opt-in. Enabling it by deafult
      kind of automatically means that you are taking responsibility of clearing
      SGID if ACL is set.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20210622150852.1507204-4-vgoyal@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
        Fixed up double def in fuse_common.h
      c46ef954
    • Vivek Goyal's avatar
      virtiofsd: Fix xattr operations overwriting errno · 5290fb62
      Vivek Goyal authored
      
      getxattr/setxattr/removexattr/listxattr operations handle regualar
      and non-regular files differently. For the case of non-regular files
      we do fchdir(/proc/self/fd) and the xattr operation and then revert
      back to original working directory. After this we are saving errno
      and that's buggy because fchdir() will overwrite the errno.
      
      FCHDIR_NOFAIL(lo->proc_self_fd);
      ret = getxattr(procname, name, value, size);
      FCHDIR_NOFAIL(lo->root.fd);
      
      if (ret == -1)
          saverr = errno
      
      In above example, if getxattr() failed, we will still return 0 to caller
      as errno must have been written by FCHDIR_NOFAIL(lo->root.fd) call.
      Fix all such instances and capture "errno" early and save in "saverr"
      variable.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20210622150852.1507204-3-vgoyal@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      5290fb62
    • Vivek Goyal's avatar
      virtiofsd: Fix fuse setxattr() API change issue · 06162445
      Vivek Goyal authored
      
      With kernel header updates fuse_setxattr_in struct has grown in size.
      But this new struct size only takes affect if user has opted in
      for fuse feature FUSE_SETXATTR_EXT otherwise fuse continues to
      send "fuse_setxattr_in" of older size. Older size is determined
      by FUSE_COMPAT_SETXATTR_IN_SIZE.
      
      Fix this. If we have not opted in for FUSE_SETXATTR_EXT, then
      expect that we will get fuse_setxattr_in of size FUSE_COMPAT_SETXATTR_IN_SIZE
      and not sizeof(struct fuse_sexattr_in).
      
      Fixes: 278f064e ("Update Linux headers to 5.13-rc4")
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20210622150852.1507204-2-vgoyal@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      06162445
    • Greg Kurz's avatar
      virtiofsd: Don't allow file creation with FUSE_OPEN · 1d03e566
      Greg Kurz authored
      
      A well behaved FUSE client uses FUSE_CREATE to create files. It isn't
      supposed to pass O_CREAT along a FUSE_OPEN request, as documented in
      the "fuse_lowlevel.h" header :
      
          /**
           * Open a file
           *
           * Open flags are available in fi->flags. The following rules
           * apply.
           *
           *  - Creation (O_CREAT, O_EXCL, O_NOCTTY) flags will be
           *    filtered out / handled by the kernel.
      
      But if the client happens to do it anyway, the server ends up passing
      this flag to open() without the mandatory mode_t 4th argument. Since
      open() is a variadic function, glibc will happily pass whatever it
      finds on the stack to the syscall. If this file is compiled with
      -D_FORTIFY_SOURCE=2, glibc will even detect that and abort:
      
      *** invalid openat64 call: O_CREAT or O_TMPFILE without mode ***: terminated
      
      Specifying O_CREAT with FUSE_OPEN is a protocol violation. Check this
      in do_open(), print out a message and return an error to the client,
      EINVAL like we already do when fuse_mbuf_iter_advance() fails.
      
      The FUSE filesystem doesn't currently support O_TMPFILE, but the very
      same would happen if O_TMPFILE was passed in a FUSE_OPEN request. Check
      that as well.
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210624101809.48032-1-groug@kaod.org>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      1d03e566
    • Daniel P. Berrangé's avatar
      virtiofsd: use GDateTime for formatting timestamp for debug messages · d9a801f7
      Daniel P. Berrangé authored
      
      The GDateTime APIs provided by GLib avoid portability pitfalls, such
      as some platforms where 'struct timeval.tv_sec' field is still 'long'
      instead of 'time_t'. When combined with automatic cleanup, GDateTime
      often results in simpler code too.
      
      Localtime is changed to UTC to avoid the need to grant extra seccomp
      permissions for GLib's access of the timezone database.
      
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20210611164319.67762-1-berrange@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      d9a801f7
  15. Jun 04, 2021
Loading