From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>, stable@vger.kernel.org
Subject: Re: [PATCH 2/3] xen/ring: Add a new macro to detect whether there is an overflow in requests and response.
Date: Fri, 25 Jan 2013 13:41:12 -0500 [thread overview]
Message-ID: <20130125184112.GA1384@phenom.dumpdata.com> (raw)
In-Reply-To: <1359135152-30688-3-git-send-email-konrad.wilk@oracle.com>
On Fri, Jan 25, 2013 at 12:32:31PM -0500, Konrad Rzeszutek Wilk wrote:
> We want to be able to exit if the difference between the request
> produced (what the frontend tells us) and the requests consumed
> (what we have so far processed) is greater than the ring size.
>
> If so, we should terminate the loop as the request produced
> is not trusted and it means it is bogus.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> include/xen/interface/io/ring.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h
> index 75271b9..1114dde 100644
> --- a/include/xen/interface/io/ring.h
> +++ b/include/xen/interface/io/ring.h
> @@ -188,6 +188,12 @@ struct __name##_back_ring { \
> #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \
> (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
>
> +/* Loop termination condition: Is the difference between request produced
> + * and request consumed greater than the ring size. If so, terminate the
> + * loop. */
> +#define RING_REQUEST_PROD_OVERFLOW(_r, _cons, _prod) \
> + (((_prod) - (_prod)) > RING_SIZE(_r))
> +
> #define RING_PUSH_REQUESTS(_r) do { \
> wmb(); /* back sees requests /before/ updated producer index */ \
> (_r)->sring->req_prod = (_r)->req_prod_pvt; \
> --
> 1.8.0.2
>
Per Roger sharp eyes:
>From 567782db60a5e410924751fb7c2e021095720b93 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Wed, 23 Jan 2013 16:53:54 -0500
Subject: [PATCH 1/2] xen/ring: Add a new macro to detect whether there is an
overflow in requests and response.
We want to be able to exit if the difference between the request
produced (what the frontend tells us) and the requests consumed
(what we have so far processed) is greater than the ring size.
If so, we should terminate the loop as the request produced
is not trusted and it means it is bogus.
Cc: stable@vger.kernel.org
[v1: Make the macro do the ring thing, swap arguments around to
match the comment]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
include/xen/interface/io/ring.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h
index 75271b9..94aa885 100644
--- a/include/xen/interface/io/ring.h
+++ b/include/xen/interface/io/ring.h
@@ -188,6 +188,12 @@ struct __name##_back_ring { \
#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \
(((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
+/* Loop termination condition: Is the difference between request produced
+ * and request consumed greater than the ring size. If so, terminate the
+ * loop. */
+#define RING_REQUEST_PROD_OVERFLOW(_r, _prod, _cons) \
+ (((_prod) - (_cons)) > RING_SIZE(_r))
+
#define RING_PUSH_REQUESTS(_r) do { \
wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = (_r)->req_prod_pvt; \
--
1.8.0.2
next prev parent reply other threads:[~2013-01-25 18:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1359135152-30688-1-git-send-email-konrad.wilk@oracle.com>
2013-01-25 17:32 ` [PATCH 1/3] xen/blkback: Don't trust the handle from the frontend Konrad Rzeszutek Wilk
2013-01-28 11:09 ` [Xen-devel] " Jan Beulich
2013-01-25 17:32 ` [PATCH 2/3] xen/ring: Add a new macro to detect whether there is an overflow in requests and response Konrad Rzeszutek Wilk
2013-01-25 17:45 ` [Xen-devel] " Roger Pau Monné
2013-01-25 18:29 ` Konrad Rzeszutek Wilk
2013-01-25 18:41 ` Konrad Rzeszutek Wilk
2013-01-25 18:41 ` Konrad Rzeszutek Wilk [this message]
2013-01-25 17:32 ` [PATCH 3/3] xen/blkback: Check for insane amounts of request on the ring Konrad Rzeszutek Wilk
2013-01-25 18:43 ` Konrad Rzeszutek Wilk
2013-01-28 11:07 ` [Xen-devel] " Jan Beulich
2013-01-28 15:42 ` Konrad Rzeszutek Wilk
2013-01-28 16:18 ` Jan Beulich
2013-01-28 16:47 ` Konrad Rzeszutek Wilk
2013-01-28 11:38 ` David Vrabel
2013-01-28 15:44 ` Konrad Rzeszutek Wilk
2013-01-28 16:03 ` David Vrabel
2013-01-28 16:13 ` Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130125184112.GA1384@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=konrad@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).