From: Tom Yu Date: Thu, 25 Aug 2016 22:02:56 +0000 (-0400) Subject: Avoid byte-swap cache corruption in libdb2 X-Git-Tag: krb5-1.15-beta1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56d02135d4c77b6aa0cb7136477d426248c60a6f;p=thirdparty%2Fkrb5.git Avoid byte-swap cache corruption in libdb2 Apply a patch from NetBSD to restore the cached copy of a page to the machine byte order after a write operation swapped it to the file byte order. As a regression test, modify test13 to sync the database file after each put to exercise this bug. ticket: 8483 (new) target_version: 1.14-next target_version: 1.13-next tags: pullup --- diff --git a/src/plugins/kdb/db2/libdb2/mpool/mpool.c b/src/plugins/kdb/db2/libdb2/mpool/mpool.c index 79ad61316d..e1de6797ab 100644 --- a/src/plugins/kdb/db2/libdb2/mpool/mpool.c +++ b/src/plugins/kdb/db2/libdb2/mpool/mpool.c @@ -432,6 +432,14 @@ mpool_write(mp, bp) if (write(mp->fd, bp->page, mp->pagesize) != 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); } diff --git a/src/plugins/kdb/db2/libdb2/test/run.test b/src/plugins/kdb/db2/libdb2/test/run.test index caf6989ad1..728a70f985 100644 --- a/src/plugins/kdb/db2/libdb2/test/run.test +++ b/src/plugins/kdb/db2/libdb2/test/run.test @@ -614,6 +614,7 @@ test13() echo p echo k$i echo d$i + echo S echo g echo k$i done > $TMP2