Skip to contentSkip to conversation

xen/public: Correct the definition of GNTTAB_CACHE_SOURCE_GREF

PATCH In review Andrew Cooper 4 participants 4 messages Oct 17, 2017 – Oct 19, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/public: Correct the definition of GNTTAB_CACHE_SOURCE_GREF

Discovered when running the XSA-232 PoC on a UBSAN-enabled hypervisor.

(d79) XSA-232 PoC
(XEN) ================================================================================ (XEN) UBSAN: Undefined behaviour in grant_table.c:3217:25
(XEN) left shift of 1 by 31 places cannot be represented in type 'int'
(XEN) ----[ Xen-4.10.0-rc x86_64 debug=y Tainted: H ]----

Update all of the GNTTAB_CACHE_* constants to be unsigned integers.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

This is a trivial bugfix, and is low risk for 4.10

---
 xen/include/public/grant_table.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/public/grant_table.h +3 -3
index 018036e..180d62c 100644
@@ -589,9 +589,9 @@ struct gnttab_cache_flush {
     } a;
     uint16_t offset; /* offset from start of grant */
     uint16_t length; /* size within the grant */
-#define GNTTAB_CACHE_CLEAN          (1<<0)
-#define GNTTAB_CACHE_INVAL          (1<<1)
-#define GNTTAB_CACHE_SOURCE_GREF    (1<<31)
+#define GNTTAB_CACHE_CLEAN          (1u<<0)
+#define GNTTAB_CACHE_INVAL          (1u<<1)
+#define GNTTAB_CACHE_SOURCE_GREF    (1u<<31)
     uint32_t op;
 };
 typedef struct gnttab_cache_flush gnttab_cache_flush_t;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Andrew Cooper

Discovered when running the XSA-232 PoC on a UBSAN-enabled hypervisor.

(d79) XSA-232 PoC
(XEN) ================================================================================ (XEN) UBSAN: Undefined behaviour in grant_table.c:3217:25
(XEN) left shift of 1 by 31 places cannot be represented in type 'int'
(XEN) ----[ Xen-4.10.0-rc x86_64 debug=y Tainted: H ]----

Update all of the GNTTAB_CACHE_* constants to be unsigned integers.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper

Discovered when running the XSA-232 PoC on a UBSAN-enabled hypervisor.

(d79) XSA-232 PoC
(XEN) ================================================================================ (XEN) UBSAN: Undefined behaviour in grant_table.c:3217:25
(XEN) left shift of 1 by 31 places cannot be represented in type 'int'
(XEN) ----[ Xen-4.10.0-rc x86_64 debug=y Tainted: H ]----

Quoted 7 lines

Update all of the GNTTAB_CACHE_* constants to be unsigned integers.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>

Quoted 35 lines
CC Stefano Stabellini <[email protected]>
CC Tim Deegan <[email protected]>
CC Wei Liu <[email protected]>
CC Julien Grall <[email protected]>

This is a trivial bugfix, and is low risk for 4.10

---
 xen/include/public/grant_table.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/public/grant_table.h +3 -3
index 018036e..180d62c 100644
@@ -589,9 +589,9 @@ struct gnttab_cache_flush {
     } a;
     uint16_t offset; /* offset from start of grant */
     uint16_t length; /* size within the grant */
-#define GNTTAB_CACHE_CLEAN          (1<<0)
-#define GNTTAB_CACHE_INVAL          (1<<1)
-#define GNTTAB_CACHE_SOURCE_GREF    (1<<31)
+#define GNTTAB_CACHE_CLEAN          (1u<<0)
+#define GNTTAB_CACHE_INVAL          (1u<<1)
+#define GNTTAB_CACHE_SOURCE_GREF    (1u<<31)
     uint32_t op;
 };
 typedef struct gnttab_cache_flush gnttab_cache_flush_t;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 11 lines · Andrew Cooper

Discovered when running the XSA-232 PoC on a UBSAN-enabled hypervisor.

   (d79) XSA-232 PoC
   (XEN) ================================================================================
   (XEN) UBSAN: Undefined behaviour in grant_table.c:3217:25
   (XEN) left shift of 1 by 31 places cannot be represented in type 'int'
   (XEN) ----[ Xen-4.10.0-rc  x86_64  debug=y   Tainted:    H ]----

Update all of the GNTTAB_CACHE_* constants to be unsigned integers.

Cheers,

Quoted 32 lines

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

This is a trivial bugfix, and is low risk for 4.10

---
  xen/include/public/grant_table.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/public/grant_table.h +3 -3
index 018036e..180d62c 100644
@@ -589,9 +589,9 @@ struct gnttab_cache_flush {
      } a;
      uint16_t offset; /* offset from start of grant */
      uint16_t length; /* size within the grant */
-#define GNTTAB_CACHE_CLEAN          (1<<0)
-#define GNTTAB_CACHE_INVAL          (1<<1)
-#define GNTTAB_CACHE_SOURCE_GREF    (1<<31)
+#define GNTTAB_CACHE_CLEAN          (1u<<0)
+#define GNTTAB_CACHE_INVAL          (1u<<1)
+#define GNTTAB_CACHE_SOURCE_GREF    (1u<<31)
      uint32_t op;
  };
  typedef struct gnttab_cache_flush gnttab_cache_flush_t;
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel