]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Lift hashtab key_size limit
authorFlorian Lehner <dev@der-flo.net>
Thu, 29 Oct 2020 20:14:42 +0000 (21:14 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 6 Nov 2020 04:04:46 +0000 (20:04 -0800)
commit8712dda02a317cce81ab8273e68e03f27e6a1075
tree17958546d169d9eb0989cb96ff10446fe2fd24c5
parentc25ea83c73778c3ae2b8e08b9af7e8973e5194bd
bpf: Lift hashtab key_size limit

Currently key_size of hashtab is limited to MAX_BPF_STACK.
As the key of hashtab can also be a value from a per cpu map it can be
larger than MAX_BPF_STACK.

The use-case for this patch originates to implement allow/disallow
lists for files and file paths. The maximum length of file paths is
defined by PATH_MAX with 4096 chars including nul.
This limit exceeds MAX_BPF_STACK.

Changelog:

v5:
 - Fix cast overflow

v4:
 - Utilize BPF skeleton in tests
 - Rebase

v3:
 - Rebase

v2:
 - Add a test for bpf side

Signed-off-by: Florian Lehner <dev@der-flo.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20201029201442.596690-1-dev@der-flo.net
kernel/bpf/hashtab.c
tools/testing/selftests/bpf/prog_tests/hash_large_key.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_hash_large_key.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_maps.c