summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-02-01 18:13:33 +0000
committermillert <millert@openbsd.org>2002-02-01 18:13:33 +0000
commit9c83a8587a72ae5a82472e1e8259d9ecd9a9686d (patch)
tree2b1c11924a2203aa4727e90f50792d6821149b54
parentFix a condition where the hole would be inserted in the wrong place during a (diff)
downloadwireguard-openbsd-9c83a8587a72ae5a82472e1e8259d9ecd9a9686d.tar.xz
wireguard-openbsd-9c83a8587a72ae5a82472e1e8259d9ecd9a9686d.zip
After writing a page out to disk, run the page back through the user's
input filter to ensure we don't end up with a cached copy of the page in the wrong byte-order for the host cpu. This fixes a fatal bug which bites when the DB 'lorder' is different to the cpu's, and a cached page is accessed soon after it was flushed to disk. From scw@netbsd.org
-rw-r--r--lib/libc/db/mpool/mpool.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c
index bb4c0ac9a9a..89cab031741 100644
--- a/lib/libc/db/mpool/mpool.c
+++ b/lib/libc/db/mpool/mpool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpool.c,v 1.7 2002/01/31 03:51:21 millert Exp $ */
+/* $OpenBSD: mpool.c,v 1.8 2002/02/01 18:13:33 millert Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)mpool.c 8.7 (Berkeley) 11/2/95";
#else
-static char rcsid[] = "$OpenBSD: mpool.c,v 1.7 2002/01/31 03:51:21 millert Exp $";
+static char rcsid[] = "$OpenBSD: mpool.c,v 1.8 2002/02/01 18:13:33 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -430,6 +430,15 @@ mpool_write(mp, bp)
if (pwrite(mp->fd, bp->page, mp->pagesize, off) != mp->pagesize)
return (RET_ERROR);
+ /*
+ * Re-run through the input filter since this page may soon be
+ * accessed via the cache, and whatever the user's output filter
+ * did may screw things up if we don't let the input filter
+ * restore the in-core copy.
+ */
+ if (mp->pgin)
+ (mp->pgin)(mp->pgcookie, bp->pgno, bp->page);
+
bp->flags &= ~MPOOL_DIRTY;
return (RET_SUCCESS);
}