possible pciback security issue
Having looked more closely into what would be needed to enable MSI support I stumbled across a simple question: If a domU is granted access to an MSI-capable device, it could maliciously or erroneously enable MSI on that device and program an arbitrary vector to be delivered, or even force the message address and/or value to something that might make the system misbehave/crash.
It would seem to me that filtering only a few header fields is insufficient from a security point of view, not only from the perspective of MSI. While this may severely limit functionality, I think by default only read access must be granted to any fields/bits of unknown meaning (namely everything outside the header).
Jan
Quoted 7 lines · Jan Beulich
Having looked more closely into what would be needed to enable MSI support I stumbled across a simple question: If a domU is granted access to an MSI-capable device, it could maliciously or erroneously enable MSI on that device and program an arbitrary vector to be delivered, or even force the message address and/or value to something that might make the system misbehave/crash.
It would seem to me that filtering only a few header fields is insufficient from a security point of view, not only from the perspective of MSI. While this may severely limit functionality, I think by default only read access must be granted to any fields/bits of unknown meaning (namely everything outside the header).
That *is* the default.
-- Keir
Quoted 18 lines
Quoted 1 line
Quoted 1 line
Keir Fraser <[email protected]> 04.05.06 15:06 >>>
Quoted 5 lines · Jan Beulich
Having looked more closely into what would be needed to enable MSI support I stumbled across a simple question: If a
domU is granted access to an MSI-capable device, it could maliciously or erroneously enable MSI on that device and
program an arbitrary vector to be delivered, or even force the messageQuoted 8 lines
address and/or value to something that might make
the system misbehave/crash.
It would seem to me that filtering only a few header fields is insufficient from a security point of view, not only from the perspective of MSI. While this may severely limit functionality, I think by default only read access must be granted to any fields/bits of unknown meaning (namely everything outside the header).
Quoted 1 line
That *is* the default.
Oh, sorry, I missed the permissive flag.
Jan
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 13 lines
Having looked more closely into what would be needed to enable MSI support I stumbled across a simple question: If a
domU is granted access to an MSI-capable device, it could maliciously or erroneously enable MSI on that device and
program an arbitrary vector to be delivered, or even force the message address and/or value to something that might make
the system misbehave/crash.
It would seem to me that filtering only a few header fields is insufficient from a security point of view, not only
from the perspective of MSI. While this may severely limit functionality, I think by default only read access must be granted to any fields/bits of unknown meaning (namely everything outside the header).
Quoted 3 lines
Quoted 1 line
That *is* the default.
Oh, sorry, I missed the permissive flag.
Ryan's putting together a story on device-specific PCI config-space access filtering, to avoid needing to set the permissive flag for as many common devices as possible.
As for the particular example of MSI -- I think pciback will set up that field as part of device handoff when booting a driver domain. Then it should not be necessary for the driver domain to touch the MSI PCI config field at all. We should probably explicitly disable access to that field, even when permissive mode is enabled.
-- Keir
Quoted 7 lines · Keir Fraser
As for the particular example of MSI -- I think pciback will set up that field as part of device handoff when booting a driver domain. Then it should not be necessary for the driver domain to touch the MSI PCI config field at all. We should probably explicitly disable access to that field, even when permissive mode is enabled.
-- Keir
Doing something like the attached patch should be sufficient to ensure that even in permissive mode, you can't turn on MSI (note that I quickly coded this patch as an example and haven't compiled/tested it yet; I believe it should do what we want, but I'm not really in a position to give it the testing that it deserves). I don't really like having to add fields to just block the handling in permissive mode (I feel as though this is creeping towards a default permit mentality), but I understand its usefulness for letting users get their devices working immediately if they're willing to accept the risk of less isolation.
AFAICT, the rest of the MSI fields are meaningless unless the MSI enable bit is set so I believe that is all that needs to be protected.
Ryan
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_capability.c +4 -0
@@ -61,11 +61,15 @@extern struct pciback_config_capability pciback_config_capability_vpd;extern struct pciback_config_capability pciback_config_capability_pm; +extern struct pciback_config_capability pciback_config_capability_msi; +extern struct pciback_config_capability pciback_config_capability_msx;int pciback_config_capability_init (void ) {register_capability (&pciback_config_capability_vpd);register_capability (&pciback_config_capability_pm); +register_capability (&pciback_config_capability_msi); +register_capability (&pciback_config_capability_msix);return 0 ; }
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_capability_msi.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* PCI Backend - Configuration space overlay for Message Signaled Interrupts +* +* Author: Ryan Wilson <[email protected]> +*/ + +#include <linux/pci.h> +#include "conf_space.h" +#include "conf_space_capability.h" + +static struct config_field caplist_msi[] = { +/* we must protect against writes to the flags field which +* could enable MSI */ + { + .offset =PCI_MSI_FLAGS , + .size =2 , + .u.w.read = pciback_read_config_word, + }, + { + .size =0 , + }, +}; + +struct pciback_config_capability pciback_config_capability_msi = { + .capability =PCI_CAP_ID_MSI , + .fields = caplist_msi, +}; + +struct pciback_config_capability pciback_config_capability_msix = { + .capability =PCI_CAP_ID_MSIX , + .fields = caplist_msi, +};
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel