]> Git Repo - linux.git/commit
libbpf: Handle size overflow for ringbuf mmap
authorHou Tao <[email protected]>
Wed, 16 Nov 2022 07:23:49 +0000 (15:23 +0800)
committerAndrii Nakryiko <[email protected]>
Thu, 17 Nov 2022 23:48:50 +0000 (15:48 -0800)
commit927cbb478adf917e0a142b94baa37f06279cc466
treeb77bd9e79b4a72bd72e05e0d60bc9e35d072dc66
parent689eb2f1ba46b4b02195ac2a71c55b96d619ebf8
libbpf: Handle size overflow for ringbuf mmap

The maximum size of ringbuf is 2GB on x86-64 host, so 2 * max_entries
will overflow u32 when mapping producer page and data pages. Only
casting max_entries to size_t is not enough, because for 32-bits
application on 64-bits kernel the size of read-only mmap region
also could overflow size_t.

So fixing it by casting the size of read-only mmap region into a __u64
and checking whether or not there will be overflow during mmap.

Fixes: bf99c936f947 ("libbpf: Add BPF ring buffer support")
Signed-off-by: Hou Tao <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
tools/lib/bpf/ringbuf.c
This page took 0.052635 seconds and 4 git commands to generate.