summaryrefslogtreecommitdiffstats
path: root/tools/include
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2020-08-27 15:01:12 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2020-08-28 21:20:33 +0200
commit07be4c4a3e7a0db148e44b16c5190e753d1c8569 (patch)
tree6069d0aed091b6505371ef8e405a6c5c7efd4c1c /tools/include
parent1e6c62a8821557720a9b2ea9617359b264f2f67c (diff)
downloadlinux-07be4c4a3e7a0db148e44b16c5190e753d1c8569.tar.gz
linux-07be4c4a3e7a0db148e44b16c5190e753d1c8569.tar.bz2
linux-07be4c4a3e7a0db148e44b16c5190e753d1c8569.zip
bpf: Add bpf_copy_from_user() helper.
Sleepable BPF programs can now use copy_from_user() to access user memory. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: KP Singh <kpsingh@google.com> Link: https://lore.kernel.org/bpf/20200827220114.69225-4-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/uapi/linux/bpf.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 6e8b706aeb05..a613750d5515 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -3569,6 +3569,13 @@ union bpf_attr {
* On success, the strictly positive length of the string,
* including the trailing NUL character. On error, a negative
* value.
+ *
+ * long bpf_copy_from_user(void *dst, u32 size, const void *user_ptr)
+ * Description
+ * Read *size* bytes from user space address *user_ptr* and store
+ * the data in *dst*. This is a wrapper of copy_from_user().
+ * Return
+ * 0 on success, or a negative error in case of failure.
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -3719,6 +3726,7 @@ union bpf_attr {
FN(inode_storage_get), \
FN(inode_storage_delete), \
FN(d_path), \
+ FN(copy_from_user), \
/* */
/* integer value in 'imm' field of BPF_CALL instruction selects which helper