Unreliable Guide To Hacking The Linux Kernel
Table of Contents 1. Introduction................................................................................................................5 2. The Players .................................................................................................................6 2.1. User Context .....................................................................................................6 2.2. Hardware Interrupts (Hard IRQs) .....................................................................7 2.3. Software Interrupt Cont ext: Bottom Halves, Tasklets, softirqs ........................7 3. Some Basic Rules........................................................................................................9 4. ioctls: Not writing a new system call ......................................................................10 5. Recipes for Deadlock ...............................................................................................12 6. Common Routines....................................................................................................13 6.1. printk() include/linux/kernel.h.......................................................13 6.2. copy_[to/from]_user() / get_user() / put_user() include/asm/uaccess.h..........................................................................13 6.3. kmalloc()/kfree() include/linux/slab.h.........................................14 6.4. current include/asm/current.h...........................................................15 6.5. local_irq_save()/local_irq_restore() include/asm/system.h15 6.6. local_bh_disable()/local_bh_enable() include/asm/softirq.h 16 6.7. smp_processor_id()/cpu_[number/logical]_map() include/asm/smp.h...................................................................................16 6.8. __init/__exit/__initdata include/linux/init.h.......................................16 6.9. __initcall()/module_init() include/linux/init.h .....................17 6.10. module_exit() include/linux/init.h ..............................................17 6.11. MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT include/linux/module.h 18 7. Wait Queues include/linux/wait.h .................................................................20 7.1. Declaring.........................................................................................................20 7.2. Queuing...........................................................................................................20 7.3. Waking Up Queued Tasks...............................................................................20 8. Atomic Operations...................................................................................................22 9. Symbols .....................................................................................................................23 3 9.1. EXPORT_SYMBOL() include/linux/module.h........................................23 9.2. EXPORT_SYMTAB ............................................................................................23 10. Routines and Conventions.....................................................................................24 10.1. Double-linked lists include/linux/list.h............................................24 10.2. Return Conventions.......................................................................................24 10.3. Breaking Compilation...................................................................................24 10.4. Initializing structure members ......................................................................24 10.5. GNU Extensions ...........................................................................................25 10.6. C++ ...............................................................................................................26 10.7. #if ..................................................................................................................26 11. Putting Your Stuff in the Kernel...........................................................................27 12. Kernel Cantrips......................................................................................................29 13. Thanks.....................................................................................................................31
用户评论