__put_user(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 __put_user(9) 🌸

hey bestie, welcome to the Kernel API Manual β€” today’s main character is __put_user(9), and she is lowkey here to write one simple value into user space with less checking. no cap. 🫢


✨ NAME ✨

__put_user β€” write a simple value into user space, with less checking. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

__put_user (x , ptr );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • x β€” the value to copy to user space. literally the thing being sent over. πŸ’Œ
  • ptr β€” the destination address, in user space. that’s where x is going, bestie. πŸ“

πŸ’œ CONTEXT πŸ’œ

user context only, okay? πŸ‘‘ this function may sleep if pagefaults are enabled β€” so don’t be weird about it. 😴


πŸ’– DESCRIPTION πŸ’–

okay so this macro copies a single simple value from kernel space to user space. it supports simple types like char and int, but not larger data types like structures or arrays β€” so leave your big complicated faves at home, this is a one-value situation. ✨

ptr must have pointer-to-simple-variable type, and x must be assignable to the result of dereferencing ptr. that’s the vibe check for the types, fr fr. 🧚

🚨 caller must check the pointer with access_ok before calling this function. not optional, bestie β€” do the check first. πŸ’€

πŸ”₯ RETURN πŸ”₯

zero on success, or -EFAULT on error. that’s it, that’s the whole report card. 😭


🌈 SEE ALSO 🌈


catch u later, mwah πŸ’… β€” this cutie came from ./arch/x86/include/asm, October 2026, and yes she ate. πŸ“πŸ‘‘

πŸ“¦ where this page comes from