-/* $OpenBSD: subr_hibernate.c,v 1.121 2017/03/27 20:26:39 deraadt Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.122 2017/06/22 15:56:29 deraadt Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
return min((pg_end - pg), HIBERNATE_CHUNK_SIZE/PAGE_SIZE);
}
+/*
+ * Calculate a hopefully unique version # for this kernel, based upon
+ * how it was linked.
+ */
+u_int32_t
+hibsum(void)
+{
+ return ((long)malloc ^ (long)km_alloc ^ (long)printf ^ (long)strlen);
+}
+
+
/*
* Fills out the hibernate_info union pointed to by hib
* with information about this machine (swap signature block
memset(&hib->kernel_version, 0, 128);
bcopy(version, &hib->kernel_version,
min(strlen(version), sizeof(hib->kernel_version)-1));
+ hib->kernel_sum = hibsum();
if (suspend) {
/* Grab the previously-allocated piglet addresses */
return (1);
}
+ if (hibsum() != disk->kernel_sum) {
+ DPRINTF("hibernate sum version mismatch %x %x\n",
+ hibsum(), disk->kernel_sum);
+ return (1);
+ }
+
for (i = 0; i < mine->nranges; i++) {
if ((mine->ranges[i].base != disk->ranges[i].base) ||
(mine->ranges[i].end != disk->ranges[i].end) ) {
-/* $OpenBSD: hibernate.h,v 1.40 2016/09/27 02:53:49 dlg Exp $ */
+/* $OpenBSD: hibernate.h,v 1.41 2017/06/22 15:56:29 deraadt Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
paddr_t piglet_pa;
vaddr_t piglet_va;
char kernel_version[128];
+ u_int32_t kernel_sum;
hibio_fn io_func;
void *io_page;
#ifndef NO_PROPOLICE