|
|
Subscribe / Log in / New account

The Thunderclap vulnerabilities

The Thunderclap vulnerabilities

Posted Mar 12, 2019 11:02 UTC (Tue) by westeri (subscriber, #62678)
In reply to: The Thunderclap vulnerabilities by rweikusat2
Parent article: The Thunderclap vulnerabilities

There is now a patch series from Lu Baolu aiming to fix the remaining issues here:

https://lore.kernel.org/lkml/20190312060005.12189-1-baolu...


to post comments

The Thunderclap vulnerabilities

Posted Mar 12, 2019 14:25 UTC (Tue) by rweikusat2 (subscriber, #117920) [Link] (7 responses)

"Copy the data into a dedicated page" is an ugly workaround for the issue.

The Thunderclap vulnerabilities

Posted Mar 12, 2019 16:16 UTC (Tue) by westeri (subscriber, #62678) [Link] (6 responses)

Feel free to propose a better one that does not involve fixing all the possible PCI drivers using DMA ;-)

The Thunderclap vulnerabilities

Posted Mar 12, 2019 19:48 UTC (Tue) by rweikusat2 (subscriber, #117920) [Link] (4 responses)

"Don't buy devices from the people who wrote the paper"?

Assuming that memory protection/ accesss control with page granularity is available, DMA buffers used by untrusted devices (and this should really be all kinds of devices) must not share memory pages with code whose information said untrusted devices are not supposed to access if the access control is supposed to be used effectively. This means *if* such a facility is to be used in a sensible way, DMA buffer allocation must be per-device and separate from all other allocations, including other DMA buffer allocation.

There are obviously tradeoffs here as most real-world devices won't be untrusted but singling out a certain kind of devices and adding an additional DMA buffer allocation system working on top of the existing DMA buffer allocation systems is a technically seriously unpleasant workaround for a highly unlikely fringe case.

The Thunderclap vulnerabilities

Posted Mar 12, 2019 21:01 UTC (Tue) by westeri (subscriber, #62678) [Link] (3 responses)

The problem here is that you can essentially plug in any PCIe device to a Thunderbolt enclosure (as they come with one or multiple PCIe slots). This means that you would need to fix each and every PCI driver to make sure they only do DMA to/from buffers that fill the whole page (the minimum IOMMU window size). Doing it in the IOMMU driver allows us to prevent the DMA attack now without need to modify all the PCI drivers. Since it only bounces buffers not filling the whole page so when a driver gets "fixed" it won't bounce anymore and eventually we can turn the bouncing off completely.

The Thunderclap vulnerabilities

Posted Mar 12, 2019 21:50 UTC (Tue) by rweikusat2 (subscriber, #117920) [Link] (2 responses)

> The problem here is that you can essentially plug in any PCIe device to a Thunderbolt enclosure (as they come with one or multiple > PCIe slots). This means that you would need to fix each and every PCI driver

Yes. I thought I already wrote this ("this should really be all kinds of devices"): If this issue is supposed to be mitigated by the IOMMU, any driver which supports DMA would need to use its own DMA buffer backing pages cache. There's no need for individual buffers to span a complete page (or some number of complete pages) provided management information used by a driver isn't kept in the unused parts of some page a part of which is currently used as DMA buffer, at least not in a way where corruption could go unnoticed. Malicious device snooping on itself sounds pretty harmless to me ;-).

Assuming that fixing this is considered desirable (the underlying issue has existed forever --- there's no reason why hardware designed by an unknown entity ought to be trustworthy, especially not if this 'hardware' is in itself complicated enough to contain a general purpose CPU running some decidedly non-trivial software), this cries out for some sort of infrastructure support for DMA buffer allocation drivers could easily make use of.

NB: I understand the benefits of the existing approach. But that's still just life-patching of a more fundamentally deficient (in this respect) memory management model.

The Thunderclap vulnerabilities

Posted Mar 13, 2019 15:21 UTC (Wed) by nybble41 (subscriber, #55106) [Link] (1 responses)

> any driver which supports DMA would need to use its own DMA buffer backing pages cache

The page cache would need to be separate for each *device*, not each driver. A device snooping on itself may be harmless, but the same is not necessarily true for snooping on other devices managed by the same driver. Besides the fact that one driver might manage multiple brands and models of devices, some more trustworthy than others, one can also envision e.g. a system with two identical NICs surreptitiously snooping on each other and transmitting internal network data over the external network.

The Thunderclap vulnerabilities

Posted Mar 13, 2019 19:17 UTC (Wed) by rweikusat2 (subscriber, #117920) [Link]

>> any driver which supports DMA would need to use its own DMA buffer backing pages cache
> The page cache would need to be separate for each *device*, not each driver.

A driver capable of managing more than one device would obviously need one cache per currently managed device. Do you think somebody wouldn't immediately recognize this if such a driver was under discussion?

The Thunderclap vulnerabilities

Posted Mar 19, 2019 13:31 UTC (Tue) by nix (subscriber, #2304) [Link]

It feels to me like a pooled allocator is what you want: each DMA-capable device gets a separate pool, and memory the allocator gives back to a given pool uses pages distinct from that used by all other pools; memory is zeroed before being placed in the pool. That way, a hostile device can only spy on memory it itself has populated (assuming that page-level protection still functions properly: so even this still needs a working IOMMU).


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds