summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-02-21 10:38:46 -0800
committerKees Cook <keescook@chromium.org>2013-02-22 17:14:21 -0800
commit97f64fcbe4fe5389e10441c7c11308c81f77ab91 (patch)
treef1955f342d26e0acae1584e937be148ed64cb2a9
parent886a9047f07d6bf9f424fd83247136c79706e136 (diff)
downloadvboot-stabilize-3701.81.B.tar.gz
In an effort to reduce the chances of a kernel bug wrecking filesystems during encrypted-stateful shutdown, add explicit sync() calls during shutdown. BUG=chrome-os-partner:17610 TEST=link build, shutdown with simulated panic in LOOP_CLR_FD results in successful journal replays BRANCH=None Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/43736 Reviewed-by: Grant Grundler <grundler@chromium.org> Change-Id: Ifd2a5f70c325d0a24296fed5e8f303838e25c36c (cherry picked from ToT commit e6cf2c21a1cd6fc46b6adcaadc865e2f8bd4874e) Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/43837 Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
-rw-r--r--utility/mount-encrypted.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/utility/mount-encrypted.c b/utility/mount-encrypted.c
index 98e63e74..9dbedc2a 100644
--- a/utility/mount-encrypted.c
+++ b/utility/mount-encrypted.c
@@ -1063,6 +1063,12 @@ static int shutdown(void)
}
}
+ /*
+ * Force syncs to make sure we don't tickle racey/buggy kernel
+ * routines that might be causing crosbug.com/p/17610.
+ */
+ sync();
+
/* Optionally run fsck on the device after umount. */
if (getenv("MOUNT_ENCRYPTED_FSCK")) {
char *cmd;
@@ -1081,12 +1087,15 @@ static int shutdown(void)
INFO("Removing %s.", dmcrypt_dev);
if (!dm_teardown(dmcrypt_dev))
ERROR("dm_teardown(%s)", dmcrypt_dev);
+ sync();
INFO("Unlooping %s (named %s).", block_path, dmcrypt_name);
if (!loop_detach_name(dmcrypt_name)) {
ERROR("loop_detach_name(%s)", dmcrypt_name);
return EXIT_FAILURE;
}
+ sync();
+
return EXIT_SUCCESS;
}