Duration
Linux Kernel Programming
4 days
Prerequisites
- C Language
- Linux Knowledge is Required
Module 1 – Introduction
- What is Device Driver
- What is Kernel Module
- Device Drivers vs Kernel Modules
- Types of Kernel Modules
- Basic Commands
- Hello World Kernel Module
- Printfs vs Printk
- Simplified Makefile
- What happens when run insmod
- What happens if we return -1 from Kernel Module Init Function
- Give another name to Kernel Module
- Kernel Module Span across Multiple C Files
- Two Kernel Modules from Single Makefile
- Dmesg in Deep
- Dmesg Follow Option
- Linux Kernel Module Example with module_init only
- Linux Kernel Module Example with module_exit only
- Two Line Linux Kernel Module
- Cross Compilation
Module 2 – Linux Kernel Module Internals
- From .c to .ko
- Understanding Module.symvers and modules.order
- Insmod vs Modprobe
- How Modprobe Calculates Dependencies
- Understanding module_init and module_exit functions
- Examples of gcc Attribute Alias
- Linux Kernel Module Example without module_init and module_exit Macro
Module 3 – Module Parameters
- Passing Parameters to Linux Kernel Modules
- What Happens if We Pass Incorrect Values to Module Parameters
- How to Pass parameters to Builtin Modules
- How to Pass String with Multiple Word as Parameter
- Passing Zero to Permission Argument of module_param macro
- Passing Array as Module Parameters
- Inv Bool
Module 4 – Exporting Symbols
- Symbol and Symbol Table
- Exporting Symbol
- System.map vs /proc/kallsyms
- Linux Kernel Module Example of Exporting Function
- Module Stacking
- Linux Kernel Module Example of Exporting Variable
- Version Magic
Module 5 – Module Licenses
- What Happens if We Don’t Specify MODULE_LICENSE macro
- What is Tainted Kernel
- How to Check Whether The Kernel is in Tainted State or Not
- What Happens When you Specify Invalid License
- What Happens When a Non-GPL Kernel Module Trying to Access GPL Module
Module 6 – Module Metadata
- How to Find Out Kernel Version from a .ko
- Module Metadata
- MODULE_INFO macro
- Objdump on Kernel Module
Module 7 – PrintK
- What Happens if We Continuously Call PrintK
- Printk Kernel Ring Buffer Size
- PrintK Log Levels
- Default PrintK Log Level
- Kernel Messages on Console
- Short PrintK Macros
- Enable pr_debug Messages
- Linux Kernel Module Example which Prints Floating Point Number
- Why Floating Point Unit is OFF in Kernel Space
- Limiting PrintK Messages – printk_rate_limit
- Limiting PrintK Messages – printk_once
- Avoiding Default New Linux Behaviour of PrintK
- Printing Hex Dump – print_hex_dump
- Printing Hex Dump – print_hex_dump_bytes
- Dynamic Debug
Module 8 – System Call for Loading Module
- What Happens if I Try to Load non-ko File with Insmod
- Strace on Insmod Command
- Find Out Name of Module from .ko
Module 9 – Kernel Panic, Oops, Bug
- How to Dump Kernel Stack
- What is Kernel Panic
- Kernel Panic Example
- What is Oops
- Oops Example
- What is BUG and Example
- Can we Remove Module After Bug/Oops
- How to Define Preprocessing Symbol in Makefile
Module 10 – Process Management in Linux Kernel
- How to Find Out How Many CPU’s are Present from User Space and Kernel Space
- Process Representation in Linux Kernel and Process States
- Linux Kernel Module Example Demonstrating Process Name, Process ID and Process
- Linux Kernel Module Example Demonstrating Current Macro
- Linux Kernel Module Which Accepts PID as Argument and prints Process and Parent
- Process Memory Map
- Linux Kernel Module Example for Printing Process Memory Map
Module 11 – Kernel Threads
- Introduction to Kernel Threads
- Kernel Thread Example – kthread_create
- Kernel Thread Example – kthread_run
- Two kernel Threads Example
- Can We Have Two Kernel Threads with Same Name
- What Happens If We Don’t Use kthread_should_stop() in Thread Function
- What Happens If We Don’t Call kthread_stop() in module_exit
- Print Process ID in Kernel Module
- Linux Kernel Thread Example of Race Condition
Module 12 – Module Support for Multiple Kernels
- LINUX_VERSION_CODE Macro
- KERNEL_VERSION Macro
- UTS_RELEASE
- Linux Kernel Module Example Supporting Multiple Versions
- Output of Pre-processed Stage
Programme scope, delivery arrangements and suitability are confirmed during enquiry.