summaryrefslogtreecommitdiffstats
path: root/sys/lib/libsa/loadfile_elf.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2013-12-28 02:51:06 +0000
committerderaadt <deraadt@openbsd.org>2013-12-28 02:51:06 +0000
commit2afebeae30e91331fb9f4496daf6b629e95d4d93 (patch)
tree9dedb71d17f962cf6905aa658a65d0c922f25889 /sys/lib/libsa/loadfile_elf.c
parentIf we fail to decrypt the softraid keys, return EPERM rather than falling (diff)
downloadwireguard-openbsd-2afebeae30e91331fb9f4496daf6b629e95d4d93.tar.xz
wireguard-openbsd-2afebeae30e91331fb9f4496daf6b629e95d4d93.zip
Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF openbsd.randomdata of the kernel, so that it has entropy right from the start. Some help from jsing for the softraid aspects. Also tested by phessler
Diffstat (limited to 'sys/lib/libsa/loadfile_elf.c')
-rw-r--r--sys/lib/libsa/loadfile_elf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/lib/libsa/loadfile_elf.c b/sys/lib/libsa/loadfile_elf.c
index 834a295ca10..493aedd0e85 100644
--- a/sys/lib/libsa/loadfile_elf.c
+++ b/sys/lib/libsa/loadfile_elf.c
@@ -1,5 +1,5 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
-/* $OpenBSD: loadfile_elf.c,v 1.6 2009/11/30 05:18:08 miod Exp $ */
+/* $OpenBSD: loadfile_elf.c,v 1.7 2013/12/28 02:51:07 deraadt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -95,6 +95,17 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
}
for (first = 1, i = 0; i < elf->e_phnum; i++) {
+ if (phdr[i].p_type == PT_OPENBSD_RANDOMIZE) {
+ int m;
+
+ /* Fill segment. */
+ for (pos = 0; pos < phdr[i].p_filesz; pos += m) {
+ m = MIN(phdr[i].p_filesz - pos, sizeof(rnddata));
+ BCOPY(rnddata, phdr[i].p_paddr + pos, m);
+ }
+ continue;
+ }
+
if (phdr[i].p_type != PT_LOAD ||
(phdr[i].p_flags & (PF_W|PF_R|PF_X)) == 0)
continue;