Skip to content
Snippets Groups Projects
  1. Jan 06, 2021
  2. Dec 18, 2020
    • Alex Chen's avatar
      virtiofsd: Remove useless code about send_notify_iov · 03350a1e
      Alex Chen authored
      
      The 'ch' will be NULL in the following stack:
      send_notify_iov()->fuse_send_msg()->virtio_send_msg(), and
      this may lead to NULL pointer dereferenced in virtio_send_msg().
      But send_notify_iov() was never called, so remove the useless code
      about send_notify_iov() to fix this problem.
      
      Signed-off-by: default avatarAlex Chen <alex.chen@huawei.com>
      Message-Id: <20201214121615.29967-1-alex.chen@huawei.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      03350a1e
    • Laszlo Ersek's avatar
      virtiofsd: update FUSE_FORGET comment on "lo_inode.nlookup" · d6211148
      Laszlo Ersek authored
      
      Miklos confirms it's *only* the FUSE_FORGET request that the client can
      use for decrementing "lo_inode.nlookup".
      
      Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Fixes: 1222f015
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Message-Id: <20201208073936.8629-1-lersek@redhat.com>
      Reviewed-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      d6211148
    • Vivek Goyal's avatar
      virtiofsd: Check file type in lo_flush() · 31a4990f
      Vivek Goyal authored
      
      Currently lo_flush() is written in such a way that it expects to receive
      a FLUSH requests on a regular file (and not directories). For example,
      we call lo_fi_fd() which searches lo->fd_map. If we open directories
      using opendir(), we keep don't keep track of these in lo->fd_map instead
      we keep them in lo->dir_map. So we expect lo_flush() to be called on
      regular files only.
      
      Even linux fuse client calls FLUSH only for regular files and not
      directories. So put a check for filetype and return EBADF if
      lo_flush() is called on a non-regular file.
      
      Reported-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20201211142544.GB3285@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      31a4990f
    • Vivek Goyal's avatar
      virtiofsd: Disable posix_lock hash table if remote locks are not enabled · e7e8aa8a
      Vivek Goyal authored
      
      If remote posix locks are not enabled (lo->posix_lock == false), then disable
      code paths taken to initialize inode->posix_lock hash table and corresponding
      destruction and search etc.
      
      lo_getlk() and lo_setlk() have been modified to return ENOSYS if daemon
      does not support posix lock but client still sends a lock/unlock request.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20201207183021.22752-3-vgoyal@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      e7e8aa8a
    • Vivek Goyal's avatar
      virtiofsd: Set up posix_lock hash table for root inode · ad3bfe1b
      Vivek Goyal authored
      
      We setup per inode hash table ->posix_lock to support remote posix locks.
      But we forgot to initialize this table for root inode.
      
      Laszlo managed to trigger an issue where he sent a FUSE_FLUSH request for
      root inode and lo_flush() found inode with inode->posix_lock NULL and
      accessing this table crashed virtiofsd.
      
      May be we can get rid of initializing this hash table for directory
      objects completely. But that optimization is for another day.
      
      Reported-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20201207195539.GB3107@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      ad3bfe1b
    • Laszlo Ersek's avatar
      virtiofsd: make the debug log timestamp on stderr more human-readable · bebc3c24
      Laszlo Ersek authored
      
      The current timestamp format doesn't help me visually notice small jumps
      in time ("small" as defined on human scale, such as a few seconds or a few
      ten seconds). Replace it with a local time format where such differences
      stand out.
      
      Before:
      
      > [13316826770337] [ID: 00000004] unique: 62, opcode: RELEASEDIR (29), nodeid: 1, insize: 64, pid: 1
      > [13316826778175] [ID: 00000004]    unique: 62, success, outsize: 16
      > [13316826781156] [ID: 00000004] virtio_send_msg: elem 0: with 1 in desc of length 16
      > [15138279317927] [ID: 00000001] virtio_loop: Got VU event
      > [15138279504884] [ID: 00000001] fv_queue_set_started: qidx=1 started=0
      > [15138279519034] [ID: 00000003] fv_queue_thread: kill event on queue 1 - quitting
      > [15138280876463] [ID: 00000001] fv_remove_watch: TODO! fd=9
      > [15138280897381] [ID: 00000001] virtio_loop: Waiting for VU event
      > [15138280946834] [ID: 00000001] virtio_loop: Got VU event
      > [15138281175421] [ID: 00000001] virtio_loop: Waiting for VU event
      > [15138281182387] [ID: 00000001] virtio_loop: Got VU event
      > [15138281189474] [ID: 00000001] virtio_loop: Waiting for VU event
      > [15138309321936] [ID: 00000001] virtio_loop: Unexpected poll revents 11
      > [15138309434150] [ID: 00000001] virtio_loop: Exit
      
      (Notice how you don't (easily) notice the gap in time after
      "virtio_send_msg", and especially the amount of time passed is hard to
      estimate.)
      
      After:
      
      > [2020-12-08 06:43:22.58+0100] [ID: 00000004] unique: 51, opcode: RELEASEDIR (29), nodeid: 1, insize: 64, pid: 1
      > [2020-12-08 06:43:22.58+0100] [ID: 00000004]    unique: 51, success, outsize: 16
      > [2020-12-08 06:43:22.58+0100] [ID: 00000004] virtio_send_msg: elem 0: with 1 in desc of length 16
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] virtio_loop: Got VU event
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] fv_queue_set_started: qidx=1 started=0
      > [2020-12-08 06:43:29.34+0100] [ID: 00000003] fv_queue_thread: kill event on queue 1 - quitting
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] fv_remove_watch: TODO! fd=9
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] virtio_loop: Waiting for VU event
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] virtio_loop: Got VU event
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] virtio_loop: Waiting for VU event
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] virtio_loop: Got VU event
      > [2020-12-08 06:43:29.34+0100] [ID: 00000001] virtio_loop: Waiting for VU event
      > [2020-12-08 06:43:29.37+0100] [ID: 00000001] virtio_loop: Unexpected poll revents 11
      > [2020-12-08 06:43:29.37+0100] [ID: 00000001] virtio_loop: Exit
      
      Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Message-Id: <20201208055043.31548-1-lersek@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      bebc3c24
    • Vivek Goyal's avatar
      virtiofsd: Use --thread-pool-size=0 to mean no thread pool · e49393a3
      Vivek Goyal authored
      
      Right now we create a thread pool and main thread hands over the request
      to thread in thread pool to process. Number of threads in thread pool
      can be managed by option --thread-pool-size.
      
      In tests we have noted that many of the workloads are getting better
      performance if we don't use a thread pool at all and process all
      the requests in the context of a thread receiving the request.
      
      Hence give user an option to be able to run virtiofsd without using
      a thread pool.
      
      To implement this, I have used existing option --thread-pool-size. This
      option defines how many maximum threads can be in the thread pool.
      Thread pool size zero freezes thead pool. I can't see why will one
      start virtiofsd with a frozen thread pool (hence frozen file system).
      So I am redefining --thread-pool-size=0 to mean, don't use a thread pool.
      Instead process the request in the context of thread receiving request
      from the queue.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Message-Id: <20201109143548.GA1479853@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      e49393a3
  3. Dec 15, 2020
  4. Dec 10, 2020
    • Markus Armbruster's avatar
      Clean up includes · 4bd802b2
      Markus Armbruster authored
      
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes, with the changes
      to the following files manually reverted:
      
          contrib/libvhost-user/libvhost-user-glib.h
          contrib/libvhost-user/libvhost-user.c
          contrib/libvhost-user/libvhost-user.h
          contrib/plugins/hotblocks.c
          contrib/plugins/hotpages.c
          contrib/plugins/howvec.c
          contrib/plugins/lockstep.c
          linux-user/mips64/cpu_loop.c
          linux-user/mips64/signal.c
          linux-user/sparc64/cpu_loop.c
          linux-user/sparc64/signal.c
          linux-user/x86_64/cpu_loop.c
          linux-user/x86_64/signal.c
          target/s390x/gen-features.c
          tests/fp/platform.h
          tests/migration/s390x/a-b-bios.c
          tests/plugin/bb.c
          tests/plugin/empty.c
          tests/plugin/insn.c
          tests/plugin/mem.c
          tests/test-rcu-simpleq.c
          tests/test-rcu-slist.c
          tests/test-rcu-tailq.c
          tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c
      
      contrib/plugins/, tests/plugin/, and tests/test-rcu-slist.c appear not
      to include osdep.h intentionally.  The remaining reverts are the same
      as in commit bbfff196.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201113061216.2483385-1-armbru@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Acked-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Tested-by: default avatarThomas Huth <thuth@redhat.com>
      Acked-by: default avatarCornelia Huck <cohuck@redhat.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Acked-by: default avatarAlexander Bulekov <alxndr@bu.edu>
      4bd802b2
  5. Dec 08, 2020
  6. Nov 12, 2020
  7. Nov 03, 2020
  8. Nov 02, 2020
  9. Oct 28, 2020
  10. Oct 26, 2020
  11. Oct 23, 2020
  12. Oct 12, 2020
    • Stefan Hajnoczi's avatar
      virtiofsd: avoid /proc/self/fd tempdir · ebf10195
      Stefan Hajnoczi authored
      
      In order to prevent /proc/self/fd escapes a temporary directory is
      created where /proc/self/fd is bind-mounted. This doesn't work on
      read-only file systems.
      
      Avoid the temporary directory by bind-mounting /proc/self/fd over /proc.
      This does not affect other processes since we remounted / with MS_REC |
      MS_SLAVE. /proc must exist and virtiofsd does not use it so it's safe to
      do this.
      
      Path traversal can be tested with the following function:
      
        static void test_proc_fd_escape(struct lo_data *lo)
        {
            int fd;
            int level = 0;
            ino_t last_ino = 0;
      
            fd = lo->proc_self_fd;
            for (;;) {
                struct stat st;
      
                if (fstat(fd, &st) != 0) {
                    perror("fstat");
                    return;
                }
                if (last_ino && st.st_ino == last_ino) {
                    fprintf(stderr, "inode number unchanged, stopping\n");
                    return;
                }
                last_ino = st.st_ino;
      
                fprintf(stderr, "Level %d dev %lu ino %lu\n", level,
                        (unsigned long)st.st_dev,
                        (unsigned long)last_ino);
                fd = openat(fd, "..", O_PATH | O_DIRECTORY | O_NOFOLLOW);
                level++;
            }
        }
      
      Before and after this patch only Level 0 is displayed. Without
      /proc/self/fd bind-mount protection it is possible to traverse parent
      directories.
      
      Fixes: 397ae982 ("virtiofsd: jail lo->proc_self_fd")
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Jens Freimann <jfreimann@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20201006095826.59813-1-stefanha@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Tested-by: default avatarJens Freimann <jfreimann@redhat.com>
      Reviewed-by: default avatarJens Freimann <jfreimann@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      ebf10195
Loading