|
|
Created:
4 years, 3 months ago by cfroussios Modified:
4 years, 2 months ago Reviewers:
Lei Zhang CC:
chromium-reviews Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionThread safe initialization of OSCrypt cache
Clients of OSCrypt run in multiple threads. This creates a race
condition for the lazy initialization of OSCrypt, which currently
isn't thread safe.
Additionally, when a synchronous call to libsecret blocks waiting for
user permission, parallel calls to it do not block on the same prompt.
Rather, they fail. This means that, while the first caller will
correctly identify that encryption should be used, subsequent callers
will behave as if full encryption is not available, until the first
caller gets permission and properly initialises OSCrypt.
Fixing thread safety should fix reported cases of data loss.
BUG=631171
Committed: https://crrev.com/fc6f304827896fb27397fc2a27f9f5717eff319c
Cr-Commit-Position: refs/heads/master@{#421097}
Patch Set 1 #Patch Set 2 : removed unrelated code #Patch Set 3 : thread safety for both passwords #Patch Set 4 : fixed refactoring #
Total comments: 2
Patch Set 5 : Added tests #Patch Set 6 : Call encryption and decryption #Patch Set 7 : removed commited log file #Patch Set 8 : Test all platforms #Patch Set 9 : lint #
Messages
Total messages: 48 (36 generated)
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Thread safe initilization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialisation of the OSCrypt. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initilises OSCrypt. BUG=495801 ========== to ========== Thread safe initilization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialisation of the OSCrypt. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initilises OSCrypt. BUG=631171 ==========
Description was changed from ========== Thread safe initilization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialisation of the OSCrypt. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initilises OSCrypt. BUG=631171 ========== to ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialisation of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 ==========
cfroussios@chromium.org changed reviewers: + thestig@chromium.org
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Hi! Can you review this bug fix? Thanks!
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Let's add unit tests to exercise this code from multiple threads. Then we can run it through TSANv2. https://www.chromium.org/developers/testing/threadsanitizer-tsan-v2 Commit msg / subject line: "initilization" is a typo. https://codereview.chromium.org/2359803002/diff/60001/components/os_crypt/os_... File components/os_crypt/os_crypt_linux.cc (right): https://codereview.chromium.org/2359803002/diff/60001/components/os_crypt/os_... components/os_crypt/os_crypt_linux.cc:64: base::Lock g_cache_lock; Does this add a static initializer? Maybe make it part of struct Cache?
BTW, what's the current call stack from OSCrypt clients? Do they go through OSCrypt::{En,De}cryptString()? Should we add comments saying these can be called on any thread?
Description was changed from ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialisation of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 ========== to ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialization of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 ==========
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
I added some tests. TSan would not accept the current pattern (reading the initialization condition outside of the guarded code), so I changed to something less efficient unfortunately. I don't exactly follow your point about the clients' call stack. Apart from the 3 initialisation functions, and mocking for tests, encrypt/decrypt are the only entry points to OSCrypt. Calling these methods thread-safe would be accurate for Mac and Linux. I didn't see any locks in windows, so I don't know how the issue is dealt there and if it's accurate to add a comment about every case. https://codereview.chromium.org/2359803002/diff/60001/components/os_crypt/os_... File components/os_crypt/os_crypt_linux.cc (right): https://codereview.chromium.org/2359803002/diff/60001/components/os_crypt/os_... components/os_crypt/os_crypt_linux.cc:64: base::Lock g_cache_lock; On 2016/09/21 19:04:56, Lei Zhang wrote: > Does this add a static initializer? Maybe make it part of struct Cache? Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
lgtm On 2016/09/22 18:04:53, cfroussios wrote: > I added some tests. TSan would not accept the current pattern (reading the > initialization condition outside of the guarded code), so I changed to something > less efficient unfortunately. I think it'll be fine. > I don't exactly follow your point about the clients' call stack. Apart from the > 3 initialisation functions, and mocking for tests, encrypt/decrypt are the only > entry points to OSCrypt. Calling these methods thread-safe would be accurate for > Mac and Linux. I didn't see any locks in windows, so I don't know how the issue > is dealt there and if it's accurate to add a comment about every case. Ah, it's just 2 calls to encrypt/decrypt racing against each other? Wasn't 100% sure who was participating in the race.
The CQ bit was checked by cfroussios@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by cfroussios@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from thestig@chromium.org Link to the patchset: https://codereview.chromium.org/2359803002/#ps160001 (title: "lint")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by thestig@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by thestig@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialization of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 ========== to ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialization of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 ==========
Message was sent while issue was closed.
Committed patchset #9 (id:160001)
Message was sent while issue was closed.
Description was changed from ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialization of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 ========== to ========== Thread safe initialization of OSCrypt cache Clients of OSCrypt run in multiple threads. This creates a race condition for the lazy initialization of OSCrypt, which currently isn't thread safe. Additionally, when a synchronous call to libsecret blocks waiting for user permission, parallel calls to it do not block on the same prompt. Rather, they fail. This means that, while the first caller will correctly identify that encryption should be used, subsequent callers will behave as if full encryption is not available, until the first caller gets permission and properly initialises OSCrypt. Fixing thread safety should fix reported cases of data loss. BUG=631171 Committed: https://crrev.com/fc6f304827896fb27397fc2a27f9f5717eff319c Cr-Commit-Position: refs/heads/master@{#421097} ==========
Message was sent while issue was closed.
Patchset 9 (id:??) landed as https://crrev.com/fc6f304827896fb27397fc2a27f9f5717eff319c Cr-Commit-Position: refs/heads/master@{#421097} |