History

bpf: Add bpf_copy_from_user_task() helper

This adds a helper for bpf programs to read the memory of other tasks. As an example use case at Meta, we are using a bpf task iterator program and this new helper to print C++ async stack traces for all threads of a given process.

Kenny Yu committed 4 years ago

Commit 376040e1 parent b77fb255 files · +59 −0Browse files

Showing the changes to include/uapi/linux (1 of 5 files). Show all

Unified · Split

include/uapi/linux/bpf.h+11−0
@@ -5076,6 +5076,16 @@ union bpf_attr { · 5075 unmodified lines
50765076 * associated to *xdp_md*, at *offset*.
50775077 * Return
50785078 * 0 on success, or a negative error in case of failure.
5079+ *
5080+ * long bpf_copy_from_user_task(void *dst, u32 size, const void *user_ptr, struct task_struct *tsk, u64 flags)
5081+ * Description
5082+ * Read *size* bytes from user space address *user_ptr* in *tsk*'s
5083+ * address space, and stores the data in *dst*. *flags* is not
5084+ * used yet and is provided for future extensibility. This helper
5085+ * can only be used by sleepable programs.
5086+ * Return
5087+ * 0 on success, or a negative error in case of failure. On error
5088+ * *dst* buffer is zeroed out.
50795089 */
50805090 #define __BPF_FUNC_MAPPER(FN) \
50815091 FN(unspec), \
@@ -5269,6 +5279,7 @@ union bpf_attr { · 187 unmodified lines
52695279 FN(xdp_get_buff_len), \
52705280 FN(xdp_load_bytes), \
52715281 FN(xdp_store_bytes), \
5282+ FN(copy_from_user_task), \
52725283 /* */
52735284
52745285 /* integer value in 'imm' field of BPF_CALL instruction selects which helper

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t