Ring buffer positions are unsigned long counters and can wrap on 32-bit systems. ringbuf_process_ring() stops consuming when producer_pos wraps below consumer_pos because it compares the counters by magnitude. Compare the positions for equality instead. The producer cannot move logically behind the consumer in a non-overwrite ring. Fixes: bf99c936f947 ("libbpf: Add BPF ring buffer support") Reported-by: Andrew Werner Assisted-by: Codex:gpt-5.5 Signed-off-by: Tamir Duberstein --- tools/lib/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c index ae7fa79b6217..b7adce37b519 100644 --- a/tools/lib/bpf/ringbuf.c +++ b/tools/lib/bpf/ringbuf.c @@ -268,7 +268,7 @@ static int64_t ringbuf_process_ring(struct ring *r, size_t n) do { got_new_data = false; prod_pos = smp_load_acquire(r->producer_pos); - while (cons_pos < prod_pos) { + while (cons_pos != prod_pos) { len_ptr = r->data + (cons_pos & r->mask); len = smp_load_acquire(len_ptr); -- 2.55.0.rc0.96.gc050c23164