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
5076 * associated to *xdp_md*, at *offset*.5076 * associated to *xdp_md*, at *offset*.
5077 * Return5077 * Return
5078 * 0 on success, or a negative error in case of failure.5078 * 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.
5079 */5089 */
5080#define __BPF_FUNC_MAPPER(FN) \5090#define __BPF_FUNC_MAPPER(FN) \
5081 FN(unspec), \5091 FN(unspec), \
@@ -5269,6 +5279,7 @@ union bpf_attr { · 187 unmodified lines
5269 FN(xdp_get_buff_len), \5279 FN(xdp_get_buff_len), \
5270 FN(xdp_load_bytes), \5280 FN(xdp_load_bytes), \
5271 FN(xdp_store_bytes), \5281 FN(xdp_store_bytes), \
5282 FN(copy_from_user_task), \
5272 /* */5283 /* */
5273 5284
5274/* integer value in 'imm' field of BPF_CALL instruction selects which helper5285/* 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