最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c - How to crash (and reboot) the linux kernel by changing program counter - Stack Overflow

programmeradmin5浏览0评论

For educational purposes, I have to inject fault into a linux kernel. The current setup is:

  • A system call, which injects the fault. In my case, I'm jumping to some random address that is probably invalid, which simulates a control flow error. Here's the code:
#include <linux/kernel.h>
#include <linux/syscalls.h>

SYSCALL_DEFINE0(fine) {
    printk("==== FINE systemcall ====\n");
    printk("====      START      ====\n");
    asm volatile("jmp 0x01");
    printk("====      JUMPED     ====\n");
    printk("====       END       ====\n");
    return 0;
}
  • A C program that calls the above system call, initiating the fault injection. Here's that code:
#include <stdio.h>
#include <sys/syscall.h> 

int main(){
    printf("Calling the system call...\n");
    printf("syscall output: %d\n", syscall(600)); // custom syscall code (fine_syscall)
    printf("System call is called!\n");
    return 0;
}
  • A virtual linux (pop os on virtualbox) for installing the custom kernel and calling the system call.

This setup works (after fixing many problems) and the system call is actually being called, but the program is being killed and here's the dmesg output after running the program: So far I've managed to inject the fault, but I want to turn that fault into error and failure. Preferably, I want the system to crash and reboot. My question is How can I do that?

Is the general purpose linux kernel robust enough that such a thing is not easily possible? Or can I do that by editing the jump destination to something "less" invalid? Considering my lack of knowledge about linux kernel (this is my first encounter with it xd), I don't really know how to effectively screw the kernel. Thanks in advance :D

发布评论

评论列表(0)

  1. 暂无评论