Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 1826b3e9 authored by Eric Biggers's avatar Eric Biggers
Browse files

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
parent 3171dbf9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment