diff options
author | 2015-05-19 20:39:12 +0000 | |
---|---|---|
committer | 2015-05-19 20:39:12 +0000 | |
commit | cd230c960d89f0a893a1ea79bd9667802ad9a5bb (patch) | |
tree | 6f93944f81175849e8befdb00ba113ad3355b397 /sys/lib/libsa/loadfile_elf.c | |
parent | Move acquisition of the kernel lock deeper in the interrupt path, and make (diff) | |
download | wireguard-openbsd-cd230c960d89f0a893a1ea79bd9667802ad9a5bb.tar.xz wireguard-openbsd-cd230c960d89f0a893a1ea79bd9667802ad9a5bb.zip |
Extend the libsa loadfile(9) granularity to tell apart randomness from the rest
of the kernel, and extend the array filled by loadfile to report the location
of the randomness area.
This doesn't introduce any change for bootblocks (save for a slightly larger
stack usage due to the larger array), for the new {LOAD,COUNT}_RANDOM bits
are included in the {LOAD,COUNT}_ALL masks everything uses or computes from.
Diffstat (limited to 'sys/lib/libsa/loadfile_elf.c')
-rw-r--r-- | sys/lib/libsa/loadfile_elf.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/lib/libsa/loadfile_elf.c b/sys/lib/libsa/loadfile_elf.c index 083a286d5b0..432f977e712 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.10 2014/10/26 10:33:48 miod Exp $ */ +/* $OpenBSD: loadfile_elf.c,v 1.11 2015/05/19 20:39:12 miod Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_long *marks, int flags) int m; /* Fill segment if asked for. */ - if (flags & LOAD_DATA) { + if (flags & LOAD_RANDOM) { for (pos = 0; pos < phdr[i].p_filesz; pos += m) { m = MIN(phdr[i].p_filesz - pos, @@ -108,6 +108,11 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_long *marks, int flags) m); } } + if (flags & (LOAD_RANDOM | COUNT_RANDOM)) { + marks[MARK_RANDOM] = LOADADDR(phdr[i].p_paddr); + marks[MARK_ERANDOM] = + marks[MARK_RANDOM] + phdr[i].p_filesz; + } continue; } |