strndup_user(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 trailing NUL β€” 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:

like I said. long long. but every single one is iconic in its own way πŸ‘‘


bestie reminder: n counts the trailing NUL, and a failed call gives you an ERR_PTR, not a NULL. 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