linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] bpf: Specify access type of bpf_sysctl_get_name args
@ 2025-06-19 14:06 Jerome Marchand
  2025-06-19 14:06 ` [PATCH v3 1/2] " Jerome Marchand
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jerome Marchand @ 2025-06-19 14:06 UTC (permalink / raw)
  To: bpf
  Cc: Martin KaFai Lau, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Yonghong Song, Eduard Zingerman, linux-kernel,
	Jerome Marchand

The second argument of bpf_sysctl_get_name() helper is a pointer to a
buffer that is being written to. However that isn't specify in the
prototype. Until commit 37cce22dbd51a ("bpf: verifier: Refactor helper
access type tracking") that mistake was hidden by the way the verifier
treated helper accesses. Since then, the verifier, working on wrong
infromation from the prototype, can make faulty optimization that
would had been caught by the test_sysctl selftests if it was run by
the CI.

The first patch fixes bpf_sysctl_get_name prototype.

The second patch converts the test_sysctl to prog_tests so that it
will be run by the CI and catch similar issues in the future.

Changes in v3:
 - Use ASSERT* macro instead of CHECK_FAIL.
 - Remove useless code.

Changes in v2:
 - Replace ARG_PTR_TO_UNINIT_MEM by ARG_PTR_TO_MEM | MEM_WRITE.
 - Converts test_sysctl to prog_tests.

Jerome Marchand (2):
  bpf: Specify access type of bpf_sysctl_get_name args
  selftests/bpf: Convert test_sysctl to prog_tests

 kernel/bpf/cgroup.c                           |  2 +-
 tools/testing/selftests/bpf/.gitignore        |  1 -
 tools/testing/selftests/bpf/Makefile          |  5 +--
 .../bpf/{ => prog_tests}/test_sysctl.c        | 37 ++++---------------
 4 files changed, 11 insertions(+), 34 deletions(-)
 rename tools/testing/selftests/bpf/{ => prog_tests}/test_sysctl.c (98%)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-06-24  4:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 14:06 [PATCH v3 0/2] bpf: Specify access type of bpf_sysctl_get_name args Jerome Marchand
2025-06-19 14:06 ` [PATCH v3 1/2] " Jerome Marchand
2025-06-19 17:32   ` Yonghong Song
2025-06-19 14:06 ` [PATCH v3 2/2] selftests/bpf: Convert test_sysctl to prog_tests Jerome Marchand
2025-06-19 17:33   ` Yonghong Song
2025-06-24  5:00 ` [PATCH v3 0/2] bpf: Specify access type of bpf_sysctl_get_name args patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).