1. 17 5月, 2017 8 次提交
    • E
      fdc: Remove user_creatable flag from sysbus-fdc & SUNW,fdtwo · 8ca97a1f
      Eduardo Habkost 提交于
      sysbus-fdc and SUNW,fdtwo devices need IRQs to be wired and mmio
      to be mapped, and can't be used with -device. Unset
      user_creatable on their device classes.
      
      Cc: John Snow <jsnow@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Cc: Thomas Huth <thuth@redhat.com>
      Acked-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-6-ehabkost@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      8ca97a1f
    • E
      iommu: Remove FIXME comment about user_creatable=true · 8ab5700c
      Eduardo Habkost 提交于
      amd-iommu and intel-iommu are really meant to be used with
      -device, so they need user_creatable=true. Remove the FIXME
      comment.
      
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-5-ehabkost@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      8ab5700c
    • E
      xen-backend: Remove FIXME comment about user_creatable flag · 950b31dd
      Eduardo Habkost 提交于
      xen-backend can be plugged/unplugged dynamically when using the
      Xen accelerator, so keep the user_creatable flag on the device
      class and remove the FIXME comment.
      
      Cc: Juergen Gross <jgross@suse.com>,
      Cc: Peter Maydell <peter.maydell@linaro.org>,
      Cc: Thomas Huth <thuth@redhat.com>
      Cc: sstabellini@kernel.org
      Cc: Markus Armbruster <armbru@redhat.com>,
      Cc: Marcel Apfelbaum <marcel@redhat.com>,
      Cc: Laszlo Ersek <lersek@redhat.com>
      Acked-by: NJuergen Gross <jgross@suse.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-4-ehabkost@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      950b31dd
    • E
      sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE · e4f4fb1e
      Eduardo Habkost 提交于
      commit 33cd52b5 unset
      cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making all
      sysbus devices appear on "-device help" and lack the "no-user"
      flag in "info qdm".
      
      To fix this, we can set user_creatable=false by default on
      TYPE_SYS_BUS_DEVICE, but this requires setting
      user_creatable=true explicitly on the sysbus devices that
      actually work with -device.
      
      Fortunately today we have just a few has_dynamic_sysbus=1
      machines: virt, pc-q35-*, ppce500, and spapr.
      
      virt, ppce500, and spapr have extra checks to ensure just a few
      device types can be instantiated:
      
      * virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE.
      * ppce500 supports only TYPE_ETSEC_COMMON.
      * spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE.
      
      This patch sets user_creatable=true explicitly on those 4 device
      classes.
      
      Now, the more complex cases:
      
      pc-q35-*: q35 has no sysbus device whitelist yet (which is a
      separate bug). We are in the process of fixing it and building a
      sysbus whitelist on q35, but in the meantime we can fix the
      "-device help" and "info qdm" bugs mentioned above. Also, despite
      not being strictly necessary for fixing the q35 bug, reducing the
      list of user_creatable=true devices will help us be more
      confident when building the q35 whitelist.
      
      xen: We also have a hack at xen_set_dynamic_sysbus(), that sets
      has_dynamic_sysbus=true at runtime when using the Xen
      accelerator. This hack is only used to allow xen-backend devices
      to be dynamically plugged/unplugged.
      
      This means today we can use -device with the following 22 device
      types, that are the ones compiled into the qemu-system-x86_64 and
      qemu-system-i386 binaries:
      
      * allwinner-ahci
      * amd-iommu
      * cfi.pflash01
      * esp
      * fw_cfg_io
      * fw_cfg_mem
      * generic-sdhci
      * hpet
      * intel-iommu
      * ioapic
      * isabus-bridge
      * kvmclock
      * kvm-ioapic
      * kvmvapic
      * SUNW,fdtwo
      * sysbus-ahci
      * sysbus-fdc
      * sysbus-ohci
      * unimplemented-device
      * virtio-mmio
      * xen-backend
      * xen-sysdev
      
      This patch adds user_creatable=true explicitly to those devices,
      temporarily, just to keep 100% compatibility with existing
      behavior of q35. Subsequent patches will remove
      user_creatable=true from the devices that are really not meant to
      user-creatable on any machine, and remove the FIXME comment from
      the ones that are really supposed to be user-creatable. This is
      being done in separate patches because we still don't have an
      obvious list of devices that will be whitelisted by q35, and I
      would like to get each device reviewed individually.
      
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Beniamino Galvani <b.galvani@gmail.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Frank Blaschka <frank.blaschka@de.ibm.com>
      Cc: Gabriel L. Somlo <somlo@cmu.edu>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: John Snow <jsnow@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Pierre Morel <pmorel@linux.vnet.ibm.com>
      Cc: Prasad J Pandit <pjp@fedoraproject.org>
      Cc: qemu-arm@nongnu.org
      Cc: qemu-block@nongnu.org
      Cc: qemu-ppc@nongnu.org
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Shannon Zhao <zhaoshenglong@huawei.com>
      Cc: sstabellini@kernel.org
      Cc: Thomas Huth <thuth@redhat.com>
      Cc: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
      Acked-by: NJohn Snow <jsnow@redhat.com>
      Acked-by: NJuergen Gross <jgross@suse.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-3-ehabkost@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [ehabkost: Small changes at sysbus_device_class_init() comments]
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      e4f4fb1e
    • E
      qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable · e90f2a8c
      Eduardo Habkost 提交于
      cannot_instantiate_with_device_add_yet was introduced by commit
      efec3dd6 to replace no_user. It was
      supposed to be a temporary measure.
      
      When it was introduced, we had 54
      cannot_instantiate_with_device_add_yet=true lines in the code.
      Today (3 years later) this number has not shrunk: we now have
      57 cannot_instantiate_with_device_add_yet=true lines. I think it
      is safe to say it is not a temporary measure, and we won't see
      the flag go away soon.
      
      Instead of a long field name that misleads people to believe it
      is temporary, replace it a shorter and less misleading field:
      user_creatable.
      
      Except for code comments, changes were generated using the
      following Coccinelle patch:
      
        @@
        expression DC;
        @@
        (
        -DC->cannot_instantiate_with_device_add_yet = false;
        +DC->user_creatable = true;
        |
        -DC->cannot_instantiate_with_device_add_yet = true;
        +DC->user_creatable = false;
        )
      
        @@
        typedef ObjectClass;
        expression dc;
        identifier class, data;
        @@
         static void device_class_init(ObjectClass *class, void *data)
         {
         ...
         dc->hotpluggable = true;
        +dc->user_creatable = true;
         ...
         }
      
        @@
        @@
         struct DeviceClass {
         ...
        -bool cannot_instantiate_with_device_add_yet;
        +bool user_creatable;
         ...
        }
      
        @@
        expression DC;
        @@
        (
        -!DC->cannot_instantiate_with_device_add_yet
        +DC->user_creatable
        |
        -DC->cannot_instantiate_with_device_add_yet
        +!DC->user_creatable
        )
      
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Thomas Huth <thuth@redhat.com>
      Acked-by: NAlistair Francis <alistair.francis@xilinx.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-2-ehabkost@redhat.com>
      [ehabkost: kept "TODO remove once we're there" comment]
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      e90f2a8c
    • S
      xen: call qemu_set_cloexec instead of fcntl · 01cd90b6
      Stefano Stabellini 提交于
      Use the common utility function, which contains checks on return values
      and first calls F_GETFD as recommended by POSIX.1-2001, instead of
      manually calling fcntl.
      
      CID: 1374831
      Signed-off-by: NStefano Stabellini <sstabellini@kernel.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      CC: anthony.perard@citrix.com
      CC: groug@kaod.org
      CC: aneesh.kumar@linux.vnet.ibm.com
      CC: Eric Blake <eblake@redhat.com>
      01cd90b6
    • S
      xen/9pfs: fix two resource leaks on error paths, discovered by Coverity · c0c24b95
      Stefano Stabellini 提交于
      CID: 1374836
      Signed-off-by: NStefano Stabellini <sstabellini@kernel.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      CC: anthony.perard@citrix.com
      CC: groug@kaod.org
      CC: aneesh.kumar@linux.vnet.ibm.com
      c0c24b95
    • S
      xen/mapcache: store dma information in revmapcache entries for debugging · 1ff7c598
      Stefano Stabellini 提交于
      The Xen mapcache is able to create long term mappings, they are called
      "locked" mappings. The third parameter of the xen_map_cache call
      specifies if a mapping is a "locked" mapping.
      
      >From the QEMU point of view there are two kinds of long term mappings:
      
      [a] device memory mappings, such as option roms and video memory
      [b] dma mappings, created by dma_memory_map & friends
      
      After certain operations, ballooning a VM in particular, Xen asks QEMU
      kindly to destroy all mappings. However, certainly [a] mappings are
      present and cannot be removed. That's not a problem as they are not
      affected by balloonning. The *real* problem is that if there are any
      mappings of type [b], any outstanding dma operations could fail. This is
      a known shortcoming. In other words, when Xen asks QEMU to destroy all
      mappings, it is an error if any [b] mappings exist.
      
      However today we have no way of distinguishing [a] from [b]. Because of
      that, we cannot even print a decent warning.
      
      This patch introduces a new "dma" bool field to MapCacheRev entires, to
      remember if a given mapping is for dma or is a long term device memory
      mapping. When xen_invalidate_map_cache is called, we print a warning if
      any [b] mappings exist. We ignore [a] mappings.
      
      Mappings created by qemu_map_ram_ptr are assumed to be [a], while
      mappings created by address_space_map->qemu_ram_ptr_length are assumed
      to be [b].
      
      The goal of the patch is to make debugging and system understanding
      easier.
      Signed-off-by: NStefano Stabellini <sstabellini@kernel.org>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Acked-by: NAnthony PERARD <anthony.perard@citrix.com>
      1ff7c598
  2. 15 5月, 2017 1 次提交
    • G
      9pfs: local: forbid client access to metadata (CVE-2017-7493) · 7a95434e
      Greg Kurz 提交于
      When using the mapped-file security mode, we shouldn't let the client mess
      with the metadata. The current code already tries to hide the metadata dir
      from the client by skipping it in local_readdir(). But the client can still
      access or modify it through several other operations. This can be used to
      escalate privileges in the guest.
      
      Affected backend operations are:
      - local_mknod()
      - local_mkdir()
      - local_open2()
      - local_symlink()
      - local_link()
      - local_unlinkat()
      - local_renameat()
      - local_rename()
      - local_name_to_path()
      
      Other operations are safe because they are only passed a fid path, which
      is computed internally in local_name_to_path().
      
      This patch converts all the functions listed above to fail and return
      EINVAL when being passed the name of the metadata dir. This may look
      like a poor choice for errno, but there's no such thing as an illegal
      path name on Linux and I could not think of anything better.
      
      This fixes CVE-2017-7493.
      Reported-by: NLeo Gaspard <leo@gaspard.io>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      7a95434e
  3. 12 5月, 2017 21 次提交
  4. 11 5月, 2017 10 次提交