selftests/bpf: Prevent out-of-bounds stack access in test_bpffs
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 24 Nov 2021 00:23:23 +0000 (16:23 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 25 Nov 2021 23:15:03 +0000 (00:15 +0100)
commit57428298b5acf2ba2dd98359c532774f6eaeecb3
tree28e480c67e6e746dc4bea684bc49a9be49303cc4
parente2e0d90c550a2588ebed7aa2753adaac0f633989
selftests/bpf: Prevent out-of-bounds stack access in test_bpffs

Buf can be not zero-terminated leading to strstr() to access data beyond
the intended buf[] array. Fix by forcing zero termination.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211124002325.1737739-12-andrii@kernel.org
tools/testing/selftests/bpf/prog_tests/test_bpffs.c