public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/3] Allow variable offsets for syscall PTR_TO_CTX
@ 2026-03-18 10:35 Kumar Kartikeya Dwivedi
  2026-03-18 10:35 ` [PATCH bpf-next v3 1/3] bpf: Support " Kumar Kartikeya Dwivedi
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-03-18 10:35 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Martin KaFai Lau, Eduard Zingerman, Tejun Heo, Dan Schatzberg,
	kkd, kernel-team

Enable pointer modification with variable offsets accumulated in the
register for PTR_TO_CTX for syscall programs where it won't be
rewritten, and the context is user-supplied and checked against the max
offset. See patches for details. Fixed offset support landed in [0].

By combining this set with [0], examples like the one below should
succeed verification now.

  SEC("syscall")
  int prog(void *ctx) {
	int *arr = ctx;
	int i;

	bpf_for(i, 0, 100)
		arr[i] *= i;

	return 0;
  }

  [0]: https://lore.kernel.org/bpf/20260227005725.1247305-1-memxor@gmail.com

Changelog:
----------
v2 -> v3
v2: https://lore.kernel.org/bpf/20260318075133.1031781-1-memxor@gmail.com

 * Prevent arg_type for KF_ARG_PTR_TO_CTX from applying to other cases
   due to preceding fallthrough. (Gemini/Sashiko)

v1 -> v2
v1: https://lore.kernel.org/bpf/20260317111850.2107846-2-memxor@gmail.com

 * Harden check_func_arg_reg_off check with ARG_PTR_TO_CTX.
 * Add tests for unmodified ctx into tail calls.
 * Squash unmodified ctx change into base commit.
 * Add Reviewed-by's from Emil.

Kumar Kartikeya Dwivedi (3):
  bpf: Support variable offsets for syscall PTR_TO_CTX
  selftests/bpf: Add syscall ctx variable offset tests
  selftests/bpf: Test modified syscall ctx for ARG_PTR_TO_CTX

 kernel/bpf/verifier.c                         |  67 ++--
 .../selftests/bpf/prog_tests/verifier.c       |  34 +-
 .../selftests/bpf/progs/verifier_ctx.c        | 356 +++++++++++++++---
 .../bpf/progs/verifier_global_subprogs.c      |  95 ++++-
 .../selftests/bpf/test_kmods/bpf_testmod.c    |   2 +-
 5 files changed, 462 insertions(+), 92 deletions(-)


base-commit: 77378dabb50f593c756d393d8eacb0b91b758863
-- 
2.52.0


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

end of thread, other threads:[~2026-03-18 23:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 10:35 [PATCH bpf-next v3 0/3] Allow variable offsets for syscall PTR_TO_CTX Kumar Kartikeya Dwivedi
2026-03-18 10:35 ` [PATCH bpf-next v3 1/3] bpf: Support " Kumar Kartikeya Dwivedi
2026-03-18 14:06   ` Mykyta Yatsenko
2026-03-18 21:59     ` Kumar Kartikeya Dwivedi
2026-03-18 21:13   ` Eduard Zingerman
2026-03-18 21:57     ` Kumar Kartikeya Dwivedi
2026-03-18 22:37       ` Eduard Zingerman
2026-03-18 23:33         ` Kumar Kartikeya Dwivedi
2026-03-18 23:43         ` Kumar Kartikeya Dwivedi
2026-03-18 10:35 ` [PATCH bpf-next v3 2/3] selftests/bpf: Add syscall ctx variable offset tests Kumar Kartikeya Dwivedi
2026-03-18 14:45   ` Mykyta Yatsenko
2026-03-18 21:41     ` Eduard Zingerman
2026-03-18 21:58       ` Kumar Kartikeya Dwivedi
2026-03-18 22:01     ` Kumar Kartikeya Dwivedi
2026-03-18 10:35 ` [PATCH bpf-next v3 3/3] selftests/bpf: Test modified syscall ctx for ARG_PTR_TO_CTX Kumar Kartikeya Dwivedi
2026-03-18 15:13   ` Mykyta Yatsenko
2026-03-18 11:45 ` [PATCH bpf-next v3 0/3] Allow variable offsets for syscall PTR_TO_CTX Puranjay Mohan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox