<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/testing/selftests/bpf, branch linux-6.0.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.0.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.0.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-12-31T12:26:46Z</updated>
<entry>
<title>selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym</title>
<updated>2022-12-31T12:26:46Z</updated>
<author>
<name>James Hilliard</name>
</author>
<published>2022-12-03T01:08:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ddb560051a0cb2d3835bfbdad4b4b0e324a2cd86'/>
<id>urn:sha1:ddb560051a0cb2d3835bfbdad4b4b0e324a2cd86</id>
<content type='text'>
[ Upstream commit ab0350c743d5c93fd88742f02b3dff12168ab435 ]

Both tolower and toupper are built in c functions, we should not
redefine them as this can result in a build error.

Fixes the following errors:
progs/bpf_iter_ksym.c:10:20: error: conflicting types for built-in function 'tolower'; expected 'int(int)' [-Werror=builtin-declaration-mismatch]
   10 | static inline char tolower(char c)
      |                    ^~~~~~~
progs/bpf_iter_ksym.c:5:1: note: 'tolower' is declared in header '&lt;ctype.h&gt;'
    4 | #include &lt;bpf/bpf_helpers.h&gt;
  +++ |+#include &lt;ctype.h&gt;
    5 |
progs/bpf_iter_ksym.c:17:20: error: conflicting types for built-in function 'toupper'; expected 'int(int)' [-Werror=builtin-declaration-mismatch]
   17 | static inline char toupper(char c)
      |                    ^~~~~~~
progs/bpf_iter_ksym.c:17:20: note: 'toupper' is declared in header '&lt;ctype.h&gt;'

See background on this sort of issue:
https://stackoverflow.com/a/20582607
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12213

(C99, 7.1.3p1) "All identifiers with external linkage in any of the
following subclauses (including the future library directions) are
always reserved for use as identifiers with external linkage."

This is documented behavior in GCC:
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-std-2

Signed-off-by: James Hilliard &lt;james.hilliard1@gmail.com&gt;
Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/r/20221203010847.2191265-1-james.hilliard1@gmail.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Select CONFIG_FUNCTION_ERROR_INJECTION</title>
<updated>2022-12-31T12:26:37Z</updated>
<author>
<name>Song Liu</name>
</author>
<published>2022-12-13T22:05:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4d9bceb766e21d74fb249ffa8eea4e4e0de60310'/>
<id>urn:sha1:4d9bceb766e21d74fb249ffa8eea4e4e0de60310</id>
<content type='text'>
[ Upstream commit a8dfde09c90109e3a98af54847e91bde7dc2d5c2 ]

BPF selftests require CONFIG_FUNCTION_ERROR_INJECTION to work. However,
CONFIG_FUNCTION_ERROR_INJECTION is no longer 'y' by default after recent
changes. As a result, we are seeing errors like the following from BPF CI:

   bpf_testmod_test_read() is not modifiable
   __x64_sys_setdomainname is not sleepable
   __x64_sys_getpgid is not sleepable

Fix this by explicitly selecting CONFIG_FUNCTION_ERROR_INJECTION in the
selftest config.

Fixes: a4412fdd49dc ("error-injection: Add prompt for function error injection")
Reported-by: Daniel Müller &lt;deso@posteo.net&gt;
Signed-off-by: Song Liu &lt;song@kernel.org&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Daniel Müller &lt;deso@posteo.net&gt;
Link: https://lore.kernel.org/bpf/20221213220500.3427947-1-song@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Mount debugfs in setns_by_fd</title>
<updated>2022-12-31T12:26:01Z</updated>
<author>
<name>Stanislav Fomichev</name>
</author>
<published>2022-11-23T20:08:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=404d3133f17d637d7e4b88f654641f9c9f674949'/>
<id>urn:sha1:404d3133f17d637d7e4b88f654641f9c9f674949</id>
<content type='text'>
[ Upstream commit 8ac88eece8009428e2577c345080a458e4507e2f ]

Jiri reports broken test_progs after recent commit 68f8e3d4b916
("selftests/bpf: Make sure zero-len skbs aren't redirectable").
Apparently we don't remount debugfs when we switch back networking namespace.
Let's explicitly mount /sys/kernel/debug.

0: https://lore.kernel.org/bpf/63b85917-a2ea-8e35-620c-808560910819@meta.com/T/#ma66ca9c92e99eee0a25e40f422489b26ee0171c1

Fixes: a30338840fa5 ("selftests/bpf: Move open_netns() and close_netns() into network_helpers.c")
Reported-by: Jiri Olsa &lt;olsajiri@gmail.com&gt;
Signed-off-by: Stanislav Fomichev &lt;sdf@google.com&gt;
Link: https://lore.kernel.org/r/20221123200829.2226254-1-sdf@google.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Make sure zero-len skbs aren't redirectable</title>
<updated>2022-12-31T12:26:01Z</updated>
<author>
<name>Stanislav Fomichev</name>
</author>
<published>2022-11-21T18:03:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9dba01924bbf1aedf3ab11db0b8dda6f90fce172'/>
<id>urn:sha1:9dba01924bbf1aedf3ab11db0b8dda6f90fce172</id>
<content type='text'>
[ Upstream commit 68f8e3d4b916531ea3bb8b83e35138cf78f2fce5 ]

LWT_XMIT to test L3 case, TC to test L2 case.

v2:
- s/veth_ifindex/ipip_ifindex/ in two places (Martin)
- add comment about which condition triggers the rejection (Martin)

Signed-off-by: Stanislav Fomichev &lt;sdf@google.com&gt;
Link: https://lore.kernel.org/r/20221121180340.1983627-2-sdf@google.com
Signed-off-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
Stable-dep-of: 8ac88eece800 ("selftests/bpf: Mount debugfs in setns_by_fd")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: fix memory leak of lsm_cgroup</title>
<updated>2022-12-31T12:25:59Z</updated>
<author>
<name>Wang Yufen</name>
</author>
<published>2022-11-15T03:29:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ca80a999695b00a53025fc96589410b3bfc3a953'/>
<id>urn:sha1:ca80a999695b00a53025fc96589410b3bfc3a953</id>
<content type='text'>
[ Upstream commit c453e64cbc9532c0c2edfa999c35d29dad16b8bb ]

kmemleak reports this issue:

unreferenced object 0xffff88810b7835c0 (size 32):
  comm "test_progs", pid 270, jiffies 4294969007 (age 1621.315s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    03 00 00 00 03 00 00 00 0f 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;00000000376cdeab&gt;] kmalloc_trace+0x27/0x110
    [&lt;000000003bcdb3b6&gt;] selinux_sk_alloc_security+0x66/0x110
    [&lt;000000003959008f&gt;] security_sk_alloc+0x47/0x80
    [&lt;00000000e7bc6668&gt;] sk_prot_alloc+0xbd/0x1a0
    [&lt;0000000002d6343a&gt;] sk_alloc+0x3b/0x940
    [&lt;000000009812a46d&gt;] unix_create1+0x8f/0x3d0
    [&lt;000000005ed0976b&gt;] unix_create+0xa1/0x150
    [&lt;0000000086a1d27f&gt;] __sock_create+0x233/0x4a0
    [&lt;00000000cffe3a73&gt;] __sys_socket_create.part.0+0xaa/0x110
    [&lt;0000000007c63f20&gt;] __sys_socket+0x49/0xf0
    [&lt;00000000b08753c8&gt;] __x64_sys_socket+0x42/0x50
    [&lt;00000000b56e26b3&gt;] do_syscall_64+0x3b/0x90
    [&lt;000000009b4871b8&gt;] entry_SYSCALL_64_after_hwframe+0x63/0xcd

The issue occurs in the following scenarios:

unix_create1()
  sk_alloc()
    sk_prot_alloc()
      security_sk_alloc()
        call_int_hook()
          hlist_for_each_entry()
            entry1-&gt;hook.sk_alloc_security
            &lt;-- selinux_sk_alloc_security() succeeded,
            &lt;-- sk-&gt;security alloced here.
            entry2-&gt;hook.sk_alloc_security
            &lt;-- bpf_lsm_sk_alloc_security() failed
      goto out_free;
        ...    &lt;-- the sk-&gt;security not freed, memleak

The core problem is that the LSM is not yet fully stacked (work is
actively going on in this space) which means that some LSM hooks do
not support multiple LSMs at the same time. To fix, skip the
"EPERM" test when it runs in the environments that already have
non-bpf lsms installed

Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
Signed-off-by: Wang Yufen &lt;wangyufen@huawei.com&gt;
Cc: Stanislav Fomichev &lt;sdf@google.com&gt;
Acked-by: Stanislav Fomichev &lt;sdf@google.com&gt;
Link: https://lore.kernel.org/r/1668482980-16163-1-git-send-email-wangyufen@huawei.com
Signed-off-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Fix xdp_synproxy compilation failure in 32-bit arch</title>
<updated>2022-12-31T12:25:57Z</updated>
<author>
<name>Yang Jihong</name>
</author>
<published>2022-11-11T03:08:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d6e2041365bee4ffce8f5c496076c05db3715413'/>
<id>urn:sha1:d6e2041365bee4ffce8f5c496076c05db3715413</id>
<content type='text'>
[ Upstream commit e4c9cf0ce8c413c2030e8fb215551d7e0582ee7b ]

xdp_synproxy fails to be compiled in the 32-bit arch, log is as follows:

  xdp_synproxy.c: In function 'parse_options':
  xdp_synproxy.c:175:36: error: left shift count &gt;= width of type [-Werror=shift-count-overflow]
    175 |                 *tcpipopts = (mss6 &lt;&lt; 32) | (ttl &lt;&lt; 24) | (wscale &lt;&lt; 16) | mss4;
        |                                    ^~
  xdp_synproxy.c: In function 'syncookie_open_bpf_maps':
  xdp_synproxy.c:289:28: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
    289 |                 .map_ids = (__u64)map_ids,
        |                            ^

Fix it.

Fixes: fb5cd0ce70d4 ("selftests/bpf: Add selftests for raw syncookie helpers")
Signed-off-by: Yang Jihong &lt;yangjihong1@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/bpf/20221111030836.37632-1-yangjihong1@huawei.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftest/bpf: Fix error usage of ASSERT_OK in xdp_adjust_tail.c</title>
<updated>2022-12-31T12:25:49Z</updated>
<author>
<name>Xu Kuohai</name>
</author>
<published>2022-10-11T12:01:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=03276a842b6aef413d8c826ce181e30b2e026d52'/>
<id>urn:sha1:03276a842b6aef413d8c826ce181e30b2e026d52</id>
<content type='text'>
[ Upstream commit cbc1c998da59687e8bbc4667154a72eead2daf2d ]

xdp_adjust_tail.c calls ASSERT_OK() to check the return value of
bpf_prog_test_load(), but the condition is not correct. Fix it.

Fixes: 791cad025051 ("bpf: selftests: Get rid of CHECK macro in xdp_adjust_tail.c")
Signed-off-by: Xu Kuohai &lt;xukuohai@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20221011120108.782373-7-xukuohai@huaweicloud.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Fix error failure of case test_xdp_adjust_tail_grow</title>
<updated>2022-12-31T12:25:49Z</updated>
<author>
<name>Xu Kuohai</name>
</author>
<published>2022-10-11T12:01:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1c311272eb3a7e807ecd32b956d9336ada7eb1ec'/>
<id>urn:sha1:1c311272eb3a7e807ecd32b956d9336ada7eb1ec</id>
<content type='text'>
[ Upstream commit 4abdb1d5b250df4b5b3afd394d5e2fa516064c04 ]

test_xdp_adjust_tail_grow failed with ipv6:
  test_xdp_adjust_tail_grow:FAIL:ipv6 unexpected error: -28 (errno 28)

The reason is that this test case tests ipv4 before ipv6, and when ipv4
test finished, topts.data_size_out was set to 54, which is smaller than the
ipv6 output data size 114, so ipv6 test fails with NOSPC error.

Fix it by reset topts.data_size_out to sizeof(buf) before testing ipv6.

Fixes: 04fcb5f9a104 ("selftests/bpf: Migrate from bpf_prog_test_run")
Signed-off-by: Xu Kuohai &lt;xukuohai@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20221011120108.782373-6-xukuohai@huaweicloud.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftest/bpf: Fix memory leak in kprobe_multi_test</title>
<updated>2022-12-31T12:25:49Z</updated>
<author>
<name>Xu Kuohai</name>
</author>
<published>2022-10-11T12:01:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=78b772629cc5adec02ab4182b62abe916f2254a0'/>
<id>urn:sha1:78b772629cc5adec02ab4182b62abe916f2254a0</id>
<content type='text'>
[ Upstream commit 6d2e21dc4db3933db65293552ecc1ede26febeca ]

The get_syms() function in kprobe_multi_test.c does not free the string
memory allocated by sscanf correctly. Fix it.

Fixes: 5b6c7e5c4434 ("selftests/bpf: Add attach bench test")
Signed-off-by: Xu Kuohai &lt;xukuohai@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20221011120108.782373-5-xukuohai@huaweicloud.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Fix memory leak caused by not destroying skeleton</title>
<updated>2022-12-31T12:25:49Z</updated>
<author>
<name>Xu Kuohai</name>
</author>
<published>2022-10-11T12:01:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=70028a10b6f50b917ac2da84478f706deb4fb066'/>
<id>urn:sha1:70028a10b6f50b917ac2da84478f706deb4fb066</id>
<content type='text'>
[ Upstream commit 6e8280b958c5d7edc514cf347a800b23b7732b2b ]

Some test cases does not destroy skeleton object correctly, causing ASAN
to report memory leak warning. Fix it.

Fixes: 0ef6740e9777 ("selftests/bpf: Add tests for kptr_ref refcounting")
Fixes: 1642a3945e22 ("selftests/bpf: Add struct argument tests with fentry/fexit programs.")
Signed-off-by: Xu Kuohai &lt;xukuohai@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20221011120108.782373-4-xukuohai@huaweicloud.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
