Merge branch 'fix-caching-of-btf-for-kfuncs-in-the-verifier'
authorAlexei Starovoitov <ast@kernel.org>
Thu, 10 Oct 2024 17:44:03 +0000 (10:44 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 10 Oct 2024 17:44:28 +0000 (10:44 -0700)
commit3f2ac59c0d7b4d9f0e87371662a6ba8273b07818
treed4b574daade59bf0cb9fdbd5f76fbb680c34abf6
parent60f802e2d6e10df609a80962b13558b7455ab32b
parentf91b256644ea6f7628580029c5a223573f55d98c
Merge branch 'fix-caching-of-btf-for-kfuncs-in-the-verifier'

Toke Høiland-Jørgensen says:

====================
Fix caching of BTF for kfuncs in the verifier

When playing around with defining kfuncs in some custom modules, we
noticed that if a BPF program calls two functions with the same
signature in two different modules, the function from the wrong module
may sometimes end up being called. Whether this happens depends on the
order of the calls in the BPF program, which turns out to be due to the
use of sort() inside __find_kfunc_desc_btf() in the verifier code.

This series contains a fix for the issue (first patch), and a selftest
to trigger it (last patch). The middle commit is a small refactor to
expose the module loading helper functions in testing_helpers.c. See the
individual patch descriptions for more details.

Changes in v2:
- Drop patch that refactors module building in selftests (Alexei)
- Get rid of expect_val function argument in selftest (Jiri)
- Collect ACKs
- Link to v1: https://lore.kernel.org/r/20241008-fix-kfunc-btf-caching-for-modules-v1-0-dfefd9aa4318@redhat.com

====================

Link: https://lore.kernel.org/r/20241010-fix-kfunc-btf-caching-for-modules-v2-0-745af6c1af98@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>