]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Enforce BPF ringbuf size to be the power of 2
authorAndrii Nakryiko <andriin@fb.com>
Tue, 30 Jun 2020 06:15:00 +0000 (23:15 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 30 Jun 2020 14:31:55 +0000 (16:31 +0200)
commit8c38bacd3271ac9914f69b5f9d822ed9c07023d3
treee1c863b9b31b8101e280f2c8b8a5b1443f274c74
parent381d47cc084fd0c872627bcf2ac35925a87d313c
bpf: Enforce BPF ringbuf size to be the power of 2

BPF ringbuf assumes the size to be a multiple of page size and the power of
2 value. The latter is important to avoid division while calculating position
inside the ring buffer and using (N-1) mask instead. This patch fixes omission
to enforce power-of-2 size rule.

Fixes: 8d560509c598 ("bpf: Implement BPF ring buffer and verifier support for it")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200630061500.1804799-1-andriin@fb.com
kernel/bpf/ringbuf.c