From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, kernel-team@fb.com,
yhs@fb.com, Eduard Zingerman <eddyz87@gmail.com>
Subject: [PATCH bpf-next 0/4] reduce BPF_ID_MAP_SIZE to fit only valid programs
Date: Sat, 17 Dec 2022 04:17:07 +0200 [thread overview]
Message-ID: <20221217021711.172247-1-eddyz87@gmail.com> (raw)
This is a follow-up for threads [1] and [2]:
- The size of the bpf_verifier_state->idmap_scratch array is reduced but
remains sufficient for any valid BPF program.
- selftests/bpf test_loader is updated to allow specifying that program
requires BPF_F_TEST_STATE_FREQ flag.
- Test case for the verifier.c:check_ids() update uses test_loader and is
meant as an example of using it for test_verifier-kind tests.
The combination of test_loader and naked functions (see [3]) with inline
assembly allows to write verifier tests easier than it is done currently
with BPF_RAW_INSN-series macros.
One can follow the steps below to add new tests of such kind:
- add a topic file under bpf/progs/ directory;
- define test programs using naked functions and inline assembly:
#include <linux/bpf.h>
#include "bpf_misc.h"
SEC(...)
__naked int foo_test(void)
{
asm volatile(
"r0 = 0;"
"exit;"
::: __clobber_all);
}
- add skeleton and runner functions in prog_tests/verifier.c:
#include "topic.skel.h"
TEST_SET(topic)
After these steps the test_progs binary would include the topic tests.
Topic tests could be selectively executed using the following command:
$ ./test_progs -vvv -a topic
These changes are suggested by Andrii Nakryiko.
[1] https://lore.kernel.org/bpf/CAEf4BzYN1JmY9t03pnCHc4actob80wkBz2vk90ihJCBzi8CT9w@mail.gmail.com/
[2] https://lore.kernel.org/bpf/CAEf4BzYPsDWdRgx+ND1wiKAB62P=WwoLhr2uWkbVpQfbHqi1oA@mail.gmail.com/
[3] https://gcc.gnu.org/onlinedocs/gcc/Basic-Asm.html#Basic-Asm
Eduard Zingerman (4):
selftests/bpf: support for BPF_F_TEST_STATE_FREQ in test_loader
selftests/bpf: convenience macro for use with 'asm volatile' blocks
bpf: reduce BPF_ID_MAP_SIZE to fit only valid programs
selftests/bpf: check if verifier.c:check_ids() handles 64+5 ids
include/linux/bpf_verifier.h | 4 +-
kernel/bpf/verifier.c | 6 +-
.../selftests/bpf/prog_tests/verifier.c | 12 +++
tools/testing/selftests/bpf/progs/bpf_misc.h | 7 ++
.../selftests/bpf/progs/check_ids_limits.c | 77 +++++++++++++++++++
tools/testing/selftests/bpf/test_loader.c | 10 +++
6 files changed, 112 insertions(+), 4 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/verifier.c
create mode 100644 tools/testing/selftests/bpf/progs/check_ids_limits.c
--
2.38.2
next reply other threads:[~2022-12-17 2:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-17 2:17 Eduard Zingerman [this message]
2022-12-17 2:17 ` [PATCH bpf-next 1/4] selftests/bpf: support for BPF_F_TEST_STATE_FREQ in test_loader Eduard Zingerman
2022-12-17 18:44 ` Yonghong Song
2022-12-20 21:03 ` Andrii Nakryiko
2022-12-22 0:11 ` Eduard Zingerman
2022-12-22 19:07 ` Andrii Nakryiko
2022-12-17 2:17 ` [PATCH bpf-next 2/4] selftests/bpf: convenience macro for use with 'asm volatile' blocks Eduard Zingerman
2022-12-17 18:58 ` Yonghong Song
2022-12-20 21:05 ` Andrii Nakryiko
2022-12-22 0:12 ` Eduard Zingerman
2022-12-17 2:17 ` [PATCH bpf-next 3/4] bpf: reduce BPF_ID_MAP_SIZE to fit only valid programs Eduard Zingerman
2022-12-17 18:59 ` Yonghong Song
2022-12-20 21:06 ` Andrii Nakryiko
2022-12-17 2:17 ` [PATCH bpf-next 4/4] selftests/bpf: check if verifier.c:check_ids() handles 64+5 ids Eduard Zingerman
2022-12-17 19:17 ` Yonghong Song
2022-12-20 21:18 ` Andrii Nakryiko
2022-12-22 0:33 ` Eduard Zingerman
2022-12-20 21:21 ` [PATCH bpf-next 0/4] reduce BPF_ID_MAP_SIZE to fit only valid programs Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221217021711.172247-1-eddyz87@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox