linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: grant-table: Check truncation when giving access to a frame
@ 2016-06-13 10:50 Julien Grall
  2016-06-13 10:57 ` [Xen-devel] " David Vrabel
  2016-06-13 12:12 ` Paul Durrant
  0 siblings, 2 replies; 10+ messages in thread
From: Julien Grall @ 2016-06-13 10:50 UTC (permalink / raw)
  To: boris.ostrovsky, david.vrabel, jgross, sstabellini, konrad.wilk
  Cc: steve.capper, linux-kernel, xen-devel, andrew.cooper3, JBeulich,
	Julien Grall

The version 1 of the grant-table protocol only supports frame encoded on
32-bit.

When the platform is supporting 48-bit physical address, the frame will
be encoded on 36-bit which will lead a truncation and give access to
the wrong frame.

On ARM Xen will always allow the guest to use all the physical address,
although today the RAM is always located under 40-bits (see
xen/include/public/arch-arm.h).

Add a truncation check in gnttab_update_entry_v1 to prevent the guest to
give access to the wrong frame.

Signed-off-by: Julien Grall <julien.grall@arm.com>

---
    This is limiting us to a 44-bit address space whilst ARM can support
    up to 48-bit today. This number of bit will increase to 52-bit in
    upcoming processors [1].

    It might be good to start thinking to extend the version 1 of the
    protocol to use 64-bit frame number.

    [1] https://community.arm.com/groups/processors/blog/2016/01/05/armv8-a-architecture-evolution
---
 drivers/xen/grant-table.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index bb36b1e..f47c2e99 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -224,6 +224,13 @@ static void gnttab_update_entry_v1(grant_ref_t ref, domid_t domid,
 {
 	gnttab_shared.v1[ref].domid = domid;
 	gnttab_shared.v1[ref].frame = frame;
+
+	/*
+	 * V1 only supports 32-bit frame, check the truncation
+	 * to avoid giving access to the wrong frame.
+	 */
+	BUG_ON(gnttab_shared.v1[ref].frame != frame);
+
 	wmb();
 	gnttab_shared.v1[ref].flags = flags;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-06-13 13:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-13 10:50 [PATCH] xen: grant-table: Check truncation when giving access to a frame Julien Grall
2016-06-13 10:57 ` [Xen-devel] " David Vrabel
2016-06-13 11:10   ` Julien Grall
2016-06-13 12:20     ` Paul Durrant
2016-06-13 12:12 ` Paul Durrant
2016-06-13 12:41   ` Julien Grall
2016-06-13 12:42     ` Julien Grall
2016-06-13 12:45       ` Paul Durrant
2016-06-13 13:05         ` Julien Grall
2016-06-13 13:14           ` Paul Durrant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).