__get_user(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– __get_user (9) β€” from the Kernel API Manual, bestie πŸ’–

okay so. picture this: you're in the kernel, you've got a pointer that points into user space, and you need exactly one lil variable out of it. that's this macro. it's get_user's chill-but-reckless cousin β€” same job, less checking. iykyk. πŸ¦‹


✨ NAME ✨

__get_user β€” get a simple variable from user space, but with less checking. (yes, "less checking" is the whole personality. not me trusting you to do the checking yourself 😭)


πŸŽ€ SYNOPSIS πŸŽ€

__get_user (x , ptr );

πŸ’… ARGUMENTS πŸ’…

  • x β€” the variable where the result goes. this is your little receiving basket 🧺
  • ptr β€” the source address, and it lives in user space. (say it with me: user space) 🌈

🌸 CONTEXT 🌸

User context only. and heads up β€” this function may sleep if pagefaults are enabled. so like, don't go calling it from somewhere that can't handle a nap πŸ’€


πŸ”₯ DESCRIPTION πŸ”₯

this macro copies a single simple variable from user space into kernel space. one. single. variable. it's giving minimalism ✨

it supports simple types like char and int, but not larger data types like structures or arrays. no bundles, no vibes-collections, just one cute lil scalar πŸ“

ptr must have pointer-to-simple-variable type, and the result of dereferencing ptr must be assignable to x without a cast. like, it has to just fit. no forcing it. if you need a cast, the vibes are off and so is your code πŸ™ˆ

⚠️ okay this part is serious, bestie: the caller must check the pointer with access_ok before calling this function. that's the "less checking" tax. this macro is not gonna do it for you. you check it. periodt. πŸ‘‘

⭐ RETURN ⭐

  • 0 on success πŸŽ‰
  • -EFAULT on error πŸ’€

and on error, x is set to 0 β€” so it's never left all undefined and mysterious, which honestly? thoughtful. iconic behavior πŸ‘‘


🫢 SEE ALSO 🫢

like, go read the whole uaccess.h family, they're all main characters in this saga πŸ’œ


and that's the page!! brought to you by ./arch/x86/include/asm, dated October 2026 β€” mwah, go check your pointers, love u, bye!! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from