Skip to content
Snippets Groups Projects
  1. Jul 05, 2021
    • 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
      docs: describe the security considerations with virtiofsd xattr mapping · 3399bca4
      Daniel P. Berrangé authored
      
      Different guest xattr prefixes have distinct access control rules applied
      by the guest. When remapping a guest xattr care must be taken that the
      remapping does not allow the a guest user to bypass guest kernel access
      control rules.
      
      For example if 'trusted.*' which requires CAP_SYS_ADMIN is remapped
      to 'user.virtiofs.trusted.*', an unprivileged guest user which can
      write to 'user.*' can bypass the CAP_SYS_ADMIN control. Thus the
      target of any remapping must be explicitly blocked from read/writes
      by the guest, to prevent access control bypass.
      
      The examples shown in the virtiofsd man page already do the right
      thing and ensure safety, but the security implications of getting
      this wrong were not made explicit. This could lead to host admins
      and apps unwittingly creating insecure configurations.
      
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Message-Id: <20210611120427.49736-1-berrange@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      3399bca4
    • 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
    • Laurent Vivier's avatar
      migration: failover: continue to wait card unplug on error · 944bc528
      Laurent Vivier authored
      If the user cancels the migration in the unplug-wait state,
      QEMU will try to plug back the card and this fails because the card
      is partially unplugged.
      To avoid the problem, continue to wait the card unplug, but to
      allow the migration to be canceled if the card never finishes to unplug
      use a timeout.
      
      Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1976852
      
      
      Signed-off-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20210629155007.629086-3-lvivier@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      944bc528
    • Laurent Vivier's avatar
      migration: move wait-unplug loop to its own function · fde93d99
      Laurent Vivier authored
      
      The loop is used in migration_thread() and bg_migration_thread(),
      so we can move it to its own function and call it from these both places.
      
      Moreover, in migration_thread() we have a wrong state transition from
      SETUP to ACTIVE while state could be WAIT_UNPLUG. This is correctly
      managed in bg_migration_thread() so use this code instead.
      
      Signed-off-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Message-Id: <20210629155007.629086-2-lvivier@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      fde93d99
    • Peter Xu's avatar
      migration: Allow reset of postcopy_recover_triggered when failed · b7f9afd4
      Peter Xu authored
      
      It's possible qemu_start_incoming_migration() failed at any point, when it
      happens we should reset postcopy_recover_triggered to false so that the user
      can still retry with a saner incoming port.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210629181356.217312-3-peterx@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      b7f9afd4
    • Peter Xu's avatar
      migration: Move yank outside qemu_start_incoming_migration() · cc48c587
      Peter Xu authored
      
      Starting from commit b5eea99e, qmp_migrate_recover() calls unregister
      before calling qemu_start_incoming_migration(). I believe it wanted to mitigate
      the next call to yank_register_instance(), but I think that's wrong.
      
      Firstly, if during recover, we should keep the yank instance there, not
      "quickly removing and adding it back".
      
      Meanwhile, calling qmp_migrate_recover() twice with b5eea99e will directly
      crash the dest qemu (right now it can't; but it'll start to work right after
      the next patch) because the 1st call of qmp_migrate_recover() will unregister
      permanently when the channel failed to establish, then the 2nd call of
      qmp_migrate_recover() crashes at yank_unregister_instance().
      
      This patch fixes it by moving yank ops out of qemu_start_incoming_migration()
      into qmp_migrate_incoming.  For qmp_migrate_recover(), drop the unregister of
      yank instance too since we keep it there during the recovery phase.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20210629181356.217312-2-peterx@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      cc48c587
    • Feng Lin's avatar
      migration: fix the memory overwriting risk in add_to_iovec · c00d434a
      Feng Lin authored
      
      When testing migration, a Segmentation fault qemu core is generated.
      0  error_free (err=0x1)
      1  0x00007f8b862df647 in qemu_fclose (f=f@entry=0x55e06c247640)
      2  0x00007f8b8516d59a in migrate_fd_cleanup (s=s@entry=0x55e06c0e1ef0)
      3  0x00007f8b8516d66c in migrate_fd_cleanup_bh (opaque=0x55e06c0e1ef0)
      4  0x00007f8b8626a47f in aio_bh_poll (ctx=ctx@entry=0x55e06b5a16d0)
      5  0x00007f8b8626e71f in aio_dispatch (ctx=0x55e06b5a16d0)
      6  0x00007f8b8626a33d in aio_ctx_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>)
      7  0x00007f8b866bdba4 in g_main_context_dispatch ()
      8  0x00007f8b8626cde9 in glib_pollfds_poll ()
      9  0x00007f8b8626ce62 in os_host_main_loop_wait (timeout=<optimized out>)
      10 0x00007f8b8626cffd in main_loop_wait (nonblocking=nonblocking@entry=0)
      11 0x00007f8b862ef01f in main_loop ()
      Using gdb print the struct QEMUFile f = {
        ...,
        iovcnt = 65, last_error = 21984,
        last_error_obj = 0x1, shutdown = true
      }
      Well iovcnt is overflow, because the max size of MAX_IOV_SIZE is 64.
      struct QEMUFile {
          ...;
          struct iovec iov[MAX_IOV_SIZE];
          unsigned int iovcnt;
          int last_error;
          Error *last_error_obj;
          bool shutdown;
      };
      iovcnt and last_error is overwrited by add_to_iovec().
      Right now, add_to_iovec() increase iovcnt before check the limit.
      And it seems that add_to_iovec() assumes that iovcnt will set to zero
      in qemu_fflush(). But qemu_fflush() will directly return when f->shutdown
      is true.
      
      The situation may occur when libvirtd restart during migration, after
      f->shutdown is set, before calling qemu_file_set_error() in
      qemu_file_shutdown().
      
      So the safiest way is checking the iovcnt before increasing it.
      
      Signed-off-by: default avatarFeng Lin <linfeng23@huawei.com>
      Message-Id: <20210625062138.1899-1-linfeng23@huawei.com>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
        Fix typo in 'writeable' which is actually misnamed 'writable'
      c00d434a
    • Peter Xu's avatar
      tests: migration-test: Add dirty ring test · 1f546b70
      Peter Xu authored
      
      Add dirty ring test if kernel supports it.  Add the dirty ring parameter on
      source should be mostly enough, but let's change the dest too to make them
      match always.
      
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210615175523.439830-3-peterx@redhat.com>
      Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      1f546b70
  2. Jul 04, 2021
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/philmd/tags/mips-20210702' into staging · 711c0418
      Peter Maydell authored
      
      MIPS patches queue
      
      - Extract nanoMIPS, microMIPS, Code Compaction from translate.c
      - Allow PCI config accesses smaller than 32-bit on Bonito64 device
      - Fix migration of g364fb device on Jazz Magnum
      - Fix dp8393x PROM checksum on Jazz Magnum and Quadra 800
      - Map the UART devices unconditionally on Jazz Magnum
      - Add functional test booting Linux on the Fuloong 2E
      
      # gpg: Signature made Fri 02 Jul 2021 16:36:19 BST
      # gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
      # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full]
      # Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE
      
      * remotes/philmd/tags/mips-20210702:
        hw/mips/jazz: Map the UART devices unconditionally
        hw/mips/jazz: specify correct endian for dp8393x device
        hw/m68k/q800: fix PROM checksum and MAC address storage
        qemu/bitops.h: add bitrev8 implementation
        dp8393x: remove onboard PROM containing MAC address and checksum
        hw/m68k/q800: move PROM and checksum calculation from dp8393x device to board
        hw/mips/jazz: move PROM and checksum calculation from dp8393x device to board
        dp8393x: convert to trace-events
        dp8393x: checkpatch fixes
        g364fb: add VMStateDescription for G364SysBusState
        g364fb: use RAM memory region for framebuffer
        tests/acceptance: Test Linux on the Fuloong 2E machine
        hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit
        hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit
        target/mips: Extract nanoMIPS ISA translation routines
        target/mips: Extract the microMIPS ISA translation routines
        target/mips: Extract Code Compaction ASE translation routines
        target/mips: Add declarations for generic TCG helpers
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      711c0418
  3. Jul 03, 2021
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210702' into staging · 73c8bf4c
      Peter Maydell authored
      
      target-arm queue:
       * more MVE instructions
       * hw/gpio/gpio_pwr: use shutdown function for reboot
       * target/arm: Check NaN mode before silencing NaN
       * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine
       * hw/arm: Add basic power management to raspi.
       * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc
      
      # gpg: Signature made Fri 02 Jul 2021 13:59:19 BST
      # gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
      # gpg:                issuer "peter.maydell@linaro.org"
      # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
      # gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
      # gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
      # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE
      
      * remotes/pmaydell/tags/pull-target-arm-20210702: (24 commits)
        target/arm: Implement MVE shifts by register
        target/arm: Implement MVE shifts by immediate
        target/arm: Implement MVE long shifts by register
        target/arm: Implement MVE long shifts by immediate
        target/arm: Implement MVE VADDLV
        target/arm: Implement MVE VSHLC
        target/arm: Implement MVE saturating narrowing shifts
        target/arm: Implement MVE VSHRN, VRSHRN
        target/arm: Implement MVE VSRI, VSLI
        target/arm: Implement MVE VSHLL
        target/arm: Implement MVE vector shift right by immediate insns
        target/arm: Implement MVE vector shift left by immediate insns
        target/arm: Implement MVE logical immediate insns
        target/arm: Use dup_const() instead of bitfield_replicate()
        target/arm: Use asimd_imm_const for A64 decode
        target/arm: Make asimd_imm_const() public
        target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH
        target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation
        hw/gpio/gpio_pwr: use shutdown function for reboot
        target/arm: Check NaN mode before silencing NaN
        ...
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      73c8bf4c
  4. Jul 02, 2021
Loading