bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC bpf-next 0/3] bpf: handle 0-sized structs properly
@ 2025-05-08 13:22 Alan Maguire
  2025-05-08 13:22 ` [RFC bpf-next 1/3] libbpf: update BPF_PROG2() to handle empty structs Alan Maguire
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Alan Maguire @ 2025-05-08 13:22 UTC (permalink / raw)
  To: martin.lau, ast, andrii, tony.ambardar, alexis.lothore
  Cc: eddyz87, song, yonghong.song, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, mykolal, bpf, dwarves, Alan Maguire

When testing v1 of [1] we noticed that functions with 0-sized structs
as parameters were not part of BTF encoding; this was fixed in v2.
However we need to make sure we handle such zero-sized structs
correctly since they confound the calling convention expectations -
no registers are used for the empty struct so this has knock-on effects
for subsequent register-parameter matching.

Patch 1 updates BPF_PROG2() to handle the zero-sized struct case.
Patch 2 makes 0-sized structs a special case, allowing them to exist
as parameter representations in BTF without failing verification.
Patch 3 is a selftest that ensures the parameters after the 0-sized
struct are represented correctly.

[1] https://lore.kernel.org/dwarves/20250502070318.1561924-1-tony.ambardar@gmail.com/

Alan Maguire (3):
  libbpf: update BPF_PROG2() to handle empty structs
  bpf: allow 0-sized structs as function parameters
  selftests/bpf: add 0-length struct testing to tracing_struct tests

 kernel/bpf/btf.c                                     |  2 +-
 tools/lib/bpf/bpf_tracing.h                          |  6 ++++--
 .../selftests/bpf/prog_tests/tracing_struct.c        |  2 ++
 tools/testing/selftests/bpf/progs/tracing_struct.c   | 11 +++++++++++
 tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 12 ++++++++++++
 5 files changed, 30 insertions(+), 3 deletions(-)

-- 
2.39.3


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

end of thread, other threads:[~2025-05-21  0:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 13:22 [RFC bpf-next 0/3] bpf: handle 0-sized structs properly Alan Maguire
2025-05-08 13:22 ` [RFC bpf-next 1/3] libbpf: update BPF_PROG2() to handle empty structs Alan Maguire
2025-05-08 13:45   ` Alan Maguire
2025-05-08 13:22 ` [RFC bpf-next 2/3] bpf: allow 0-sized structs as function parameters Alan Maguire
2025-05-08 13:22 ` [RFC bpf-next 3/3] selftests/bpf: add 0-length struct testing to tracing_struct tests Alan Maguire
2025-05-09 18:40 ` [RFC bpf-next 0/3] bpf: handle 0-sized structs properly Andrii Nakryiko
2025-05-12  9:17   ` Tony Ambardar
2025-05-14 10:30     ` Alan Maguire
2025-05-14 16:22       ` Andrii Nakryiko
2025-05-15  8:02         ` Tony Ambardar
2025-05-15 16:23           ` Andrii Nakryiko
2025-05-15 10:56   ` Alan Maguire
2025-05-20  8:59     ` Alan Maguire
2025-05-21  0:58       ` Tony Ambardar

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).