]> git.baikalelectronics.ru Git - 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)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Dec 2020 02:07:05 +0000 (18:07 -0800)
commit6040d727e65ebd39dd375567f55e9f2626144027
treeaa96f057c1fc40f0d9f8db8b1ba63808a563933f
parent61b45eeeeb6dbe6ba02989d52484ccedb12f828b
selftests/bpf: Fix invalid use of strncat in test_sockmap

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: 25017cdeb1ee ("bpf: sockmap, add selftests")
Fixes: c564869d651b ("selftests/bpf: test_sockmap, print additional test options")
Fixes: 7596f11edcdb ("bpf: test_sockmap, add options for msg_pop_data() helper")
Fixes: 70f234ad2aa2 ("bpf, selftests: Add test for ktls with skb bpf ingress policy")
Fixes: ea29ae6bc81e ("bpf: add tls support for testing in test_sockmap")
Fixes: 1f9ad0bbd60b ("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
tools/testing/selftests/bpf/test_sockmap.c