I am attempting to create a Kernel Module, and I am looking to use getrandom to access a secure random from /dev/urandom. I am having problems getting the make to allow the function. Make will not complete and is returning the following error:
implicit declaration of function 'getrandom' [-Werror=implicit-function-declaration]
What would I need to do to fix this?
I've already followed this guide on how to update my glibc library from the sid repositories. Running ldd --version
in the terminal will return the following info:
ldd (Debian GLIBC 2.27-3) 2.27
hello-2.c
#define MODULE
#define LINUX
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/random.h>
static int hello_2_init(void)
{
printk("Hello, world 2\n");
int rnd = 0;
void *buf;
getrandom(rnd, 256, 0);
printk("Number is %d ", rnd);
return 0;
}
The expected result would be getrandom to not prevent my program from compiling into a kernel mod and return a random int, but the current result is the fatal compilation error.