5,214,868 AI resources indexedWorking toward the world’s largest AI resource index.

PDF

Kernel

An MCP server that provides on-demand skill loading for AI coding assistants.

Installable skillMITBy modbenderUpdated Oct 31, 2026
INTENDED FORClaude CodeInstall in a listed agent.

instructions.md

---
name: kernel-b8678917bd9e
description: Avoid common Linux kernel mistakes β€” atomic context violations, allocation failures, and locking traps.
metadata: {"clawdbot":{"emoji":"🐧","os":["linux"]}}
---

## Atomic Context Traps
- `spin_lock` held = cannot sleep β€” no `kmalloc(GFP_KERNEL)`, no `mutex_lock`, no `copy_from_user`
- Interrupt can take same spinlock β€” must use `spin_lock_irqsave`, not plain `spin_lock`
- `rcu_read_lock()` section cannot sleep β€” no blocking calls inside RCU read-side
- `might_sleep()` annotation β€” add to functions that may sleep, catches bugs with `CONFIG_DEBUG_ATOMIC_SLEEP`

## Allocation Failures
- `GFP_ATOMIC` can return NULL β€” always check, don't assume success
- `vmalloc` memory not physically contiguous β€” cannot use for DMA
- `kzalloc` over `kmalloc` β€” uninitialized memory leaks kernel info to userspace
- Allocation in loop risks OOM β€” preallocate or use memory pool

## User Pointer Handling
- `copy_from_user` returns bytes NOT copied β€” 0 means success, not failure
- Never use `%s` with user pointer in printk β€” kernel crash or info leak
- User memory can change during syscall β€” copy to kernel buffer, validate the copy
- `__user` annotation is documentation β€” doesn't enforce anything, you must use copy functions

## Memory Ordering
- `READ_ONCE`/`WRITE_ONCE` for lockless shared data β€” prevents compiler from caching/reordering
- Spinlock release has implicit barrier β€” but check-then-act patterns still need care
- `smp_wmb()` before publishing pointer β€” ensures data visible before pointer is

## Module Error Paths
- Init fails midway β€” must undo everything already done
- Reverse order cleanup β€” unregister in opposite order of register
- `goto err_*` pattern standard β€” cleaner than nested ifs
- Check what's actually initialized β€” don't free/unregister what wasn't set up

## Locking Mistakes
- Same lock acquired twice = deadlock β€” even in different functions
- Inconsistent lock ordering β€” document order, acquire in same sequence everywhere
- `mutex_trylock` returns 1 on success β€” opposite of `pthread_mutex_trylock`
- Reader-writer locks rarely worth it β€” contention overhead usually exceeds benefit

Discuss this resource

Platform guidance

Imported from the listed AgentSkill.sh category. Complete supplied package files and notices are retained. Required external tools and credentials are not installed. No bundled code was executed during import. Individual agent task behavior has not been tested.