All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Jike Song <jike.song@intel.com>, Robin Murphy <robin.murphy@arm.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	linuxppc-dev@lists.ozlabs.org,
	David Gibson <david@gibson.dropbear.id.au>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
	Yongji Xie <elohimes@gmail.com>,
	Eric Auger <eric.auger@redhat.com>,
	Kyle Mahlkuch <Kyle.Mahlkuch@ibm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Joerg Roedel <joro@8bytes.org>,
	Arvind Yadav <arvind.yadav.cs@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Kirti Wankhede <kwankhede@nvidia.com>,
	Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>,
	Neo Jia <cjia@nvidia.com>, Paul Mackerras <paulus@samba.org>,
	Vlad Tsyrklevich <vlad@tsyrklevich.net>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v5 0/5] vfio-pci: Add support for mmapping MSI-X table
Date: Tue, 15 Aug 2017 01:33:40 +0000	[thread overview]
Message-ID: <1502760820.4493.40.camel@kernel.crashing.org> (raw)
In-Reply-To: <59924B85.5040405@intel.com>

On Tue, 2017-08-15 at 09:16 +0800, Jike Song wrote:
> > Taking a step back, though, why does vfio-pci perform this check in the
> > first place? If a malicious guest already has control of a device, any
> > kind of interrupt spoofing it could do by fiddling with the MSI-X
> > message address/data it could simply do with a DMA write anyway, so the
> > security argument doesn't stand up in general (sure, not all PCIe
> > devices may be capable of arbitrary DMA, but that seems like more of a
> > tenuous security-by-obscurity angle to me).

I tried to make that point for years, thanks for re-iterating it :-)

> Hi Robin,
> 
> DMA writes will be translated (thereby censored) by DMA Remapping hardware,
> while MSI/MSI-X will not. Is this different for non-x86?

There is no way your DMA remapping HW can differenciate. The only
difference between a DMA write and an MSI is ... the address. So if I
can make my device DMA to the MSI address range, I've defeated your
security.

The table obfuscating in qemu is only useful as an insecure way of
"making things sort-of-work" for HW that doesnt have proper remapping
or filtering.

On pseries we don't have that problem because:

 1) Our hypervisor (which is qemu) provide the DMA address for MSIs/X
so there is no need for "magic remapping" to give the guest a value
that works.

 2) Our HW (configured by VFIO/KVM) filters which device can DMA to
what address (including which MSIs/X) thus even if the guest doesn't
use the address passed and messes around, it can only shoot itself in
the foot.

So all we need is a way to tell qemu to stop doing that filtering on
our platform. This is *one bit* of information, it's taken 3 years of
arguments and we still don't have a solution. In the meantime,
workloads *are* being hurt by significant performance degradation due
to the MSI-X table sharing a 64K page (our page size) with other MMIOs.

Yay !

Ben.


WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
To: Jike Song <jike.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Cc: Vlad Tsyrklevich <vlad-NIZqynvkaCU43zv7NVfAiQ@public.gmane.org>,
	kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Alexey Kardashevskiy
	<aik-sLpHqDYs0B2HXe+LvDLADg@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Kyle Mahlkuch <Kyle.Mahlkuch-qyM6JfAXOaQ@public.gmane.org>,
	Kirti Wankhede
	<kwankhede-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Yongji Xie <elohimes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mauricio Faria de Oliveira
	<mauricfo-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	Paul Mackerras <paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>,
	Bjorn Helgaas <bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Arvind Yadav
	<arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	David Gibson
	<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
Subject: Re: [RFC PATCH v5 0/5] vfio-pci: Add support for mmapping MSI-X table
Date: Tue, 15 Aug 2017 11:33:40 +1000	[thread overview]
Message-ID: <1502760820.4493.40.camel@kernel.crashing.org> (raw)
In-Reply-To: <59924B85.5040405-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

On Tue, 2017-08-15 at 09:16 +0800, Jike Song wrote:
> > Taking a step back, though, why does vfio-pci perform this check in the
> > first place? If a malicious guest already has control of a device, any
> > kind of interrupt spoofing it could do by fiddling with the MSI-X
> > message address/data it could simply do with a DMA write anyway, so the
> > security argument doesn't stand up in general (sure, not all PCIe
> > devices may be capable of arbitrary DMA, but that seems like more of a
> > tenuous security-by-obscurity angle to me).

I tried to make that point for years, thanks for re-iterating it :-)

> Hi Robin,
> 
> DMA writes will be translated (thereby censored) by DMA Remapping hardware,
> while MSI/MSI-X will not. Is this different for non-x86?

There is no way your DMA remapping HW can differenciate. The only
difference between a DMA write and an MSI is ... the address. So if I
can make my device DMA to the MSI address range, I've defeated your
security.

The table obfuscating in qemu is only useful as an insecure way of
"making things sort-of-work" for HW that doesnt have proper remapping
or filtering.

On pseries we don't have that problem because:

 1) Our hypervisor (which is qemu) provide the DMA address for MSIs/X
so there is no need for "magic remapping" to give the guest a value
that works.

 2) Our HW (configured by VFIO/KVM) filters which device can DMA to
what address (including which MSIs/X) thus even if the guest doesn't
use the address passed and messes around, it can only shoot itself in
the foot.

So all we need is a way to tell qemu to stop doing that filtering on
our platform. This is *one bit* of information, it's taken 3 years of
arguments and we still don't have a solution. In the meantime,
workloads *are* being hurt by significant performance degradation due
to the MSI-X table sharing a 64K page (our page size) with other MMIOs.

Yay !

Ben.

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Jike Song <jike.song@intel.com>, Robin Murphy <robin.murphy@arm.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	linuxppc-dev@lists.ozlabs.org,
	David Gibson <david@gibson.dropbear.id.au>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
	Yongji Xie <elohimes@gmail.com>,
	Eric Auger <eric.auger@redhat.com>,
	Kyle Mahlkuch <Kyle.Mahlkuch@ibm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Joerg Roedel <joro@8bytes.org>,
	Arvind Yadav <arvind.yadav.cs@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Kirti Wankhede <kwankhede@nvidia.com>,
	Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>,
	Neo Jia <cjia@nvidia.com>, Paul Mackerras <paulus@samba.org>,
	Vlad Tsyrklevich <vlad@tsyrklevich.net>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v5 0/5] vfio-pci: Add support for mmapping MSI-X table
Date: Tue, 15 Aug 2017 11:33:40 +1000	[thread overview]
Message-ID: <1502760820.4493.40.camel@kernel.crashing.org> (raw)
In-Reply-To: <59924B85.5040405@intel.com>

On Tue, 2017-08-15 at 09:16 +0800, Jike Song wrote:
> > Taking a step back, though, why does vfio-pci perform this check in the
> > first place? If a malicious guest already has control of a device, any
> > kind of interrupt spoofing it could do by fiddling with the MSI-X
> > message address/data it could simply do with a DMA write anyway, so the
> > security argument doesn't stand up in general (sure, not all PCIe
> > devices may be capable of arbitrary DMA, but that seems like more of a
> > tenuous security-by-obscurity angle to me).

I tried to make that point for years, thanks for re-iterating it :-)

> Hi Robin,
> 
> DMA writes will be translated (thereby censored) by DMA Remapping hardware,
> while MSI/MSI-X will not. Is this different for non-x86?

There is no way your DMA remapping HW can differenciate. The only
difference between a DMA write and an MSI is ... the address. So if I
can make my device DMA to the MSI address range, I've defeated your
security.

The table obfuscating in qemu is only useful as an insecure way of
"making things sort-of-work" for HW that doesnt have proper remapping
or filtering.

On pseries we don't have that problem because:

 1) Our hypervisor (which is qemu) provide the DMA address for MSIs/X
so there is no need for "magic remapping" to give the guest a value
that works.

 2) Our HW (configured by VFIO/KVM) filters which device can DMA to
what address (including which MSIs/X) thus even if the guest doesn't
use the address passed and messes around, it can only shoot itself in
the foot.

So all we need is a way to tell qemu to stop doing that filtering on
our platform. This is *one bit* of information, it's taken 3 years of
arguments and we still don't have a solution. In the meantime,
workloads *are* being hurt by significant performance degradation due
to the MSI-X table sharing a 64K page (our page size) with other MMIOs.

Yay !

Ben.

  reply	other threads:[~2017-08-15  1:33 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07  7:25 [RFC PATCH v5 0/5] vfio-pci: Add support for mmapping MSI-X table Alexey Kardashevskiy
2017-08-07  7:25 ` Alexey Kardashevskiy
2017-08-07  7:25 ` Alexey Kardashevskiy
2017-08-07  7:25 ` Alexey Kardashevskiy
2017-08-07  7:25 ` [RFC PATCH v5 1/5] iommu: Add capabilities to a group Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-09  5:55   ` David Gibson
2017-08-09  5:55     ` David Gibson
2017-08-09  5:55     ` David Gibson
2017-08-07  7:25 ` [RFC PATCH v5 2/5] iommu: Set IOMMU_GROUP_CAP_ISOLATE_MSIX if MSI controller enables IRQ remapping Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25 ` [RFC PATCH v5 3/5] iommu/intel/amd: Set IOMMU_GROUP_CAP_ISOLATE_MSIX if IRQ remapping is enabled Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25 ` [RFC PATCH v5 4/5] powerpc/iommu: Set IOMMU_GROUP_CAP_ISOLATE_MSIX Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25 ` [RFC PATCH v5 5/5] vfio-pci: Allow to expose MSI-X table to userspace when safe Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-07  7:25   ` Alexey Kardashevskiy
2017-08-09  6:59   ` David Gibson
2017-08-09  6:59     ` David Gibson
2017-08-09  6:59     ` David Gibson
2017-08-14  9:45 ` [RFC PATCH v5 0/5] vfio-pci: Add support for mmapping MSI-X table Alexey Kardashevskiy
2017-08-14  9:45   ` Alexey Kardashevskiy
2017-08-14  9:45   ` Alexey Kardashevskiy
2017-08-14 13:12   ` Robin Murphy
2017-08-14 13:12     ` Robin Murphy
2017-08-15  1:16     ` Jike Song
2017-08-15  1:16       ` Jike Song
2017-08-15  1:16       ` Jike Song
2017-08-15  1:33       ` Benjamin Herrenschmidt [this message]
2017-08-15  1:33         ` Benjamin Herrenschmidt
2017-08-15  1:33         ` Benjamin Herrenschmidt
2017-08-15  1:47         ` Jike Song
2017-08-15  1:47           ` Jike Song
2017-08-15  1:47           ` Jike Song
2017-08-15  5:38           ` Benjamin Herrenschmidt
2017-08-15  5:38             ` Benjamin Herrenschmidt
2017-08-15  5:38             ` Benjamin Herrenschmidt
2017-08-15 14:48         ` David Laight
2017-08-15 14:48           ` David Laight
2017-08-15 14:48           ` David Laight
2017-08-15 14:48           ` David Laight
2017-08-15 14:48           ` David Laight
2017-08-15  5:42     ` Benjamin Herrenschmidt
2017-08-15  5:42       ` Benjamin Herrenschmidt
2017-08-15  5:42       ` Benjamin Herrenschmidt
2017-08-15 16:37     ` Alex Williamson
2017-08-15 16:37       ` Alex Williamson
2017-08-15 16:37       ` Alex Williamson
2017-08-16  0:35       ` Benjamin Herrenschmidt
2017-08-16  0:35         ` Benjamin Herrenschmidt
2017-08-16  0:35         ` Benjamin Herrenschmidt
2017-08-16 16:56         ` Alex Williamson
2017-08-16 16:56           ` Alex Williamson
2017-08-16 16:56           ` Alex Williamson
2017-08-17  4:43           ` Benjamin Herrenschmidt
2017-08-17  4:43             ` Benjamin Herrenschmidt
2017-08-17  4:43             ` Benjamin Herrenschmidt
2017-08-17 10:56           ` David Laight
2017-08-17 10:56             ` David Laight
2017-08-17 10:56             ` David Laight
2017-08-17 19:25             ` Alex Williamson
2017-08-17 19:25               ` Alex Williamson
2017-08-17 19:25               ` Alex Williamson
2017-08-21  2:47   ` Alexey Kardashevskiy
2017-08-21  2:47     ` Alexey Kardashevskiy
2017-08-21  2:47     ` Alexey Kardashevskiy
2017-08-29  2:58     ` Alexey Kardashevskiy
2017-08-29  2:58       ` Alexey Kardashevskiy
2017-08-29  2:58       ` Alexey Kardashevskiy
2017-09-11  3:27       ` Alexey Kardashevskiy
2017-09-11  3:27         ` Alexey Kardashevskiy
2017-09-11  3:27         ` Alexey Kardashevskiy

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=1502760820.4493.40.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=Kyle.Mahlkuch@ibm.com \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=cjia@nvidia.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=dwmw2@infradead.org \
    --cc=elohimes@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jike.song@intel.com \
    --cc=joro@8bytes.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mauricfo@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=robin.murphy@arm.com \
    --cc=vlad@tsyrklevich.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.