Skip to content

Commit 6b51fd3

Browse files
committed
xen/xenbus: ensure xenbus_map_ring_valloc() returns proper grant status
xenbus_map_ring_valloc() maps a ring page and returns the status of the used grant (0 meaning success). There are Xen hypervisors which might return the value 1 for the status of a failed grant mapping due to a bug. Some callers of xenbus_map_ring_valloc() test for errors by testing the returned status to be less than zero, resulting in no error detected and crashing later due to a not available ring page. Set the return value of xenbus_map_ring_valloc() to GNTST_general_error in case the grant status reported by Xen is greater than zero. This is part of XSA-316. Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Wei Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent d6f34f4 commit 6b51fd3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/xen/xenbus/xenbus_client.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,14 @@ EXPORT_SYMBOL_GPL(xenbus_free_evtchn);
448448
int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_refs,
449449
unsigned int nr_grefs, void **vaddr)
450450
{
451-
return ring_ops->map(dev, gnt_refs, nr_grefs, vaddr);
451+
int err;
452+
453+
err = ring_ops->map(dev, gnt_refs, nr_grefs, vaddr);
454+
/* Some hypervisors are buggy and can return 1. */
455+
if (err > 0)
456+
err = GNTST_general_error;
457+
458+
return err;
452459
}
453460
EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
454461

0 commit comments

Comments
 (0)