IOMMU: make domctl handler tolerate NULL domain
authorJan Beulich <jbeulich@suse.com>
Tue, 7 Jun 2022 12:02:30 +0000 (14:02 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 7 Jun 2022 12:02:30 +0000 (14:02 +0200)
Besides the reporter's issue of hitting a NULL deref when !CONFIG_GDBSX,
XEN_DOMCTL_test_assign_device can legitimately end up having NULL passed
here, when the domctl was passed DOMID_INVALID.

Fixes: 71e617a6b8f6 ("use is_iommu_enabled() where appropriate...")
Reported-by: Cheyenne Wills <cheyenne.wills@gmail.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Juergen Gross <jgross@suse.com>
master commit: fa4d84e6dd3c3bfd23a525b75a5483d4ce15adbb
master date: 2022-04-26 10:25:54 +0200

xen/drivers/passthrough/iommu.c

index caaba62c88656ecce53bbfe20b88cb0256b0ed1f..287f63fc736f97f84b17ac83491a5905c6ba5912 100644 (file)
@@ -535,7 +535,7 @@ int iommu_do_domctl(
 {
     int ret = -ENODEV;
 
-    if ( !is_iommu_enabled(d) )
+    if ( !(d ? is_iommu_enabled(d) : iommu_enabled) )
         return -EOPNOTSUPP;
 
 #ifdef CONFIG_HAS_PCI