diff options
| author | 2022-06-24 17:31:51 +0000 | |
|---|---|---|
| committer | 2022-07-01 22:58:34 +0000 | |
| commit | 1826b3e94d11da55e6c6984565dcc59dd2c2c400 (patch) | |
| tree | 3208d09b02e39cb71bf9754786f5e2730fab65ea /libs/androidfw/StringPool.cpp | |
| parent | 3171dbf96c53a68745dd09c44b94ffd51aaef9a6 (diff) | |
LockSettingsStorage: fix concurrent read clobbering a removal
Since Cache.remove() doesn't increment mVersion, the key removal can be
clobbered by a concurrent read that loads the key into the cache. Fix
this by making Cache.remove() increment mVersion, indicating that the
backing storage has been modified.
Found by code review; this bug isn't known to have been causing any
real-world problems.
Add a best-effort test for this, though due to the very tight race
needed, it didn't reproduce the bug in 2000 iterations. However, it
reproduced the bug in just a few iterations if a 1 millisecond sleep is
added in the right place (just before the call to
Cache.putKeyValueIfUnchanged() in LockSettingsStorage.readKeyValue()).
Test: atest --iterations 50 LockSettingsStorageTests
Change-Id: I960cc386ecd040af7517d3d62a3eefe57a518620
Diffstat (limited to 'libs/androidfw/StringPool.cpp')
0 files changed, 0 insertions, 0 deletions