Set suppress_bind_attrs on the virtio-iommu driver to prevent userspace
from triggering driver unbind via sysfs.

Unbinding the IOMMU driver from beneath live endpoint devices would
leave those devices with dangling domain pointers. This would not be a
recoverable operation.

Note that suppress_bind_attrs covers only the driver bind/unbind path,
not PCI-level device removal triggered via the sysfs remove file.

Fixes: edcd69ab9a32 ("iommu: Add virtio-iommu driver")
Signed-off-by: Cam Miller <[email protected]>
---
 drivers/iommu/virtio-iommu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index a08474eeed58..dd10c3e98a3d 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -1285,7 +1285,10 @@ static struct virtio_device_id id_table[] = {
 MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_iommu_drv = {
-       .driver.name            = KBUILD_MODNAME,
+       .driver         = {
+               .name           = KBUILD_MODNAME,
+               .suppress_bind_attrs     = true,
+       },
        .id_table               = id_table,
        .feature_table          = features,
        .feature_table_size     = ARRAY_SIZE(features),
-- 
2.54.0


Reply via email to