Skip to content

Commit aff6db4

Browse files
congwangdavem330
authored andcommitted
ptr_ring: wrap back ->producer in __ptr_ring_swap_queue()
__ptr_ring_swap_queue() tries to move pointers from the old ring to the new one, but it forgets to check if ->producer is beyond the new size at the end of the operation. This leads to an out-of-bound access in __ptr_ring_produce() as reported by syzbot. Reported-by: [email protected] Fixes: 5d49de5 ("ptr_ring: resize support") Cc: "Michael S. Tsirkin" <[email protected]> Cc: John Fastabend <[email protected]> Cc: Jason Wang <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4087d2b commit aff6db4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/ptr_ring.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ static inline void **__ptr_ring_swap_queue(struct ptr_ring *r, void **queue,
573573
else if (destroy)
574574
destroy(ptr);
575575

576+
if (producer >= size)
577+
producer = 0;
576578
__ptr_ring_set_size(r, size);
577579
r->producer = producer;
578580
r->consumer_head = 0;

0 commit comments

Comments
 (0)