所以我的最后一个内核作业是通过用我自己的劫持例程的地址替换IDT中的中断处理程序的地址来劫持中断。我的模块正常工作;但是每当我在我的劫持程序中有一个打印语句时,我就会得到一个内核oops或恐慌。所以我想我想知道是否有人对此有解释或者是否有办法调试它。我正在运行内核3.0.4,这是我得到的一些错误消息
[ 2479.355359] general protection fault: 0000 [#2] SMP
[ 2479.356972] Modules linked in: get_idt(P) cryptd aes_i586 aes_generic binfmt_misc pci_stub vboxpci vboxnetadp vboxnetflt vboxdrv nouveau ttm drm_kms_helper drm i2c_algo_bit mxm_wmi parport_pc ppdev snd_hda_codec_analog joydev pcmcia snd_hda_intel snd_hda_codec snd_hwdep snd_pcm arc4 snd_seq_midi yenta_socket pcmcia_rsrc pcmcia_core snd_rawmidi r852 sm_common nand nand_ids nand_ecc video ath5k ath snd_seq_midi_event mac80211 snd_seq snd_timer cfg80211 btusb snd_seq_device bluetooth psmouse thinkpad_acpi tpm_tis serio_raw sdhci_pci firewire_ohci sdhci mtd firewire_core crc_itu_t tpm tpm_bios nvram snd e1000e lp parport soundcore snd_page_alloc [last unloaded: get_idt]
[ 2479.358225]
[ 2479.358225] Pid: 2872, comm: float Tainted: P D 3.0.0 #46 LENOVO 64574JU/64574JU
[ 2479.358225] EIP: 0060:[<c1049244>] EFLAGS: 00210046 CPU: 0
[ 2479.358225] EIP is at vprintk+0x64/0x4a0
[ 2479.358225] EAX: ffffffff EBX: 00000000 ECX: 00000000 EDX: 00000000
[ 2479.358225] ESI: f0143fd8 EDI: 00000000 EBP: f0143fbc ESP: f0143f44
[ 2479.358225] DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068
[ 2479.358225] Process float (pid: 2872, ti=f0142000 task=f08df230 task.ti=f0142000)
[ 2479.358225] Stack:
[ 2479.358225] f08df230 f0398ab8 f0398a80 00000004 00200046 b7651c10 c10ff884 f84bd024
[ 2479.358225] f0398a80 f0143f98 c1100889 ffffffef 00000004 ef85e7f4 f0398a84 ef85e9a0
[ 2479.358225] b7799000 ef85e7e8 f0398a80 f0398ab8 b7788000 f0143fac c1101c9b b7783ff4
[ 2479.358225] Call Trace:
[ 2479.358225] [<c10ff884>] ? remove_vma+0x44/0x60
[ 2479.358225] [<c1100889>] ? do_munmap+0x1f9/0x270
[ 2479.358225] [<c1101c9b>] ? sys_munmap+0x4b/0x60
[ 2479.358225] [<c1516760>] ? spurious_fault+0xd0/0xd0
[ 2479.358225] [<c1510af6>] printk+0x30/0x32
[ 2479.358225] [<f84bc028>] take_over+0x28/0x30 [get_idt]
[ 2479.358225] [<f84bc03e>] hijack+0x6/0x18 [get_idt]
[ 2479.358225] Code: 78 c1 00 0f 84 29 03 00 00 8b 1d ac 94 78 c1 85 db 0f 85 a6 03 00 00 9c 58 8d 74 26 00 89 45 98 fa 90 8d 74 26 00 a1 f4 6d 73 c1
[ 2479.358225] 8b 15 c0 30 83 c1 89 55 9c 39 c2 0f 84 9f 03 00 00 b8 a0 d6
[ 2479.358225] EIP: [<c1049244>] vprintk+0x64/0x4a0 SS:ESP 0068:f0143f44
[ 2479.358225] ---[ end trace bae1cb37e149735b ]---
这是我的劫持程序给我一个错误:
asmlinkage void take_over(void) {
printk("Divide by 0 has been hijacked\n");
}
我做了一个不同的例程来操作一个正常工作的整数,但是我想让例程包含一个print语句。
答案 0 :(得分:0)
printk
调用应以KERN_*
常量为前缀。所以请尝试:
printk(KERN_INFO "Divide by 0 has been hijacked\n");
是的,这很严格:KERN_INFO
和字符串之间没有逗号。
答案 1 :(得分:0)
可能是那些特定的键击需要特定的处理并且通过返回IRQ_HANDLED
内核不会调用其他共享处理程序吗?您是否尝试过返回IRQ_NONE
?