From: Ian Campbell Subject: [PATCH] tools/ocaml: oxenstored: correctly handle a full ring. (Was: Re: [xen-unstable test] 15452: regressions - FAIL) Date: Mon, 11 Feb 2013 11:30:39 +0000 Message-ID: <1360582239.29432.120.camel@zakaz.uk.xensource.com> References: <1360581166.29432.114.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1360581166.29432.114.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: "xen-devel@lists.xensource.com" , Dave Scott List-Id: xen-devel@lists.xenproject.org On Mon, 2013-02-11 at 11:12 +0000, Ian Campbell wrote: > > 26521:2c0fd406f02c tools/ocaml: oxenstored: Be more paranoid about > ring reading I think this change has broken the case where the ring is full. Specifically we've gone from cons = intf->req_cons; prod = intf->req_prod; ... if (prod == cons) return 0; to: cons = intf->req_cons; prod = intf->req_prod; cons = MASK_XENSTORE_IDX(cons); prod = MASK_XENSTORE_IDX(prod); ... if (prod == cons) return 0; IOW if prod == cons + PAGE_SIZE we now make proc == cons before checking if they are the same... 8<--------------------------------- >From dd72c63ee56e700b00c0ceffa5d8c150e50fa36f Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Mon, 11 Feb 2013 11:27:47 +0000 Subject: [PATCH] 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. Signed-off-by: Ian Campbell --- tools/ocaml/libs/xb/xs_ring_stubs.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ocaml/libs/xb/xs_ring_stubs.c b/tools/ocaml/libs/xb/xs_ring_stubs.c index 4888ac5..fdd9983 100644 --- a/tools/ocaml/libs/xb/xs_ring_stubs.c +++ b/tools/ocaml/libs/xb/xs_ring_stubs.c @@ -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 -- 1.7.2.5