System Calls in deep

Linux Kernel Programming - System calls

4.00 (18 reviews)
Udemy
platform
English
language
Operating Systems
category
instructor
System Calls in deep
444
students
5 hours
content
Apr 2021
last update
$54.99
regular price

What you will learn

Basics of Inline Assembly

Writing examples for Inline Assembly

Various places where inline assembly is used

Adding a new system call to kernel

Updating system call table

VDSO and Virtual System Calls

Description

What will you learn from this course?

  • Basics of Inline Assembly

  • Types of Inline Assembly: Basic and Extended

  • GCC Assembly Syntax: AT&T

  • Constraint strings

  • Input and output operands

  • Clobbering

  • Various use cases of Inline assembly in Linux kernel: Interrupts, I/O Ports, Atomic operations, CPUID, Control Registers, Timestamp counters etc

  • Deep understanding of system calls: Various ways of switching from user space to kernel space (int $0x80, sysenter/sysexit, syscall/sysret)

  • VDSO

  • Adding a new system call which doesn't accept any arguments

  • Adding a system call which accept argument

  • Kernel Symbols and Kernel Symbol table

  • Writing a kernel module which overwrite the kernel symbol table

  • Writing a kernel module which sniffs the parameters passed to a system call

Examples covered in this course:

  • Add two numbers in inline assembly

  • Add three numbers in inline assembly

  • Subtract, divide, multiply in inline assembly

  • Can we disable/enable interrupts in user space

  • Checking whether interrupts are enabled and disabled in user space

  • Enabling/Disabling interrupts in user space

  • Implementing simple locking to avoid race conditions: Lock prefix, compare and exchange instructions

  • And many

Content

Inline Assembly

Introduction to Inline Assembly
Example of speed with Inline Assembly
x86_64 Registers
GCC Basic Assembly Example
GCC Assembly Syntax
Extended Format
Output operand
Constraint string
Example of extended assembly
Example of extended assembly 2
What if i only have input operands
Debugging Inline assembly using gdb
Inline assembly example for add,sub,mul and div
Inline assembly example for accessing memory
Immediate integer operand
Example of immediate integer operand
Example of printing stack pointer
Matching constraints
Clobberring
Example of cloberring
Special specifiers in clobbering section
Immediate I
More constraints
More Example of Inline Assembly

Linux Kernel Inline Assembly Examples

Implementation of enable and disable interrupt
Implementation of irqs_disabled()
Implementation of saving and restore flags
Can we read EFLAGS register from userspace
Can we enable disable interrupts from userspace
Will cli disable interrupts on other processors
Halt Instruction
Instructions for accessing I/O Ports
iopl
What happens to flag register when we call iopl
Enabling and disabling interrupts from userspace
Atomic operations
Atomic Increment and decrement
Example and solution of race condition
Locking technique for multiple instructions
CPUID
Processor Info and Feature bits
Reading Timestamp counter
Control Register 0
Control Registers in Oops
MSR
CPU_RELAX

Introduction to System Calls

What is System call
What happens inside a system call
Why do we need system calls
Current Privilege Level
Difference between system call and function call
System call number and system call table
Passing Parameters
int $0x80
entry_INT80_32
Example of int $0x80
Problem with int $0x80
Fast System calls
Sysenter and sysexit
kernel_vsyscall
ELF Auxiliary Vectors
kernel_vsyscall from inline assembly
64-bit fast system calls
dump_stack in module init
syscall instruction from inline assembly
How system call is executed in other architectures
Return value of system call
syscall library function
What happens when we pass a system call number which is not implemented

VDSO

Introduction to VDSO
Example of VDSO
strace on vdso
Where is linux-vdso.so present
vsyscalls

Adding a new system call

SYSCALL_DEFINEn
Example of SYSCALL_DEFINEn
asmlinkage
How userspace reaches sys_read
Adding a new system call
Return value of system calls
Adding a system call accepting argument
What happens if i pass a different type of argument
Generic System call table
What happens when we compile user space app for 32 bit
How is ia32_sys_hello map to x64_sys_hello
System call Table
Compatibility System calls

Kernel Symbols

Kernel Symbols and Kernel Symbol table
How do you find out whether a function is static or global
A peek inside LKM
kallsyms_lookup_name
Dynamically find the address at which the kernel is loaded
kallsyms_on_each_symbol
Finding the size of kernel function
Use function pointer returned by kallsysms_lookup_name
Can we access non exported symbols
Can we update symbol address
Updating system call table
Access the parameters passed to system call

Reviews

William
September 6, 2023
The class information is excellent. Well written content by a knowledgeable instructor. The audio quality is terrible, and there are no subtitles available, which is frustrating because the sound you can make out sounds like a great instructor. I would not recommend to most because of this. I will edit and improve rating if sound quality is improved and CC are enabled.
Madhuresh
July 23, 2023
The audio quality is really poor and it's really difficult to make out what is being said. The content is kind of okey but it makes refrences to other course of the educator since this is a part of much larger course and is the trimmed out version of it. The educator has cut out chunks of a big course and made them into mini course. Hence it is not self contained.

Charts

Price

System Calls in deep - Price chart

Rating

System Calls in deep - Ratings chart

Enrollment distribution

System Calls in deep - Distribution chart

Related Topics

3503668
udemy ID
9/16/2020
course created date
1/21/2021
course indexed date
Bot
course submited by