bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/5] Add a snprintf eBPF helper
@ 2021-03-10 22:02 Florent Revest
  2021-03-10 22:02 ` [PATCH bpf-next 1/5] bpf: Add a ARG_PTR_TO_CONST_STR argument type Florent Revest
                   ` (4 more replies)
  0 siblings, 5 replies; 27+ messages in thread
From: Florent Revest @ 2021-03-10 22:02 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, yhs, kpsingh, jackmanb, linux-kernel,
	Florent Revest

We have a usecase where we want to audit symbol names (if available) in
callback registration hooks. (ex: fentry/nf_register_net_hook)

A few months back, I proposed a bpf_kallsyms_lookup series but it was
decided in the reviews that a more generic helper, bpf_snprintf, would
be more useful.

This series implements the helper according to the feedback received in
https://lore.kernel.org/bpf/20201126165748.1748417-1-revest@google.com/T/#u

- A new arg type guarantees the NULL-termination of string arguments and
  lets us pass format strings in only one arg
- A new helper is implemented using that guarantee. Because the format
  string is known at verification time, the format string validation is
  done by the verifier
- To implement a series of tests for bpf_snprintf, the logic for
  marshalling variadic args in a fixed-size array is reworked as per:
https://lore.kernel.org/bpf/20210310015455.1095207-1-revest@chromium.org/T/#u

Florent Revest (5):
  bpf: Add a ARG_PTR_TO_CONST_STR argument type
  bpf: Add a bpf_snprintf helper
  libbpf: Initialize the bpf_seq_printf parameters array field by field
  libbpf: Introduce a BPF_SNPRINTF helper macro
  selftests/bpf: Add a series of tests for bpf_snprintf

 include/linux/bpf.h                           |   5 +
 include/uapi/linux/bpf.h                      |  28 +++
 kernel/bpf/verifier.c                         | 178 ++++++++++++++++++
 kernel/trace/bpf_trace.c                      | 110 +++++++++++
 tools/include/uapi/linux/bpf.h                |  28 +++
 tools/lib/bpf/bpf_tracing.h                   |  45 ++++-
 .../selftests/bpf/prog_tests/snprintf.c       |  71 +++++++
 .../selftests/bpf/progs/test_snprintf.c       |  71 +++++++
 8 files changed, 535 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/snprintf.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_snprintf.c

-- 
2.30.1.766.gb4fecdf3b7-goog


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

end of thread, other threads:[~2021-03-23 14:05 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 22:02 [PATCH bpf-next 0/5] Add a snprintf eBPF helper Florent Revest
2021-03-10 22:02 ` [PATCH bpf-next 1/5] bpf: Add a ARG_PTR_TO_CONST_STR argument type Florent Revest
2021-03-11  0:04   ` kernel test robot
2021-03-11  1:00   ` kernel test robot
2021-03-16  1:03   ` Andrii Nakryiko
2021-03-16 23:58     ` Florent Revest
2021-03-17  0:35       ` Andrii Nakryiko
2021-03-17  0:45         ` Florent Revest
2021-03-17  1:02           ` Andrii Nakryiko
2021-03-17 10:32             ` Florent Revest
2021-03-10 22:02 ` [PATCH bpf-next 2/5] bpf: Add a bpf_snprintf helper Florent Revest
2021-03-11  0:14   ` kernel test robot
2021-03-11  3:12   ` kernel test robot
2021-03-11  3:12   ` [RFC PATCH] bpf: check_bpf_snprintf_call() can be static kernel test robot
2021-03-16  1:25   ` [PATCH bpf-next 2/5] bpf: Add a bpf_snprintf helper Andrii Nakryiko
2021-03-16 13:18     ` Florent Revest
2021-03-23  3:21   ` Alexei Starovoitov
2021-03-23 14:04     ` Florent Revest
2021-03-10 22:02 ` [PATCH bpf-next 3/5] libbpf: Initialize the bpf_seq_printf parameters array field by field Florent Revest
2021-03-16  4:36   ` Andrii Nakryiko
2021-03-16  4:41     ` Andrii Nakryiko
2021-03-16 22:43     ` Florent Revest
2021-03-16 23:06       ` Andrii Nakryiko
2021-03-10 22:02 ` [PATCH bpf-next 4/5] libbpf: Introduce a BPF_SNPRINTF helper macro Florent Revest
2021-03-16  4:39   ` Andrii Nakryiko
2021-03-10 22:02 ` [PATCH bpf-next 5/5] selftests/bpf: Add a series of tests for bpf_snprintf Florent Revest
2021-03-16  4:49   ` Andrii Nakryiko

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