Kernel
Installation
SKILL.md
Atomic Context Traps
spin_lockheld = cannot sleep — nokmalloc(GFP_KERNEL), nomutex_lock, nocopy_from_user- Interrupt can take same spinlock — must use
spin_lock_irqsave, not plainspin_lock rcu_read_lock()section cannot sleep — no blocking calls inside RCU read-sidemight_sleep()annotation — add to functions that may sleep, catches bugs withCONFIG_DEBUG_ATOMIC_SLEEP
Allocation Failures
GFP_ATOMICcan return NULL — always check, don't assume successvmallocmemory not physically contiguous — cannot use for DMAkzallocoverkmalloc— uninitialized memory leaks kernel info to userspace- Allocation in loop risks OOM — preallocate or use memory pool
User Pointer Handling
copy_from_userreturns bytes NOT copied — 0 means success, not failure- Never use
%swith user pointer in printk — kernel crash or info leak - User memory can change during syscall — copy to kernel buffer, validate the copy
__userannotation is documentation — doesn't enforce anything, you must use copy functions