]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, test, cgroup: Use sk_{alloc,free} for test cases
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 27 Sep 2021 12:39:21 +0000 (14:39 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 28 Sep 2021 07:29:28 +0000 (09:29 +0200)
commit3d3080ad89887ddd0c23a6d2027de42d454bf625
treec728ee23e0b3fd5d6d5f51836af5102555185880
parenta218b43b279cbe88041a2e15f9b1aa273f70142d
bpf, test, cgroup: Use sk_{alloc,free} for test cases

BPF test infra has some hacks in place which kzalloc() a socket and perform
minimum init via sock_net_set() and sock_init_data(). As a result, the sk's
skcd->cgroup is NULL since it didn't go through proper initialization as it
would have been the case from sk_alloc(). Rather than re-adding a NULL test
in sock_cgroup_ptr() just for this, use sk_{alloc,free}() pair for the test
socket. The latter also allows to get rid of the bpf_sk_storage_free() special
case.

Fixes: 82247e076111 ("bpf, cgroups: Fix cgroup v2 fallback on v1/v2 mixed mode")
Fixes: fbd38e5f0394 ("bpf: add BPF_PROG_TEST_RUN support for flow dissector")
Fixes: 541cb37586dd ("bpf: add tests for direct packet access from CGROUP_SKB")
Reported-by: syzbot+664b58e9a40fbb2cec71@syzkaller.appspotmail.com
Reported-by: syzbot+33f36d0754d4c5c0e102@syzkaller.appspotmail.com
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: syzbot+664b58e9a40fbb2cec71@syzkaller.appspotmail.com
Tested-by: syzbot+33f36d0754d4c5c0e102@syzkaller.appspotmail.com
Link: https://lore.kernel.org/bpf/20210927123921.21535-2-daniel@iogearbox.net
net/bpf/test_run.c