[PATCH bpf-next v2 4/7] tools headers UAPI: Update tools's copy of bpf.h header
From: Levi Zim via B4 Relay
Date: Sat Jan 25 2025 - 03:31:02 EST
From: Levi Zim <rsworktech@xxxxxxxxxxx>
This update brings the new bpf_probe_read_{kernel,user} helpers
Signed-off-by: Levi Zim <rsworktech@xxxxxxxxxxx>
---
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