summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_hibernate.c
diff options
context:
space:
mode:
authormlarkin <mlarkin@openbsd.org>2014-07-09 12:43:51 +0000
committermlarkin <mlarkin@openbsd.org>2014-07-09 12:43:51 +0000
commitbd831450ecfa352a2566676139bdad6cd231d422 (patch)
tree4c134337665912dcb0788b3d0b521f4d97809843 /sys/kern/subr_hibernate.c
parentexpire IPcomp SAs too; ok mikeb (some time ago) (diff)
downloadwireguard-openbsd-bd831450ecfa352a2566676139bdad6cd231d422.tar.xz
wireguard-openbsd-bd831450ecfa352a2566676139bdad6cd231d422.zip
Use suspending kernel's stack smash guard to avoid panicing during unpack.
ok deraadt@
Diffstat (limited to 'sys/kern/subr_hibernate.c')
-rw-r--r--sys/kern/subr_hibernate.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c
index 375720be0b6..c5f8879d50b 100644
--- a/sys/kern/subr_hibernate.c
+++ b/sys/kern/subr_hibernate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_hibernate.c,v 1.92 2014/05/31 04:36:59 mlarkin Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.93 2014/07/09 12:43:51 mlarkin Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -77,6 +77,10 @@ int hib_debug = 99;
#define DNPRINTF(n,x...)
#endif
+#ifndef NO_PROPOLICE
+extern long __guard_local;
+#endif /* ! NO_PROPOLICE */
+
void hibernate_copy_chunk_to_piglet(paddr_t, vaddr_t, size_t);
/*
@@ -643,6 +647,11 @@ get_hibernate_info(union hibernate_info *hib, int suspend)
struct disklabel dl;
char err_string[128], *dl_ret;
+#ifndef NO_PROPOLICE
+ /* Save propolice guard */
+ hib->guard = __guard_local;
+#endif /* ! NO_PROPOLICE */
+
/* Determine I/O function to use */
hib->io_func = get_hibernate_io_function();
if (hib->io_func == NULL)
@@ -1175,6 +1184,11 @@ hibernate_resume(void)
/* Switch stacks */
hibernate_switch_stack_machdep();
+#ifndef NO_PROPOLICE
+ /* Start using suspended kernel's propolice guard */
+ __guard_local = disk_hib.guard;
+#endif /* ! NO_PROPOLICE */
+
/* Unpack and resume */
hibernate_unpack_image(&disk_hib);