<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/testing/selftests/bpf/prog_tests/kfunc_call.c, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-09-09T22:58:17Z</updated>
<entry>
<title>bpf: Fix error message on kfunc arg type mismatch</title>
<updated>2024-09-09T22:58:17Z</updated>
<author>
<name>Maxim Mikityanskiy</name>
</author>
<published>2024-09-09T13:39:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bee109b7b3e50739b88252a219fa07ecd78ad628'/>
<id>urn:sha1:bee109b7b3e50739b88252a219fa07ecd78ad628</id>
<content type='text'>
When "arg#%d expected pointer to ctx, but got %s" error is printed, both
template parts actually point to the type of the argument, therefore, it
will also say "but got PTR", regardless of what was the actual register
type.

Fix the message to print the register type in the second part of the
template, change the existing test to adapt to the new format, and add a
new test to test the case when arg is a pointer to context, but reg is a
scalar.

Fixes: 00b85860feb8 ("bpf: Rewrite kfunc argument handling")
Signed-off-by: Maxim Mikityanskiy &lt;maxim@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Kumar Kartikeya Dwivedi &lt;memxor@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20240909133909.1315460-1-maxim@isovalent.com
</content>
</entry>
<entry>
<title>selftests/bpf: Add kfunc_call test for simple dtor in bpf_testmod</title>
<updated>2024-06-21T21:46:29Z</updated>
<author>
<name>Alan Maguire</name>
</author>
<published>2024-06-20T09:17:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=47a8cf0c5b3f6769b9d558301735c75119a0a165'/>
<id>urn:sha1:47a8cf0c5b3f6769b9d558301735c75119a0a165</id>
<content type='text'>
add simple kfuncs to create/destroy a context type to bpf_testmod,
register them and add a kfunc_call test to use them.  This provides
test coverage for registration of dtor kfuncs from modules.

By transferring the context pointer to a map value as a __kptr
we also trigger the map-based dtor cleanup logic, improving test
coverage.

Suggested-by: Eduard Zingerman &lt;eddyz87@gmail.com&gt;
Signed-off-by: Alan Maguire &lt;alan.maguire@oracle.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20240620091733.1967885-7-alan.maguire@oracle.com
</content>
</entry>
<entry>
<title>selftests/bpf: Fix repeat option when kfunc_call verification fails</title>
<updated>2023-08-14T16:03:00Z</updated>
<author>
<name>Yipeng Zou</name>
</author>
<published>2023-08-14T03:14:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=811915db674f8daf19bb4fcb67da9017235ce26d'/>
<id>urn:sha1:811915db674f8daf19bb4fcb67da9017235ce26d</id>
<content type='text'>
There is no way where topts.repeat can be set to 1 when tc_test fails.
Fix the typo where the break statement slipped by one line.

Fixes: fb66223a244f ("selftests/bpf: add test for accessing ctx from syscall program type")
Signed-off-by: Yipeng Zou &lt;zouyipeng@huawei.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Reviewed-by: Li Zetao &lt;lizetao1@huawei.com&gt;
Link: https://lore.kernel.org/bpf/20230814031434.3077944-1-zouyipeng@huawei.com
</content>
</entry>
<entry>
<title>selftests/bpf: Add testcase for static kfunc with unused arg</title>
<updated>2023-02-01T23:25:14Z</updated>
<author>
<name>David Vernet</name>
</author>
<published>2023-02-01T17:30:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6aed15e330bfec6a423f40582b2a8b53d9ce1757'/>
<id>urn:sha1:6aed15e330bfec6a423f40582b2a8b53d9ce1757</id>
<content type='text'>
kfuncs are allowed to be static, or not use one or more of their
arguments. For example, bpf_xdp_metadata_rx_hash() in net/core/xdp.c is
meant to be implemented by drivers, with the default implementation just
returning -EOPNOTSUPP. As described in [0], such kfuncs can have their
arguments elided, which can cause BTF encoding to be skipped. The new
__bpf_kfunc macro should address this, and this patch adds a selftest
which verifies that a static kfunc with at least one unused argument can
still be encoded and invoked by a BPF program.

Signed-off-by: David Vernet &lt;void@manifault.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20230201173016.342758-5-void@manifault.com
</content>
</entry>
<entry>
<title>selftests/bpf: Add a sign-extension test for kfuncs</title>
<updated>2023-01-28T20:30:09Z</updated>
<author>
<name>Ilya Leoshkevich</name>
</author>
<published>2023-01-28T00:06:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=be6b5c10ecc4014446e5c807d6a69c5a7cc1c497'/>
<id>urn:sha1:be6b5c10ecc4014446e5c807d6a69c5a7cc1c497</id>
<content type='text'>
s390x ABI requires the caller to zero- or sign-extend the arguments.
eBPF already deals with zero-extension (by definition of its ABI), but
not with sign-extension.

Add a test to cover that potentially problematic area.

Signed-off-by: Ilya Leoshkevich &lt;iii@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20230128000650.1516334-15-iii@linux.ibm.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Add tests for kfunc returning a memory pointer</title>
<updated>2022-09-07T18:05:17Z</updated>
<author>
<name>Benjamin Tissoires</name>
</author>
<published>2022-09-06T15:13:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=22ed8d5a46520ef0f060e7c0ee91f1cc6f684400'/>
<id>urn:sha1:22ed8d5a46520ef0f060e7c0ee91f1cc6f684400</id>
<content type='text'>
We add 2 new kfuncs that are following the RET_PTR_TO_MEM
capability from the previous commit.
Then we test them in selftests:
the first tests are testing valid case, and are not failing,
and the later ones are actually preventing the program to be loaded
because they are wrong.

To work around that, we mark the failing ones as not autoloaded
(with SEC("?tc")), and we manually enable them one by one, ensuring
the verifier rejects them.

Signed-off-by: Benjamin Tissoires &lt;benjamin.tissoires@redhat.com&gt;
Link: https://lore.kernel.org/r/20220906151303.2780789-8-benjamin.tissoires@redhat.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: add test for accessing ctx from syscall program type</title>
<updated>2022-09-07T18:04:27Z</updated>
<author>
<name>Benjamin Tissoires</name>
</author>
<published>2022-09-06T15:13:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fb66223a244f252273995557b23e0fa53092e92c'/>
<id>urn:sha1:fb66223a244f252273995557b23e0fa53092e92c</id>
<content type='text'>
We need to also export the kfunc set to the syscall program type,
and then add a couple of eBPF programs that are testing those calls.

The first one checks for valid access, and the second one is OK
from a static analysis point of view but fails at run time because
we are trying to access outside of the allocated memory.

Signed-off-by: Benjamin Tissoires &lt;benjamin.tissoires@redhat.com&gt;
Link: https://lore.kernel.org/r/20220906151303.2780789-5-benjamin.tissoires@redhat.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: regroup and declare similar kfuncs selftests in an array</title>
<updated>2022-09-07T17:57:28Z</updated>
<author>
<name>Benjamin Tissoires</name>
</author>
<published>2022-09-06T15:12:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=012ba1156e4a7b38062d109b818cb479a68c87ba'/>
<id>urn:sha1:012ba1156e4a7b38062d109b818cb479a68c87ba</id>
<content type='text'>
Similar to tools/testing/selftests/bpf/prog_tests/dynptr.c:
we declare an array of tests that we run one by one in a for loop.

Followup patches will add more similar-ish tests, so avoid a lot of copy
paste by grouping the declaration in an array.

For light skeletons, we have to rely on the offsetof() macro so we can
statically declare which program we are using.
In the libbpf case, we can rely on bpf_object__find_program_by_name().
So also change the Makefile to generate both light skeletons and normal
ones.

Signed-off-by: Benjamin Tissoires &lt;benjamin.tissoires@redhat.com&gt;
Acked-by: Kumar Kartikeya Dwivedi &lt;memxor@gmail.com&gt;
Link: https://lore.kernel.org/r/20220906151303.2780789-2-benjamin.tissoires@redhat.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Fix spelling mistake.</title>
<updated>2022-08-19T19:45:14Z</updated>
<author>
<name>Colin Ian King</name>
</author>
<published>2022-08-17T21:32:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e918cd231ee6f1dc969e71718ed11c71e98f5c4c'/>
<id>urn:sha1:e918cd231ee6f1dc969e71718ed11c71e98f5c4c</id>
<content type='text'>
There is a spelling mistake in an ASSERT_OK literal string. Fix it.

Signed-off-by: Colin Ian King &lt;colin.i.king@gmail.com&gt;
Acked-by: Mykola Lysenko &lt;mykolal@fb.com&gt;
Link: https://lore.kernel.org/r/20220817213242.101277-1-colin.i.king@gmail.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: add destructive kfunc test</title>
<updated>2022-08-10T16:22:18Z</updated>
<author>
<name>Artem Savkov</name>
</author>
<published>2022-08-10T06:59:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e338945816754a1c362f606b8e2029f2c023e51c'/>
<id>urn:sha1:e338945816754a1c362f606b8e2029f2c023e51c</id>
<content type='text'>
Add a test checking that programs calling destructive kfuncs can only do
so if they have CAP_SYS_BOOT capabilities.

Signed-off-by: Artem Savkov &lt;asavkov@redhat.com&gt;
Link: https://lore.kernel.org/r/20220810065905.475418-4-asavkov@redhat.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
</feed>
