include/public: add RING_RESPONSE_PROD_OVERFLOW macro
PATCH 1/1 include/public: add RING_RESPONSE_PROD_OVERFLOW macro
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 <[email protected]>
--- xen/include/public/io/ring.h | 4 ++++ 1 file changed, 4 insertions(+)
xen/include/public/io/ring.h +4 -0
@@ -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; \
Signature · 1 line
2.26.2
Quoted 5 lines · 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 <[email protected]>
Acked-by Jan Beulich <[email protected]>
Quoted 14 lines
xen/include/public/io/ring.h +4
-0@@ -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; \