[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250125-bpf_dynptr_probe-v1-4-c3cb121f6951@outlook.com>
Date: Sat, 25 Jan 2025 16:23:39 +0800
From: Levi Zim via B4 Relay <devnull+rsworktech.outlook.com@...nel.org>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Matt Bobrowski <mattbobrowski@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>
Cc: bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
Andrii Nakryiko <andrii.nakryiko@...il.com>,
Levi Zim <rsworktech@...look.com>
Subject: [PATCH 4/7] tools headers UAPI: Update tools's copy of bpf.h
header
From: Levi Zim <rsworktech@...look.com>
This update brings the new bpf_probe_read_{kernel,user} helpers
Signed-off-by: Levi Zim <rsworktech@...look.com>
---
tools/include/uapi/linux/bpf.h | 49 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 2acf9b33637174bd16b1d12ccc6410c5f55a7ea9..f92cf809b50bc393d54eb0e8de2e1ce2a39e95d0 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -5805,6 +5805,52 @@ union bpf_attr {
* 0 on success.
*
* **-ENOENT** if the bpf_local_storage cannot be found.
+ *
+ * long bpf_probe_read_kernel_dynptr(const struct bpf_dynptr *dst, u32 offset, u32 size, const void *unsafe_ptr, u64 flags)
+ * Description
+ * Safely attempt to read *size* bytes from kernel space address
+ * *unsafe_ptr* and store the data in *dst* starting from *offset*.
+ * *flags* is currently unused.
+ * Return
+ * 0 on success.
+ *
+ * **-E2BIG** if *offset* + *len* exceeds the length of *src*'s data
+ *
+ * **-EINVAL** if *src* is an invalid dynptr or doesn't support this
+ * support this helper, or if *flags* is not 0.
+ *
+ * Or other negative errors on failure reading kernel memory.
+ *
+ * long bpf_probe_read_user_dynptr(const struct bpf_dynptr *dst, u32 offset, u32 size, const void *unsafe_ptr, u64 flags)
+ * Description
+ * Safely attempt to read *size* bytes from user space address
+ * *unsafe_ptr* and store the data in *dst* starting from *offset*.
+ * *flags* is currently unused.
+ * Return
+ * 0 on success.
+ *
+ * **-E2BIG** if *offset* + *len* exceeds the length of *src*'s data
+ *
+ * **-EINVAL** if *src* is an invalid dynptr or doesn't support this
+ * support this helper, or if *flags* is not 0.
+ *
+ * Or other negative errors on failure reading user space memory.
+ *
+ * long bpf_copy_from_user_dynptr(const struct bpf_dynptr *dst, u32 offset, u32 size, const void *user_ptr, u64 flags)
+ * Description
+ * Read *size* bytes from user space address *user_ptr* and store
+ * the data in *dst* starting from *offset*.
+ * This is a wrapper of **copy_from_user**\ ().
+ * *flags* is currently unused.
+ * Return
+ * 0 on success.
+ *
+ * **-E2BIG** if *offset* + *len* exceeds the length of *src*'s data
+ *
+ * **-EINVAL** if *src* is an invalid dynptr or doesn't support this
+ * support this helper, or if *flags* is not 0.
+ *
+ * Or other negative errors on failure reading user space memory.
*/
#define ___BPF_FUNC_MAPPER(FN, ctx...) \
FN(unspec, 0, ##ctx) \
@@ -6019,6 +6065,9 @@ union bpf_attr {
FN(user_ringbuf_drain, 209, ##ctx) \
FN(cgrp_storage_get, 210, ##ctx) \
FN(cgrp_storage_delete, 211, ##ctx) \
+ FN(probe_read_kernel_dynptr, 212, ##ctx) \
+ FN(probe_read_user_dynptr, 213, ##ctx) \
+ FN(copy_from_user_dynptr, 214, ##ctx) \
/* */
/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
--
2.48.1
Powered by blists - more mailing lists