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.
Showing the changes to include/uapi/linux (1 of 5 files). Show all
Unified · Split
| @@ -5076,6 +5076,16 @@ union bpf_attr { · 5075 unmodified lines | ||
| 5076 | 5076 | * associated to *xdp_md*, at *offset*. |
| 5077 | 5077 | * Return |
| 5078 | 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 | 5090 | #define __BPF_FUNC_MAPPER(FN) \ |
| 5081 | 5091 | FN(unspec), \ |
| @@ -5269,6 +5279,7 @@ union bpf_attr { · 187 unmodified lines | ||
| 5269 | 5279 | FN(xdp_get_buff_len), \ |
| 5270 | 5280 | FN(xdp_load_bytes), \ |
| 5271 | 5281 | FN(xdp_store_bytes), \ |
| 5282 | + FN(copy_from_user_task), \ | |
| 5272 | 5283 | /* */ |
| 5273 | 5284 | |
| 5274 | 5285 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |