[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thunderbolt (and other PCI hotplug) isolation


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 16 Jan 2024 10:58:05 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 16 Jan 2024 09:58:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.01.2024 03:20, Marek Marczykowski-Górecki wrote:
> Hi,
> 
> A little background:
> In Qubes OS we try to isolate external (especially hot pluggable)
> devices as much as possible. For PCI devices, we do PCI passthrough to
> dedicated domains (sys-net, sys-usb - mostly the latter). The goal is to
> prevent unauthorized device to compromise the whole system, especially
> using DMA (either initiated by a malicious device itself, or by a
> compromised driver). For the discussion here, lets ignore what happens
> before Xen starts.
> 
> The matter becomes much more complicated for hot plugged devices. I did
> some test recently, enabled PCI hoplug in dom0 kernel (we have it
> disabled by default), and this is what I got:
> 1. Hot plugged devices were properly detected, and dom0 told Xen about
> them. In my case, it was two PCI bridges and an NVMe disk.
> 2. New devices were assigned to dom0 automatically.
> 3. New leaf device (the disk) can be assigned to a HVM domU and seems to work.
> 4. The bridges cannot be assigned to a domU.
> 
> Now, there are (at least) two problems with the above:
> i) The second point above: new device automatically gain ability to DMA (at
> least) into dom0 memory. I guess this should be easy-ish solvable for
> leaf devices by assigning them to a quarantine domain by default. There
> is an issue how to decide what devices to handle this way (for example,
> what about external devices present during Xen/dom0 startup already),
> but it feels like a problem solvable with some configuration. And of
> course dom0 will need to be adjusted to not talk to such devices
> automatically (via drivers blacklisting or similar approach). But for
> the bridge devices, it's more complicated, basically the second point
> below.
> 
> ii) The fourth point above: an external PCI device remains in dom0
> (including being able to dom0 into dom0's memory) just because it happen
> to have some specific bits in its config space set. When considering
> malicious device, it doesn't even need to function as a bridge - it's
> just enough to present itself as a bridge, wait for dom0's thunderbolt
> driver to authorize the device so it gets assigned dom0's IOMMU context,
> and boom. On the other hand, a bridge has privileged function by
> design, for example IIUC takes part in discovering devices behind it
> (which then needs to be properly registered in Xen, assigned IOMMU
> context etc).

I may not be following the underlying concept here: If you consider a
device potentially malicious, why would you even connect it to your
system? And if you mean Dom0 to not drive devices, why would you even
build the respective drivers for such a Dom0 kernel?

> iii) Untested, but it feels like there is a lot of room for various race
> conditions in the hot plug handling. For example, device must be
> allowed any DMA only after its IOMMU context is properly configured.

Isn't that the case already? Any attempt to DMA without respective
device / context table entry (AMD / Intel terminology) ought to result
in IOMMU faults.

Jan

> I
> believe thunderbolt technically allows that (plain PCIe hotplug most
> likely not), but my guess is it's not the case currently.
> 
> My question is mostly: what can be done about the "ii" problem above?
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.