| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a2f0738 commit e798e26
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,7 +136,13 @@ bool InitCryptoOnce(Isolate* isolate) { | |||
| 136 | 136 | return true; | |
| 137 | 137 | } | |
| 138 | 138 | ||
| 139 | + // Protect accesses to FIPS state with a mutex. This should potentially | ||
| 140 | + // be part of a larger mutex for global OpenSSL state. | ||
| 141 | + static Mutex fips_mutex; | ||
| 142 | + | ||
| 139 | 143 | void InitCryptoOnce() { | |
| 144 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 145 | + Mutex::ScopedLock fips_lock(fips_mutex); | ||
| 140 | 146 | #ifndef OPENSSL_IS_BORINGSSL | |
| 141 | 147 | OPENSSL_INIT_SETTINGS* settings = OPENSSL_INIT_new(); | |
| 142 | 148 | ||
@@ -196,6 +202,9 @@ void InitCryptoOnce() { | |||
| 196 | 202 | } | |
| 197 | 203 | ||
| 198 | 204 | void GetFipsCrypto(const FunctionCallbackInfo<Value>& args) { | |
| 205 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 206 | + Mutex::ScopedLock fips_lock(fips_mutex); | ||
| 207 | + | ||
| 199 | 208 | #if OPENSSL_VERSION_MAJOR >= 3 | |
| 200 | 209 | args.GetReturnValue().Set(EVP_default_properties_is_fips_enabled(nullptr) ? | |
| 201 | 210 | 1 : 0); | |
@@ -205,8 +214,13 @@ void GetFipsCrypto(const FunctionCallbackInfo<Value>& args) { | |||
| 205 | 214 | } | |
| 206 | 215 | ||
| 207 | 216 | void SetFipsCrypto(const FunctionCallbackInfo<Value>& args) { | |
| 217 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 218 | + Mutex::ScopedLock fips_lock(fips_mutex); | ||
| 219 | + | ||
| 208 | 220 | CHECK(!per_process::cli_options->force_fips_crypto); | |
| 209 | 221 | Environment* env = Environment::GetCurrent(args); | |
| 222 | + // TODO(addaleax): This should not be possible to set from worker threads. | ||
| 223 | + // CHECK(env->owns_process_state()); | ||
| 210 | 224 | bool enable = args[0]->BooleanValue(env->isolate()); | |
| 211 | 225 | ||
| 212 | 226 | #if OPENSSL_VERSION_MAJOR >= 3 | |
@@ -227,6 +241,9 @@ void SetFipsCrypto(const FunctionCallbackInfo<Value>& args) { | |||
| 227 | 241 | } | |
| 228 | 242 | ||
| 229 | 243 | void TestFipsCrypto(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 244 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 245 | + Mutex::ScopedLock fips_lock(fips_mutex); | ||
| 246 | + | ||
| 230 | 247 | #ifdef OPENSSL_FIPS | |
| 231 | 248 | #if OPENSSL_VERSION_MAJOR >= 3 | |
| 232 | 249 | OSSL_PROVIDER* fips_provider = nullptr; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments