Interacting with Kernel Modules

Character devices

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#define KERN_MODULE "/dev/kernel-overflow"
void main()
{
    /*
     * Interacting with this kernel module is easy
     * just treat it like a file
     */

    int fd;
    unsigned long stack_cookie;

    fd = open(KERN_MODULE, O_RDWR);
    if (fd < 0) exit(-1);
    
    close(fd);
    
}

Last updated

Was this helpful?