Skip to contentSkip to conversation

tools/ocaml: oxenstored: correctly handle a full ring.

PATCH In review Ian Campbell 3 participants 6 messages Feb 13, 2013 – Feb 15, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/ocaml: oxenstored: correctly handle a full ring.

Change 26521:2c0fd406f02c (part of XSA-38 / CVE-2013-0215) incorrectly caused us to ignore rather than process a completely full ring. Check if producer and consumer are equal before masking to avoid this, since prod == cons + PAGE_SIZE after masking becomes prod == cons.

---
 tools/ocaml/libs/xb/xs_ring_stubs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/libs/xb/xs_ring_stubs.c +2 -2
index 4888ac5..fdd9983 100644
@@ -45,10 +45,10 @@ static int xs_ring_read(struct mmap_interface *interface,
 	cons = *(volatile uint32*)&intf->req_cons;
 	prod = *(volatile uint32*)&intf->req_prod;
 	xen_mb();
-	cons = MASK_XENSTORE_IDX(cons);
-	prod = MASK_XENSTORE_IDX(prod);
 	if (prod == cons)
 		return 0;
+	cons = MASK_XENSTORE_IDX(cons);
+	prod = MASK_XENSTORE_IDX(prod);
 	if (prod > cons)
 		to_read = prod - cons;
 	else
Signature · 1 line
1.7.2.5
#1 lore raw

Can I get an ACK or NACK for this please, we really should update XSA-38 ASAP...

Quoted 27 lines · Ian Campbell

Change 26521:2c0fd406f02c (part of XSA-38 / CVE-2013-0215) incorrectly caused us to ignore rather than process a completely full ring. Check if producer and consumer are equal before masking to avoid this, since prod == cons + PAGE_SIZE after masking becomes prod == cons.

---
 tools/ocaml/libs/xb/xs_ring_stubs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/libs/xb/xs_ring_stubs.c +2 -2
index 4888ac5..fdd9983 100644
@@ -45,10 +45,10 @@ static int xs_ring_read(struct mmap_interface *interface,
 	cons = *(volatile uint32*)&intf->req_cons;
 	prod = *(volatile uint32*)&intf->req_prod;
 	xen_mb();
-	cons = MASK_XENSTORE_IDX(cons);
-	prod = MASK_XENSTORE_IDX(prod);
 	if (prod == cons)
 		return 0;
+	cons = MASK_XENSTORE_IDX(cons);
+	prod = MASK_XENSTORE_IDX(prod);
 	if (prod > cons)
 		to_read = prod - cons;
 	else
Acked-by
#2 lore raw

Who are you looking for an Ack from? The patch makes pefect sense to me so you can have mine if you want it.

Quoted 39 lines · Ian Campbell

Can I get an ACK or NACK for this please, we really should update XSA-38 ASAP...

Quoted 27 lines · Ian Campbell

Change 26521:2c0fd406f02c (part of XSA-38 / CVE-2013-0215) incorrectly caused us to ignore rather than process a completely full ring. Check if producer and consumer are equal before masking to avoid this, since prod == cons + PAGE_SIZE after masking becomes prod == cons.

---
 tools/ocaml/libs/xb/xs_ring_stubs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/libs/xb/xs_ring_stubs.c +2 -2
index 4888ac5..fdd9983 100644
@@ -45,10 +45,10 @@ static int xs_ring_read(struct mmap_interface *interface,
 cons = *(volatile uint32*)&intf->req_cons;
 prod = *(volatile uint32*)&intf->req_prod;
 xen_mb();
- cons = MASK_XENSTORE_IDX(cons);
- prod = MASK_XENSTORE_IDX(prod);
 if (prod == cons)
 return 0;
+ cons = MASK_XENSTORE_IDX(cons);
+ prod = MASK_XENSTORE_IDX(prod);
 if (prod > cons)
 to_read = prod - cons;
Quoted 1 line

else

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

#3 lore raw

You'll do :-P

Quoted 49 lines · Keir Fraser

Who are you looking for an Ack from? The patch makes pefect sense to me so you can have mine if you want it.

Quoted 39 lines · Ian Campbell

Can I get an ACK or NACK for this please, we really should update XSA-38 ASAP...

Quoted 27 lines · Ian Campbell

Change 26521:2c0fd406f02c (part of XSA-38 / CVE-2013-0215) incorrectly caused us to ignore rather than process a completely full ring. Check if producer and consumer are equal before masking to avoid this, since prod == cons + PAGE_SIZE after masking becomes prod == cons.

---
 tools/ocaml/libs/xb/xs_ring_stubs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/ocaml/libs/xb/xs_ring_stubs.c +2 -2
index 4888ac5..fdd9983 100644
@@ -45,10 +45,10 @@ static int xs_ring_read(struct mmap_interface *interface,
 cons = *(volatile uint32*)&intf->req_cons;
 prod = *(volatile uint32*)&intf->req_prod;
 xen_mb();
- cons = MASK_XENSTORE_IDX(cons);
- prod = MASK_XENSTORE_IDX(prod);
 if (prod == cons)
 return 0;
+ cons = MASK_XENSTORE_IDX(cons);
+ prod = MASK_XENSTORE_IDX(prod);
 if (prod > cons)
 to_read = prod - cons;
Quoted 1 line

else

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

#4 lore raw
Quoted 5 lines · Keir Fraser
Quoted 4 lines

Who are you looking for an Ack from? The patch makes pefect sense to me so you can have mine if you want it.

Committed, thanks.

Ian: Can you backport 26539:759574df84a6 to everywhere the original patches went please.

Thanks,
Ian.

#5 lore raw

Ian Campbell writes ("Re: [Xen-devel] [PATCH] tools/ocaml: oxenstored: correctly handle a full ring."):

Quoted 10 lines
Quoted 5 lines · Keir Fraser
Quoted 4 lines

Who are you looking for an Ack from? The patch makes pefect sense to me so you can have mine if you want it.

Committed, thanks.

Ian: Can you backport 26539:759574df84a6 to everywhere the original patches went please.

Done. Sorry for making this mess.

Ian.