From 390be83e74e62d9ab2ed23ed68992fdc711a00fb Mon Sep 17 00:00:00 2001 From: Dana Keeler Date: Wed, 9 Aug 2023 20:47:57 +0000 Subject: [PATCH] Bug 1838894 - webauthn: prevent dispatches to the IPC thread after threads have been shut down r=jschanck Depends on D183057 Differential Revision: https://phabricator.services.mozilla.com/D185232 --- dom/webauthn/WebAuthnController.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dom/webauthn/WebAuthnController.cpp b/dom/webauthn/WebAuthnController.cpp index 5b92d0ad4af1..cee8db7a376a 100644 --- a/dom/webauthn/WebAuthnController.cpp +++ b/dom/webauthn/WebAuthnController.cpp @@ -323,6 +323,9 @@ WebAuthnController::ResumeRegister(uint64_t aTransactionId, &WebAuthnController::RunResumeRegister, aTransactionId, aForceNoneAttestation)); + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; + } return gWebAuthnBackgroundThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); } @@ -355,6 +358,9 @@ WebAuthnController::FinishRegister(uint64_t aTransactionId, if (!gWebAuthnBackgroundThread) { return NS_ERROR_FAILURE; } + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; + } return gWebAuthnBackgroundThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); } @@ -493,6 +499,9 @@ WebAuthnController::FinishSign( if (!gWebAuthnBackgroundThread) { return NS_ERROR_FAILURE; } + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; + } return gWebAuthnBackgroundThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); } @@ -589,6 +598,9 @@ WebAuthnController::SignatureSelectionCallback(uint64_t aTransactionId, if (!gWebAuthnBackgroundThread) { return NS_ERROR_FAILURE; } + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; + } return gWebAuthnBackgroundThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); } @@ -666,6 +678,9 @@ WebAuthnController::PinCallback(uint64_t aTransactionId, if (!gWebAuthnBackgroundThread) { return NS_ERROR_FAILURE; } + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; + } return gWebAuthnBackgroundThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); } @@ -690,6 +705,9 @@ WebAuthnController::Cancel(uint64_t aTransactionId) { if (!gWebAuthnBackgroundThread) { return NS_ERROR_FAILURE; } + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; + } return gWebAuthnBackgroundThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); }