diff options
author | Florent Revest <revest@chromium.org> | 2021-04-19 17:52:40 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-04-19 15:27:36 -0700 |
commit | 7b15523a989b63927c2bb08e9b5b0bbc10b58bef (patch) | |
tree | d74e1482dfa030476a1666909b83f0da10a1757c /include/linux/bpf.h | |
parent | fff13c4bb646ef849fd74ced87eef54340d28c21 (diff) | |
download | linux-stable-7b15523a989b63927c2bb08e9b5b0bbc10b58bef.tar.gz linux-stable-7b15523a989b63927c2bb08e9b5b0bbc10b58bef.tar.bz2 linux-stable-7b15523a989b63927c2bb08e9b5b0bbc10b58bef.zip |
bpf: Add a bpf_snprintf helper
The implementation takes inspiration from the existing bpf_trace_printk
helper but there are a few differences:
To allow for a large number of format-specifiers, parameters are
provided in an array, like in bpf_seq_printf.
Because the output string takes two arguments and the array of
parameters also takes two arguments, the format string needs to fit in
one argument. Thankfully, ARG_PTR_TO_CONST_STR is guaranteed to point to
a zero-terminated read-only map so we don't need a format string length
arg.
Because the format-string is known at verification time, we also do
a first pass of format string validation in the verifier logic. This
makes debugging easier.
Signed-off-by: Florent Revest <revest@chromium.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210419155243.1632274-4-revest@chromium.org
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r-- | include/linux/bpf.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index c160526fc8bf..f8a45f109e96 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1953,6 +1953,7 @@ extern const struct bpf_func_proto bpf_skc_to_tcp_request_sock_proto; extern const struct bpf_func_proto bpf_skc_to_udp6_sock_proto; extern const struct bpf_func_proto bpf_copy_from_user_proto; extern const struct bpf_func_proto bpf_snprintf_btf_proto; +extern const struct bpf_func_proto bpf_snprintf_proto; extern const struct bpf_func_proto bpf_per_cpu_ptr_proto; extern const struct bpf_func_proto bpf_this_cpu_ptr_proto; extern const struct bpf_func_proto bpf_ktime_get_coarse_ns_proto; |