insight kernel stack

周作人
2023-12-01

首先是一段内核模块代码

#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void) {
    long addr;

    asm("mov %%rbp, %%rax\n\t"
        "mov %%rax, %0\n\t"
        : "=r"(addr)
        :
        : "rax");
    printk(KERN_INFO "current %lX, esp %lX, stack %lX\n", (unsigned long)current, (unsigned long)addr, (unsigned long)(current->stack));
    return 0;
}

static void hello_exit(void) {
    printk(KERN_ALERT "Goodbye, cruel world!\n");
}

module_init(hello_init);
module_exit(hello_exit);


 类似资料:

相关阅读

相关文章

相关问答