Fsync directories after creating files
Bug: 120248692
Test: adb shell locksettings set-pin 1111 && \
adb shell "echo b > /proc/sysrq-trigger"
Change-Id: I53d252942c21365983b4f8b6e0948b1864f195c1
diff --git a/KeyStorage.cpp b/KeyStorage.cpp
index 9dd4991..fc700c5 100644
--- a/KeyStorage.cpp
+++ b/KeyStorage.cpp
@@ -484,6 +484,7 @@
if (!encryptWithoutKeymaster(appId, key, &encryptedKey)) return false;
}
if (!writeStringToFile(encryptedKey, dir + "/" + kFn_encrypted_key)) return false;
+ if (!FsyncDirectory(dir)) return false;
return true;
}