linux-stable/tools
Hou Tao 0140e079a4 libbpf: Handle size overflow for ringbuf mmap
[ Upstream commit 927cbb478a ]

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: bf99c936f9 ("libbpf: Add BPF ring buffer support")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221116072351.1168938-3-houtao@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-12-08 11:28:39 +01:00
..
accounting
arch x86/cpu: Restore AMD's DE_CFG MSR after resume 2022-11-16 09:58:31 +01:00
bootconfig
bpf bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE 2022-11-16 09:58:15 +01:00
build tools build: Switch to new openssl API for test-libcrypto 2022-08-25 11:40:14 +02:00
cgroup
debugging
edid
firewire
firmware
gpio
hv
iio tools: iio: iio_generic_buffer: Fix read size 2022-12-02 17:41:10 +01:00
include tools/nolibc/string: Fix memcmp() implementation 2022-11-10 18:15:38 +01:00
io_uring
kvm/kvm_stat tools/kvm_stat: fix display of error when multiple processes are found 2022-08-11 13:07:51 +02:00
laptop
leds
lib libbpf: Handle size overflow for ringbuf mmap 2022-12-08 11:28:39 +01:00
memory-model
objtool objtool: Preserve special st_shndx indexes in elf_update_symbol 2022-10-26 12:34:37 +02:00
pci
pcmcia
perf perf tools: Add the include/perf/ directory to .gitignore 2022-11-16 09:58:20 +01:00
power tools/power turbostat: fix ICX DRAM power numbers 2022-06-09 10:22:32 +02:00
rcu
scripts
spi
testing selftests: mptcp: fix mibit vs mbit mix up 2022-12-02 17:41:03 +01:00
thermal/tmon tools/thermal: Fix possible path truncations 2022-08-17 14:24:15 +02:00
time
tracing
usb
virtio tools/virtio: compile with -pthread 2022-05-25 09:57:25 +02:00
vm tools/vm/slabinfo: use alphabetic order when two values are equal 2022-08-25 11:40:13 +02:00
wmi
Makefile