OSDN Git Service

Fsync directories before delete key
authorWoody Lin <woodylin@google.com>
Mon, 11 Mar 2019 12:58:20 +0000 (20:58 +0800)
committerChris Fries <cfries@google.com>
Thu, 14 Mar 2019 15:29:42 +0000 (10:29 -0500)
commita598e04a91c64741f9f71c6511a7ced7f71d194e
tree830448980a242aef2cd8625c383adf926034fd94
parent2e58acb4123e559fddfd4013af3ead6c055bd71c
Fsync directories before delete key

The boot failure symptom is reproduced on Walleye devices. System boots
up after taking OTA and try to upgrade key, but keymaster returns "failed
to ugprade key". Device reboots to recovery mode because of the failure,
and finally trapped in bootloader screen. Possible scenario is:

(After taking OTA)
vold sends old key and op=UPGRADE to keymaster
keymaster creates and saves new key to RPMB, responses new key to vold
vold saves new key as temp key
vold renames temp key to main key -------------- (1) -- still in cache
vold sends old key and op=DELETE_KEY to keymaster
keymaster removes old key from RPMB ------------ (2) -- write directly to RPMB
==> SYSTEM INTERRUPTED BY CRASH OR SOMETHING; ALL CACHE LOST.
==> System boots up, key in RPMB is deleted but key in storage is old key.

Solution: A Fsync is required between (1) and (2) to cover this case.

Detail analysis: b/124279741#comment21

Bug: 112145641
Bug: 124279741
Test: Insert fault right after deleteKey in vold::begin (KeyStorage.cpp),
      original boot failure symptom is NOT reproducible.
Change-Id: Ia042b23699c37c94758fb660aecec64d39f39738
Merged-In: Ib8c349d6d033f86b247f4b35b8354d97cf249d26
KeyStorage.cpp