aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/ringbuf.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <[email protected]>2024-04-30 20:19:51 +0000
committerMartin KaFai Lau <[email protected]>2024-05-02 23:41:02 +0000
commit00f0e08f23fc007f4a5a71cd7e37fcdb15af0c1b (patch)
tree9bf2f7de3fb366f9cda9f3566132e53885be313c /tools/lib/bpf/ringbuf.c
parentMerge branch 'Add new args into tcp_congestion_ops' cong_control' (diff)
downloadkernel-00f0e08f23fc007f4a5a71cd7e37fcdb15af0c1b.tar.gz
kernel-00f0e08f23fc007f4a5a71cd7e37fcdb15af0c1b.zip
libbpf: fix potential overflow in ring__consume_n()
ringbuf_process_ring() return int64_t, while ring__consume_n() assigns it to int. It's highly unlikely, but possible for ringbuf_process_ring() to return value larger than INT_MAX, so use int64_t. ring__consume_n() does check INT_MAX before returning int result to the user. Fixes: 4d22ea94ea33 ("libbpf: Add ring__consume_n / ring_buffer__consume_n") Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
Diffstat (limited to 'tools/lib/bpf/ringbuf.c')
-rw-r--r--tools/lib/bpf/ringbuf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c
index 99e44cf02321..37c5a2d86a78 100644
--- a/tools/lib/bpf/ringbuf.c
+++ b/tools/lib/bpf/ringbuf.c
@@ -405,7 +405,7 @@ int ring__map_fd(const struct ring *r)
int ring__consume_n(struct ring *r, size_t n)
{
- int res;
+ int64_t res;
res = ringbuf_process_ring(r, n);
if (res < 0)