interrupt hooking by directly modifying the idt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello,

i am trying to write a module that hooks interrupts by modifying the
interrupt descriptor table (IDT).

suppose i have my own interrupt handler such as:
asmlinkage void my_handler(void) {
printk("this is my handler running!");
}

first i save the address of the original handler in original_stub.
that address can be obtained by looking at the right entry in the IDT.

now, here is the code that will be pointed to by the aprropriate entry
in the IDT:
void asm_stub(void) {
__asm__ (
".globl my_stub                   \n"
".align 4                              \n"
"my_stub:                           \n"
"call %0                              \n"                 // first
call my_handler
"jmp %1                              \n"                // now execute
the original handler
::"m"(my_handler), "m"(original_stub));
}

later, i can reverse the hook by restoring the address of the original
handler so my_stub will never be called.

i tried to hook interrupt 3 (used for breakpoints while debugging)
using this method but whenever i trigger the interrupt (by adding a
breakpoint in gdb) i keep getting segmentation faults.

can anyone help me with this?

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux