memdup_user_nul(9)
π memdup_user_nul(9) π
ok so bestie, you found it β the page for memdup_user_nul, straight out of the Kernel API Manual (section 9, kernel-space edition, we're fancy today π). This one's a little baby function that copies some bytes out of user space and makes sure the result is NUL-terminated. Ngl it's short, but it eats.
β¨ NAME β¨
memdup_user_nul β duplicate a memory region from user space and NUL-terminate it π«Ά
πΈ SYNOPSIS πΈ
void * memdup_user_nul (const void __user *src , size_t len );
π¦ ARGUMENTS π¦
srcβ the source address, and it lives in user space (yes, the__useris doing the heavy lifting here π).lenβ how many bytes we're copying, periodt.
β RETURN β
On failure you get an ERR_PTR back. That's the whole vibe the page gives us β it's literally the only thing documented under RETURN π so like, check the return value properly, IS_ERR() girlies know what's up. (The success return is not spelled out here, so I'm not gonna make it up for you π
.)
π₯ SEE ALSO π₯
- Kernel file
./mm/util.c kfree_const(9)__kmemdup_nul(9)kstrdup(9)kstrdup_const(9)kstrndup(9)kmemdup(9)kmemdup_array(9)kvmemdup(9)kmemdup_nul(9)memdup_user(9)vmemdup_user(9)strndup_user(9)randomize_page(9)__account_locked_vm(9)account_locked_vm(9)__vmalloc_array(9)vmalloc_array(9)__vcalloc(9)vcalloc(9)folio_mapping(9)folio_copy(9)get_cmdline(9)mem_dump_obj(9)compat_set_desc_from_vma(9)__compat_vma_mmap(9)compat_vma_mmap(9)snapshot_page(9)mmap_action_prepare(9)mmap_action_complete(9)folio_pte_batch(9)page_range_contiguous(9)
lowkey that's a whole friend group of memory-copying functions and I love that for them π
and that's the whole page, bestie β no cap, it's a short one π
this iconic little writeup lives under ./mm in the Kernel API Manual, dated October 2026 β mwah, see u in the next man page ππ§ββοΈ
π¦ 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