libvchan: Make raw_get_{data_ready, buffer_space} match
PATCH 1/1 libvchan: Make raw_get_{data_ready, buffer_space} match
For writing into a vchan, raw_get_buffer_space used >, allowing the full ring size to be written. On the read side, raw_get_data_ready compared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.
--- tools/libvchan/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libvchan/io.c +1 -1
@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)static inline int raw_get_data_ready (struct libxenvchan *ctrl) {uint32_t ready =rd_prod (ctrl) -rd_cons (ctrl); -if (ready >=rd_ring_size (ctrl)) +if (ready >rd_ring_size (ctrl))/* We have no way to return errors. Locking up the ring is * better than the alternatives. */ return 0 ;
Signature · 1 line
1.8.3.1
Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):
Quoted 4 lines
For writing into a vchan,
raw_get_buffer_spaceused >, allowing the full ring size to be written. On the read side,raw_get_data_readycompared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.
This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment.
Thanks,
Ian.
Quoted 21 lines
Signed-off-by Jason Andryuk <[email protected]>--- tools/libvchan/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/libvchan/io.c +1
-1@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)static inline int raw_get_data_ready (struct libxenvchan *ctrl) {uint32_t ready =rd_prod (ctrl) -rd_cons (ctrl); -if (ready >=rd_ring_size (ctrl)) +if (ready >rd_ring_size (ctrl))/* We have no way to return errors. Locking up the ring is * better than the alternatives. */ return 0 ;Signature · 1 line
1.8.3.1
Quoted 11 lines · Ian Jackson
Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):
Quoted 4 lines
For writing into a vchan,
raw_get_buffer_spaceused >, allowing the full ring size to be written. On the read side,raw_get_data_readycompared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment.
Thanks,
Ian.
This also looks correct to me.
Quoted 23 lines
Quoted 21 lines
Signed-off-by Jason Andryuk <[email protected]>--- tools/libvchan/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/libvchan/io.c +1
-2@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)static inline int raw_get_data_ready (struct libxenvchan *ctrl) {uint32_t ready =rd_prod (ctrl) -rd_cons (ctrl); -if (ready >=rd_ring_size (ctrl)) +if (ready >rd_ring_size (ctrl))/* We have no way to return errors. Locking up the ring is * better than the alternatives. */ return 0 ; --1.8.3.1
Signature · 2 lines
Daniel De Graaf National Security Agency
Ian Campbell
Acked-byQuoted 7 lines · Daniel De Graaf
Quoted 6 lines · Ian Jackson
Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):
Quoted 4 lines
For writing into a vchan,
raw_get_buffer_spaceused >, allowing the full ring size to be written. On the read side,raw_get_data_readycompared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.
Quoted 7 lines
Quoted 5 lines
This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment.
Thanks,
Ian.This also looks correct to me.
Can I take that as an Acked-by frm the both of you?
Ian.