rendered paste bodyfalcon randint # make clean && cp /usr/src/linux/drivers/char/random.o . && cp /usr/src/linux/lib/sha1.o . && make && insmod ./randtest.ko && rmmod randtest
rm -f Module.symvers *.o *~ .\#* .*.cmd *.mod.c *.ko
rm -rf .tmp_versions
make -C /lib/modules/2.6.21.5/build/ SUBDIRS=/root/randint modules
make[1]: Entering directory `/usr/src/linux-2.6.21.5'
CC [M] /root/randint/randint.o
LD [M] /root/randint/randtest.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: /root/randint/randtest: 'sha_transform' exported twice. Previous export was in vmlinux
WARNING: /root/randint/randtest: 'add_input_randomness' exported twice. Previous export was in vmlinux
WARNING: /root/randint/randtest: 'add_disk_randomness' exported twice. Previous export was in vmlinux
WARNING: /root/randint/randtest: 'get_random_bytes' exported twice. Previous export was in vmlinux
WARNING: /root/randint/randtest: 'generate_random_uuid' exported twice. Previous export was in vmlinux
WARNING: /root/randint/randtest: 'secure_tcpv6_sequence_number' exported twice. Previous export was in vmlinux
WARNING: /root/randint/randtest: 'secure_tcp_sequence_number' exported twice. Previous export was in vmlinux
CC /root/randint/randtest.mod.o
LD [M] /root/randint/randtest.ko
make[1]: Leaving directory `/usr/src/linux-2.6.21.5'
insmod: error inserting './randtest.ko': -1 Invalid module format
falcon randint # cat Kbuild
obj-m := randtest.o
randtest-objs := sha1.o random.o randint.o
falcon randint # cat Makefile
default:
make -C /lib/modules/$(shell uname -r)/build/ SUBDIRS=$(PWD) modules
clean:
rm -f Module.symvers *.o *~ .\#* .*.cmd *.mod.c *.ko
rm -rf .tmp_versions
falcon randint # cat randint.c
/*-
solar,pappy@gentoo.org
Tue Jun 19 00:39:29
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/random.h>
static int randint_init(void) {
unsigned int seed[2];
seed[0] = 0x0; // get_random_int();
seed[1] = 0x0; // get_random_int();
if (seed[0] == seed[1]) {
printk(KERN_ALERT "Possible Security Problem: Fast repeated calls to the function get_random_int() is not cryptographically safe: 0x%0*x=0x%0*x\n"
,
sizeof(long), seed[0], sizeof(long), seed[1]);
return 1;
} else {
printk(KERN_INFO "Checking randomization: Fast repeated calls to the function get_random_int(): 0x%0*x=0x%0*x\n",
sizeof(long), seed[0], sizeof(long), seed[1]);
return 0;
}
}
static void randint_exit(void) {
return;
}
module_init(randint_init);
module_exit(randint_exit);
MODULE_LICENSE("GPL");