CSC 469 Lecture 3- Linux Kernel Modules Performance Evaluation

CSC 469 Lecture 3- Linux Kernel Modules Performance Evaluation

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 3: Linux Kernel Modules Performance Evaluation Interrupts & Signals CSC 469H1F / CSC 2208H1F Fall 2014 Angela Demke Brown
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSC469 Loadable Kernel Modules Giving everyone a virtual machine doesn’t entirely solve the extension problem You can run what you want on your VM, but do you really want to write a custom OS? Often just want to modify/replace small part Solution: Allow parts of the kernel to be dynamically loaded / unloaded Requires dynamic relocation and linking Common strategy in monolithic kernels for device drivers (FreeBSD, Windows NT/2K/XP, Linux)
Image of page 2
CSC469 Linux Loadable Kernel Modules Module writer must define (at least) two functions init_module code executed when module loads cleanup_module code executed when module unloads Module functions can refer to any exported kernel symbols Module is compiled into relocatable .ko file (since 2.6) insmod command loads module into running kernel 2.4 insmod resolves references to kernel symbols 2.6 invokes init_module() syscall, kernel does the linking rmmod command removes module from kernel lsmod command lists currently-installed modules
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Tracking Modules Kernel has a linked list of module objects struct contained in the module memory itself CSC469 state list name ref modules_which_use_me state list name ref modules_which_use_me state list name ref modules_which_use_me
Image of page 4
CSC469 sys_init_module() Kernel handler for init_module() system call Checks permission and copies arguments to kernel Checks that module is not loaded already Allocates memory for module and fills it in from ELF sections Locates module object structure in this memory, initializes fields Relocates all external or global symbols with correct addresses Links new module into list Sets state to MODULE_STATE_COMING Calls init function of module Sets state to MODULE_STATE_LIVE
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSC469 rmmod Unlinks module from kernel Needs to ensure no one is using module first! Reference count incremented whenever module is used modules_that_use_me list identifies other modules that that depend on this one Frees memory Getting module unloading right is tricky Part of module object is a field that indicates whether it is safe to EVER unload an object
Image of page 6
CSC469 Problems with module approach Requires stable interfaces Linux uses version numbers to check if module is compiled for correct version of kernel, but it is easy to get this wrong Unsafe Module code can do anything because it runs privileged E.g. recall VMWare Workstation driver? “hijacks” machine by changing interrupt descriptor table (IDT) base register and then jumps to code in the VM application!
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSC469 Alternate kernel-level schemes Trusted compiler (or certification authority) + digital signatures Allows verification of source of code added to kernel You still have to decide if you trust that source
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern