xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] include/public: add RING_RESPONSE_PROD_OVERFLOW macro
@ 2021-05-12 16:48 Juergen Gross
  2021-05-17  9:38 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Gross @ 2021-05-12 16:48 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross

Add a new RING_RESPONSE_PROD_OVERFLOW() macro for being able to
detect an ill-behaved backend tampering with the response producer
index.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/include/public/io/ring.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h
index 0b08b2697e..c486c457e0 100644
--- a/xen/include/public/io/ring.h
+++ b/xen/include/public/io/ring.h
@@ -259,6 +259,10 @@ typedef struct __name##_back_ring __name##_back_ring_t
 #define RING_REQUEST_PROD_OVERFLOW(_r, _prod)                           \
     (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
 
+/* Ill-behaved backend determination: Can there be this many responses? */
+#define RING_RESPONSE_PROD_OVERFLOW(_r, _prod)                          \
+    (((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))
+
 #define RING_PUSH_REQUESTS(_r) do {                                     \
     xen_wmb(); /* back sees requests /before/ updated producer index */ \
     (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] include/public: add RING_RESPONSE_PROD_OVERFLOW macro
  2021-05-12 16:48 [PATCH] include/public: add RING_RESPONSE_PROD_OVERFLOW macro Juergen Gross
@ 2021-05-17  9:38 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2021-05-17  9:38 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel

On 12.05.2021 18:48, Juergen Gross wrote:
> Add a new RING_RESPONSE_PROD_OVERFLOW() macro for being able to
> detect an ill-behaved backend tampering with the response producer
> index.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/include/public/io/ring.h
> +++ b/xen/include/public/io/ring.h
> @@ -259,6 +259,10 @@ typedef struct __name##_back_ring __name##_back_ring_t
>  #define RING_REQUEST_PROD_OVERFLOW(_r, _prod)                           \
>      (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
>  
> +/* Ill-behaved backend determination: Can there be this many responses? */
> +#define RING_RESPONSE_PROD_OVERFLOW(_r, _prod)                          \
> +    (((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))
> +
>  #define RING_PUSH_REQUESTS(_r) do {                                     \
>      xen_wmb(); /* back sees requests /before/ updated producer index */ \
>      (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-17  9:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 16:48 [PATCH] include/public: add RING_RESPONSE_PROD_OVERFLOW macro Juergen Gross
2021-05-17  9:38 ` Jan Beulich

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).