THE LINUX KERNEL THE LINUX KERNEL One PR PROG OGRAM t to r rule - - PowerPoint PPT Presentation

the linux kernel the linux kernel
SMART_READER_LITE
LIVE PREVIEW

THE LINUX KERNEL THE LINUX KERNEL One PR PROG OGRAM t to r rule - - PowerPoint PPT Presentation

THE LINUX KERNEL THE LINUX KERNEL One PR PROG OGRAM t to r rule t them a all ll, , One PROGRAM to rule them all, one PR PROG OGRAM t to fin find t them, , one PROGRAM to find them, one PR PROG OGRAM t to bring t g them a m


slide-1
SLIDE 1

One PROGRAM to rule them all, One PR PROG OGRAM t to r rule t them a all ll, ,

  • ne PROGRAM to find them,
  • ne PR

PROG OGRAM t to fin find t them, ,

  • ne PROGRAM to bring them all,
  • ne PR

PROG OGRAM t to bring t g them a m all, l, and in the darkness bind them and in in t the d darkness b bin ind t them

THE LINUX KERNEL THE LINUX KERNEL

slide-2
SLIDE 2

What is the GNU/Linux Kernel?

  • It is a program
  • It has PID 0 !!!!
  • It has absolute power and control
  • It is composed of different layers
  • It is reentrant
  • It is preemptive (finally ;-) !!!)
  • It is running all the time in Ring 0
slide-3
SLIDE 3

A peek inside the GNU/Linux Kernel

slide-4
SLIDE 4

The GNU/Linux kernel compiling process

  • Get the sources
  • Set the options
  • Make the image
  • Make and install the modules
  • Copy the new Kernel to /boot directory
  • Make the initrd, if needed.
  • Update your Boot Loader's config file
  • ... and keep your fingers crossed !!!!
slide-5
SLIDE 5

Make menuconfig screen

slide-6
SLIDE 6

Altering an initrd image file:

# gunzip -f -S "" -c /boot/initrd.img-2.6.18-test > /boot/initrd.img-2.6.18-test-gunzipped # file /boot/initrd.img-2.6.18-test-gunzipped /boot/initrd.img-2.6.18-test-gunzipped: ASCII cpio archive ... # mkdir /tmp/initrd # cd /tmp/initrd # cat /boot/initrd.img-2.6.18-test-gunzipped | cpio -id 20505 blocks # ls -l bin conf etc init lib modules sbin scripts

Building the initrd image file

# find ./ | cpio -H newc -o > /tmp/new-initrd.cpio 20505 blocks # gzip -c /tmp/new-initrd.cpio > /boot/initrd.img-2.6.18-test

slide-7
SLIDE 7

Personalising initrd: A quick example init:

... echo -ne "TCG: please, insert the module parameters for mymodule: \>" read marg load modules $marg ...

scripts/functions:

... if [ "$m" = "mymodule" ]; then echo -ne "\t Personalised module $m with arg $marg \n" Do some tasks ... else modprobe -q $m fi ... # echo “mymodule” >> conf/modules

slide-8
SLIDE 8

...as a result:

? ? ? ? ? ? ? ? ? ?

slide-9
SLIDE 9

The GNU/Linux Kernel's exported symbol table /proc/kallsyms ... c0102b7f t check userspace c0102b94 T resume userspace c0102bac T sysenter entry c0102bb3 t sysenter past esp c0102c2c T system call c0102c55 t no singlestep c0102c6c t syscall call c0102c77 t syscall exit c0102c86 t restore all c0102c9e t restore nocheck c0102c9e t restore nocheck notrace ...

slide-10
SLIDE 10

An ELF module object unkown symbols list

# nm kmodest.ko ... 00000004 B bytes to read 00000000 T cleanup module U copy from user U copy to user 00000000 D current cmd U do fsync 00000557 T do_insert_fd 000003b2 T do_remap_fd 0000043c T do_restore_task 0000028c T fd_deinstall_by_task 000002f6 T fd_install_by_task 00000020 B fds_info 0000003d T fill_file_information ...

+

=

slide-11
SLIDE 11

Exporting a symbol “by hand”

# insmod ./kmodest.ko insmod: error inserting ’./kmodest.ko’: -1 Unknown symbol in module # dmesg|tail -3 kmodest: Unknown symbol do_fsync kmodest: Unknown symbol sys_kill kmodest: Unknown symbol get_files_struct

... asmlinkagelong sys kill(int pid, int sig) ... ... } EXPORT SYMBOL(sys kill);

slide-12
SLIDE 12

Dealing with Kernel OOPS messages

Pid: 3378, comm: find Not tainted (2.6.24-etchnhalf.1-686 #1) EIP: 0060:[<c01875d5>] EFLAGS: 00000286 CPU: 1 EIP is at d lookup+0xbe/0xd9 EAX: dbc649e4 EBX: dbc649d4 ECX: 00000011 EDX: c17e2100 ESI: efbcdf04 EDI: dbc649e4 EBP: d9b347c8 ESP: efbcddc4 [<c017ec3a>] do lookup+0x24/0x14e [<c0180869>] link path walk+0x73f/0xb46 [<c0180cb4>] link path walk+0x44/0xb3 [<c0180f9c>] do path lookup+0x162/0x1c4 [<c017ff66>] getname+0x59/0xad [<c018176d>] user walk fd+0x2f/0x40 [<c017b6ae>] vfs lstat fd+0x16/0x3d [<c017b742>] sys lstat64+0xf/0x23 [<c0103ede>] syscall call+0x7/0xb [<c02b0000>] skb icv walk+0x21e/0x262 (...)

slide-13
SLIDE 13

Dealing with Kernel PANIC messages Not loaded hard-disk controller (such as ahci.ko, ata_piix.ko, ...) Not file-system support for mounting the slash partition (ext3.ko, reiserfs.ko, ...)

slide-14
SLIDE 14

Thanks for coming!!!