Skip to contentSkip to conversation

Xen/gntdev: don't ignore kernel unmapping error

PATCH Applied Jan Beulich 2 participants 3 messages Sep 17, 2021 – Sep 20, 2021 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Xen/gntdev: don't ignore kernel unmapping error

While working on XSA-361 and its follow-ups, I failed to spot another place where the kernel mapping part of an operation was not treated the same as the user space part. Detect and propagate errors and add a 2nd pr_debug().

---
It is of course questionable whether zapping handles even upon failure is the best course of action. Otoh unmapping shouldn't normally fail unless there's a bug elsewhere (which is how I came to notice this discrepancy).

drivers/xen/gntdev.c +8 -0
@@ -396,6 +396,14 @@ static int __unmap_grant_pages(struct gn
 			map->unmap_ops[offset+i].handle,
 			map->unmap_ops[offset+i].status);
 		map->unmap_ops[offset+i].handle = INVALID_GRANT_HANDLE;
+		if (use_ptemod) {
+			if (map->kunmap_ops[offset+i].status)
+				err = -EINVAL;
+			pr_debug("kunmap handle=%u st=%d\n",
+				 map->kunmap_ops[offset+i].handle,
+				 map->kunmap_ops[offset+i].status);
+			map->kunmap_ops[offset+i].handle = INVALID_GRANT_HANDLE;
+		}
 	}
 	return err;
 }
maintainer Applied
#2 lore raw
In reply to Jan Beulich
Quoted 6 lines · Jan Beulich

While working on XSA-361 and its follow-ups, I failed to spot another place where the kernel mapping part of an operation was not treated the same as the user space part. Detect and propagate errors and add a 2nd pr_debug().

Pushed to xen/tip.git for-linus-5.15b

Juergen