Skip to content

Commit

Permalink
bpf: Add bpf_copy_from_user_str kfunc
Browse files Browse the repository at this point in the history
This adds a kfunc wrapper around strncpy_from_user,
which can be called from sleepable BPF programs.

This matches the non-sleepable 'bpf_probe_read_user_str'
helper except it includes an additional 'flags'
param, which allows consumers to clear the entire
destination buffer on success or failure.

Signed-off-by: Jordan Rome <linux@jordanrome.com>
Link: https://lore.kernel.org/r/20240823195101.3621028-1-linux@jordanrome.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Jordan Rome authored and qmonnet committed Sep 2, 2024
1 parent 0db3e34 commit 07d9690
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -7512,4 +7512,13 @@ struct bpf_iter_num {
__u64 __opaque[1];
} __attribute__((aligned(8)));

/*
* Flags to control BPF kfunc behaviour.
* - BPF_F_PAD_ZEROS: Pad destination buffer with zeros. (See the respective
* helper documentation for details.)
*/
enum bpf_kfunc_flags {
BPF_F_PAD_ZEROS = (1ULL << 0),
};

#endif /* _UAPI__LINUX_BPF_H__ */

0 comments on commit 07d9690

Please sign in to comment.