__get_user(9)
π __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 β
0on success π-EFAULTon 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 π«Ά
- Kernel file
./arch/x86/include/asm/uaccess.h get_user(9)put_user(9)__put_user(9)
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
- 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