__copy_to_user_inatomic(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… __copy_to_user_inatomic โœจ

okay bestie, welcome to the Kernel API Manual ๐ŸŽ€ โ€” today's main character is __copy_to_user_inatomic, and honestly? she's iconic, but she comes with โœจrulesโœจ so let's get into it ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

__copy_to_user_inatomic โ€” copy a block of data into user space, with less checking ๐Ÿ’ซ

like yes, she copies, but she does not do the whole security-check routine for you. you're on your own for that part, bestie ๐Ÿ˜ญ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

unsigned long __copy_to_user_inatomic (void __user *to , const void *from , unsigned long n );

that's the whole vibe. three args, one unsigned long coming back at you ๐Ÿ’œ


๐Ÿ“ ARGUMENTS ๐Ÿ“

  • to โ€” the destination address, and it lives in user space. that's where the data's going, periodt ๐Ÿ’…
  • from โ€” the source address, and this one's in kernel space. that's where the data's coming from ๐ŸŒˆ
  • n โ€” number of bytes to copy. literally just how much you're moving, no cap ๐Ÿ”ฅ

๐Ÿงš CONTEXT ๐Ÿงš

User context only. ๐Ÿšจ

that's it. that's the whole rule. do not try this anywhere else, i'm begging ๐Ÿ™ˆ


โญ DESCRIPTION โญ

so basically: you're copying data from kernel space to user space ๐Ÿ’–

but here's the thing โ€” the caller must check the specified block with access_ok before calling this function. like, that's not optional, that's the whole assignment, bestie ๐Ÿ“

the caller should also make sure he pins the user space address, so that we don't result in page fault and sleep ๐Ÿ˜ด๐Ÿ’€ โ€” like, we are literally not trying to fall asleep mid-copy in an atomic context, that would be a whole mess ๐Ÿซ 


๐Ÿ”ฎ SEE ALSO ๐Ÿ”ฎ

go check out the kernel file ./include/linux/uaccess.h for the lore ๐Ÿ“– plus all these other icons:


and that's the tea ๐Ÿต this little page lives in ./include/linux and it's dated October 2026 โ€” so yeah, she's from the future, slay ๐Ÿ‘‘โœจ mwah, study up and stay safe out there ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from