From 85e3d8cd50c540b1a4827bd179e3b8b609731e61 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Tue, 26 Apr 2016 12:50:53 -0700 Subject: [PATCH] Drop caches after installing key policy to avoid cache clashes Note that this is an ugly workaround for a kernel bug. Bug: 28373400 Change-Id: Iec1ae53f4e18f06e41e8cf1fcc3ab03fc9848632 --- Ext4Crypt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp index 309a1f2..eaac26a 100644 --- a/Ext4Crypt.cpp +++ b/Ext4Crypt.cpp @@ -176,6 +176,14 @@ static bool install_key(const std::string& key, std::string* raw_ref) { } LOG(DEBUG) << "Added key " << key_id << " (" << ref << ") to keyring " << device_keyring << " in process " << getpid(); + + // *TODO* Remove this code when kernel is fixed - see b/28373400 + // Kernel preserves caches across a key insertion with ext4ice, which leads + // to contradictory dirents + if (!android::base::WriteStringToFile("3", "/proc/sys/vm/drop_caches")) { + PLOG(ERROR) << "Failed to drop_caches"; + } + return true; }