*** linux-2.6.11.12/drivers/char/random.c 2005-06-12 03:45:37.000000000 +0100 --- linux-2.6.11.12-random/drivers/char/random.c 2005-06-20 00:45:07.000000000 +0100 *************** *** 1499,1510 **** --- 1499,1520 ---- __u32 words[2]; char *p; int i; + #ifdef __arch_um__ + extern int host_get_random_data(unsigned char *, size_t); + __u32 host_random_words[256]; + + if (0 == host_get_random_data((unsigned char*)host_random_words, sizeof host_random_words)) { + add_entropy_words(r, host_random_words, 256); + credit_entropy_store(r, 256 * 32); + } + #endif /* __arch_um__ */ do_gettimeofday(&tv); words[0] = tv.tv_sec; words[1] = tv.tv_usec; add_entropy_words(r, words, 2); + /* * This doesn't lock system.utsname. However, we are generating * entropy so a race with a name set here is fine. *** linux-2.6.11.12/arch/um/kernel/seedrandom.c 1970-01-01 01:00:00.000000000 +0100 --- linux-2.6.11.12-random/arch/um/kernel/seedrandom.c 2005-06-20 00:49:27.000000000 +0100 *************** *** 0 **** --- 1,39 ---- + /* + * seedrandom.c: + * Simple interface to read data from host's /dev/random. This can then be + * called during the initialisation of the UML host's /dev/random, to prevent + * it from running out of entropy during boot. + */ + + #include + + #include + #include + #include + + #include "user.h" + + int + host_get_random_data(unsigned char *buf, size_t num) + { + int fd; + if (-1 == (fd = open("/dev/random", O_RDONLY))) { + printk("open(\"/dev/random\") failed, errno = %d\n", errno); + return -1; + } + while (num > 0) { + ssize_t n; + do + n = read(fd, buf, num); + while (n == -1 && errno == EINTR); + if (n == -1) { + printk("read(\"/dev/random\") failed, errno = %d\n", errno); + close(fd); + return -1; + } + num -= n; + buf += n; + } + close(fd); + return 0; + } *** linux-2.6.11.12/arch/um/kernel/Makefile 2005-06-12 03:45:37.000000000 +0100 --- linux-2.6.11.12-random/arch/um/kernel/Makefile 2005-06-20 00:40:13.000000000 +0100 *************** *** 12,18 **** sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ syscall_kern.o syscall_user.o sysrq.o sys_call_table.o tempfile.o \ time.o time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o \ ! um_arch.o umid.o user_util.o obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o obj-$(CONFIG_GPROF) += gprof_syms.o --- 12,18 ---- sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ syscall_kern.o syscall_user.o sysrq.o sys_call_table.o tempfile.o \ time.o time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o \ ! um_arch.o umid.o user_util.o seedrandom.o obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o obj-$(CONFIG_GPROF) += gprof_syms.o *************** *** 25,31 **** user-objs-$(CONFIG_TTY_LOG) += tty_log.o USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \ ! main.o process.o tempfile.o time.o tty_log.o umid.o user_util.o frame.o USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) CFLAGS_frame.o := -fno-omit-frame-pointer --- 25,31 ---- user-objs-$(CONFIG_TTY_LOG) += tty_log.o USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \ ! main.o process.o tempfile.o time.o tty_log.o umid.o user_util.o frame.o seedrandom.o USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) CFLAGS_frame.o := -fno-omit-frame-pointer