bpf_copy_from_user_task_str(9)
π
bpf_copy_from_user_task_str β Kernel API Manual, bestie edition π
okay so this is the bpf_copy_from_user_task_str(9) page, and honestly? it's giving "small function, big responsibility" energy. stick with me and you'll get it β¨
πΈ NAME πΈ
bpf_copy_from_user_task_str β literally just copy a string out of a task's address space, no cap π«Ά
β¨ SYNOPSIS β¨
__bpf_kfunc int bpf_copy_from_user_task_str (void *dst , u32 dst__sz ,
const void __user *unsafe_ptr__ign , struct task_struct *tsk , u64 flags
);
look at her, five whole parameters, standing there being iconic π
π¦ ARGUMENTS π¦
dstβ the destination address, and it lives in kernel space babe. this buffer has to be at leastdst__szbytes long, so no funny business with tiny buffers, ok? πdst__szβ the max number of bytes to copy, and yes that count includes the trailing NUL. inclusive queen πunsafe_ptr__ignβ the source address, sitting all the way over in the task's address space. the name hasunsafein it so you already know π«Άtskβ the task whose address space is getting borrowed for this little operation πflagsβ and the only supported flag isBPF_F_PAD_ZEROS. that's it. that's the whole menu, periodt π
π DESCRIPTION π
so what she actually does: copies a NUL-terminated string from a task's address space into the dst__sz buffer. super straightforward, main character behavior π
if the user string is too long, she still makes sure there's a zero terminator inside the dst__sz buffer β the one exception is when the buffer size is 0. zero-size buffer, zero promises, that's the deal π
and if the BPF_F_PAD_ZEROS flag is set? two very specific moods:
- on success:
memsetthe tail ofdst__szto0π - on failure:
memsetall ofdst__szto0π
she's thorough like that π§
π RETURN π
- success β the number of copied bytes, and yes it includes the NUL terminator β
- failure β a negative error code π
π₯ SEE ALSO π₯
she runs with a whole squad β ngl this list is long and every single one of them made it:
Kernel file ./kernel/bpf/helpers.c, plus:
bpf_obj_new(9), bpf_percpu_obj_new(9), bpf_obj_drop(9), bpf_percpu_obj_drop(9), bpf_refcount_acquire(9), bpf_list_push_front(9), bpf_list_push_back(9), bpf_rbtree_add(9), bpf_task_acquire(9), bpf_task_release(9), bpf_cgroup_acquire(9), bpf_cgroup_release(9), bpf_cgroup_ancestor(9), bpf_cgroup_from_id(9), bpf_task_under_cgroup(9), bpf_task_get_cgroup1(9), bpf_task_from_pid(9), bpf_task_from_vpid(9), bpf_dynptr_slice(9), bpf_dynptr_slice_rdwr(9), bpf_dynptr_copy(9), bpf_dynptr_memset(9), bpf_iter_bits_new(9), bpf_iter_bits_next(9), bpf_iter_bits_destroy(9), bpf_copy_from_user_str(9), bpf_strcmp(9), bpf_strcasecmp(9), bpf_strnchr(9), bpf_strchr(9), bpf_strchrnul(9), bpf_strrchr(9), bpf_strnlen(9), bpf_strlen(9), bpf_strspn(9), bpf_strcspn(9), bpf_strstr(9), bpf_strcasestr(9), bpf_strnstr(9), bpf_strncasestr(9), bpf_lookup_user_key(9), bpf_lookup_system_key(9), bpf_key_put(9), bpf_verify_pkcs7_signature(9), bpf_task_work_schedule_signal(9), bpf_task_work_schedule_resume(9), bpf_timer_cancel_async(9)
ok that's the whole page bestie, go forth and copy those strings responsibly π
mwah π β this one came from ./kernel/bpf, dated October 2026, and she's filed under bpf_copy_from_user_task_str(9) in case you need to find her again π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms