]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.4.83/xen-io-ring.h-new-macro-to-detect-whether-there-are-too-many-requests-on-the-ring.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.83 / xen-io-ring.h-new-macro-to-detect-whether-there-are-too-many-requests-on-the-ring.patch
CommitLineData
2720559d
GKH
1From 79c4d036e08cdcd9403047a37cbc9e37b5ee86b4 Mon Sep 17 00:00:00 2001
2From: Jan Beulich <jbeulich@suse.com>
3Date: Mon, 17 Jun 2013 15:16:33 -0400
4Subject: xen/io/ring.h: new macro to detect whether there are too many requests on the ring
5
6From: Jan Beulich <jbeulich@suse.com>
7
8commit 8d9256906a97c24e97e016482b9be06ea2532b05 upstream.
9
10Backends may need to protect themselves against an insane number of
11produced requests stored by a frontend, in case they iterate over
12requests until reaching the req_prod value. There can't be more
13requests on the ring than the difference between produced requests
14and produced (but possibly not yet published) responses.
15
16This is a more strict alternative to a patch previously posted by
17Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>.
18
19Signed-off-by: Jan Beulich <jbeulich@suse.com>
20Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
21Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
22Cc: Yijing Wang <wangyijing@huawei.com>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25---
26 include/xen/interface/io/ring.h | 5 +++++
27 1 file changed, 5 insertions(+)
28
29--- a/include/xen/interface/io/ring.h
30+++ b/include/xen/interface/io/ring.h
31@@ -188,6 +188,11 @@ struct __name##_back_ring { \
32 #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \
33 (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
34
35+/* Ill-behaved frontend determination: Can there be this many requests? */
36+#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \
37+ (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
38+
39+
40 #define RING_PUSH_REQUESTS(_r) do { \
41 wmb(); /* back sees requests /before/ updated producer index */ \
42 (_r)->sring->req_prod = (_r)->req_prod_pvt; \