copy_from_user_nmi(9)
β¨ copy_from_user_nmi(9) β¨
okay so bestie, welcome to the Kernel API Manual π β today's main character is copy_from_user_nmi, and she's lowkey iconic.
πΈ NAME πΈ
copy_from_user_nmi β NMI safe copy from user π
π SYNOPSIS π
unsigned long copy_from_user_nmi (void *to , const void __user *from ,
unsigned long n );
like, yes, that's the whole signature, no cap β¨
π¦ ARGUMENTS π¦
toβ pointer to the destination buffer, aka where the bytes are gonna land π«Άfromβ pointer to a user space address of the current task πnβ the number of bytes to copy, fr fr, that's literally it π
π RETURN π
she returns the number of not copied bytes π β so 0 means success, i.e. all bytes copied. slay π
π DESCRIPTION π
okay so here's the vibe check: contrary to other copy_from_user variants, this function can be called from NMI context π₯. And despite the name, she's not restricted to NMI context either β it's safe to be called from any other context as well, no gatekeeping here π§.
She disables pagefaults across the copy, which means a fault will abort the copy π β yes, like, mid-copy, done, no more bytes, periodt.
For NMI context invocations, this relies on the nested NMI work to allow atomic faults from the NMI path; the nested NMI paths are careful to preserve CR2 β. iykyk.
π« SEE ALSO π«
Kernel file ./arch/x86/lib/usercopy.c π
that's the whole page bestie, go read the source and stan π
with love from ./arch/x86/lib, dated October 2026, manual page copy_from_user_nmi(9) β mwah π
π¦ 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