__copy_to_user_inatomic(9)
๐
__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:
probe_subpage_writeable(9)copy_struct_from_user(9)copy_struct_to_user(9)get_kernel_nofault(9)__scoped_user_access_begin(9)__scoped_user_access(9)scoped_user_read_access_size(9)scoped_user_read_access(9)scoped_user_write_access_size(9)scoped_user_write_access(9)scoped_user_rw_access_size(9)scoped_user_rw_access(9)get_user_inline(9)put_user_inline(9)
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
- 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