strndup_user(9)
π strndup_user(9) π
okay so bestie, welcome to the strndup_user page from the Kernel API Manual β yes, that's <italic>9</italic>, the kernel developer section, we're in the big leagues now π«Ά
β¨ NAME β¨
strndup_user β duplicate an existing string from user space π
like yeah, it copies a string for you, but the string lives in user space and you're over here in kernel land, so it's a whole thing, iykyk π¦
πΈ SYNOPSIS πΈ
char * strndup_user (const char __user *s , long n );
π ARGUMENTS π
sβ the string you wanna duplicate, babes. that's the one. the source. the moment. β¨nβ maximum number of bytes to copy, and yes this includes the trailingNULβ do not forget the NUL, the NUL is part of the count, no cap π
π RETURN π
a newly allocated copy of s π β or, plot twist, an ERR_PTR in case of error π so like, always check that bad boy before you dereference it, fr fr.
π SEE ALSO π
okay this list is long long, so buckle up bestie, we're going on a journey through the kernel:
- 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)memdup_user_nul(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)
like I said. long long. but every single one is iconic in its own way π
bestie reminder:ncounts the trailingNUL, and a failed call gives you anERR_PTR, not aNULL. check it properly or the kernel will simply not be slaying anymore π
that's the whole page, bestie, go forth and duplicate responsibly π§ from the ./mm corner of the source tree, dated October 2026, signing off as your girl strndup_user(9) β mwah ππ
π¦ 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