]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
selftests/bpf: Fix invalid use of strncat in test_sockmap
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 3 Dec 2020 23:54:40 +0000 (15:54 -0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 4 Jan 2021 15:37:15 +0000 (16:37 +0100)
commit956f20709f4d1ccc1912713fd05848120cc297ec
treec5f37fb45049f39ccd89e1d14e436be6ed074623
parent14ccee129f0d20128f056d9ba9f0e9b1d27375c9
selftests/bpf: Fix invalid use of strncat in test_sockmap

BugLink: https://bugs.launchpad.net/bugs/1910111
[ Upstream commit eceae70bdeaeb6b8ceb662983cf663ff352fbc96 ]

strncat()'s third argument is how many bytes will be added *in addition* to
already existing bytes in destination. Plus extra zero byte will be added
after that. So existing use in test_sockmap has many opportunities to overflow
the string and cause memory corruptions. And in this case, GCC complains for
a good reason.

Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Fixes: 73563aa3d977 ("selftests/bpf: test_sockmap, print additional test options")
Fixes: 1ade9abadfca ("bpf: test_sockmap, add options for msg_pop_data() helper")
Fixes: 463bac5f1ca7 ("bpf, selftests: Add test for ktls with skb bpf ingress policy")
Fixes: e9dd904708c4 ("bpf: add tls support for testing in test_sockmap")
Fixes: 753fb2ee0934 ("bpf: sockmap, add msg_peek tests to test_sockmap")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201203235440.2302137-2-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
tools/testing/selftests/bpf/test_sockmap.c