Crash downloading mail in nssCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature
Categories
(Thunderbird :: Security, defect)
Tracking
(thunderbird_esr52 wontfix, thunderbird_esr60+ affected, thunderbird59 wontfix, thunderbird60 wontfix, thunderbird61 wontfix, thunderbird62 wontfix, thunderbird63 wontfix, thunderbird65 wontfix, thunderbird66 verified)
People
(Reporter: wsmwk, Assigned: KaiE)
References
Details
(5 keywords, Whiteboard: [tbird topcrash][regression:TB58?])
Crash Data
User Story
Beta picture: no crashes after 60.0b11 but frequent during and before that, for both ... nssCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature and nssCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | CERT_ImportCerts | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature no crashes after 60.0b9, but frequent before that ... PORT_ArenaAlloc_Util | nssTrust_GetCERTCertTrustForCert | fill_CERTCertificateFields rare but consistent non-Windows crashes in beta for nssCertificate_Destroy | <name omitted> | CERT_ImportCerts | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature bug 1453518's signature becomes rare after 60.0b11 nssCertificate_Destroy | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature -- Assuming the above items did not go away because of a fix, perhaps they have been replace by rising stars... nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature bp-e9981019-32db-4d10-93cb-ec2c70190109 and nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_ImportCerts | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature bp-095b69fe-e3fc-4ed9-b640-f9e8c0190112
Attachments
(2 files, 2 obsolete files)
|
1.96 KB,
patch
|
jorgk-bmo
:
review+
jorgk-bmo
:
approval-comm-beta+
|
Details | Diff | Splinter Review |
|
1.84 KB,
patch
|
KaiE
:
review+
jorgk-bmo
:
approval-comm-esr60+
|
Details | Diff | Splinter Review |
| Reporter | ||
Comment 1•8 years ago
|
||
| Reporter | ||
Comment 2•8 years ago
|
||
| Reporter | ||
Comment 3•8 years ago
|
||
Comment 4•8 years ago
|
||
| Reporter | ||
Comment 5•8 years ago
|
||
| Reporter | ||
Comment 6•8 years ago
|
||
| Reporter | ||
Comment 7•8 years ago
|
||
Comment 8•8 years ago
|
||
Comment 9•8 years ago
|
||
Comment 10•8 years ago
|
||
| Reporter | ||
Comment 11•8 years ago
|
||
Comment 12•8 years ago
|
||
Comment 13•8 years ago
|
||
Comment 14•8 years ago
|
||
Comment 15•8 years ago
|
||
| Reporter | ||
Comment 16•8 years ago
|
||
Comment 17•8 years ago
|
||
Comment 18•8 years ago
|
||
Comment 19•8 years ago
|
||
| Reporter | ||
Comment 20•8 years ago
|
||
| Assignee | ||
Comment 21•8 years ago
|
||
| Reporter | ||
Comment 22•8 years ago
|
||
| Reporter | ||
Comment 23•8 years ago
|
||
Comment 24•8 years ago
|
||
| Reporter | ||
Comment 25•8 years ago
|
||
| Reporter | ||
Updated•8 years ago
|
Updated•7 years ago
|
| Reporter | ||
Comment 26•7 years ago
|
||
| Reporter | ||
Comment 27•7 years ago
|
||
| Reporter | ||
Comment 28•7 years ago
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 29•7 years ago
|
||
| Assignee | ||
Comment 30•7 years ago
|
||
Comment 31•7 years ago
|
||
| Reporter | ||
Comment 32•7 years ago
|
||
| Reporter | ||
Comment 33•7 years ago
|
||
| Reporter | ||
Comment 35•7 years ago
|
||
Signatures more common in beta than the previously documented signatures
nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature
bp-e9981019-32db-4d10-93cb-ec2c70190109
Crashing Thread (63), Name: SMimeVerify
0 nss3.dll nssCertificate_Destroy security/nss/lib/pki/certificate.c:95
1 nss3.dll NSSCertificate_Destroy security/nss/lib/pki/certificate.c:141
2 nss3.dll CERT_DestroyCertificate security/nss/lib/certdb/stanpcertdb.c:817
3 nss3.dll CERT_DestroyCertArray security/nss/lib/certdb/certdb.c:2232
4 nss3.dll NSS_CMSSignedData_ImportCerts security/nss/lib/smime/cmssigdata.c:635
5 xul.dll nsCMSMessage::CommonVerifySignature(unsigned char*, unsigned int) comm/mailnews/mime/src/nsCMS.cpp:224
6 xul.dll nsCMSMessage::VerifyDetachedSignature(unsigned char*, unsigned int) comm/mailnews/mime/src/nsCMS.cpp:180
7 xul.dll SMimeVerificationTask::CalculateResult() comm/mailnews/mime/src/nsCMS.cpp:353
8 xul.dll mozilla::CryptoTask::Run() security/manager/ssl/CryptoTask.cpp:39
nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_ImportCerts | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature
bp-095b69fe-e3fc-4ed9-b640-f9e8c0190112
Crashing Thread (69), Name: SMimeVerify
0 nss3.dll nssCertificate_Destroy security/nss/lib/pki/certificate.c:95
1 nss3.dll NSSCertificate_Destroy security/nss/lib/pki/certificate.c:141
2 nss3.dll CERT_DestroyCertificate security/nss/lib/certdb/stanpcertdb.c:817
3 nss3.dll CERT_ImportCerts security/nss/lib/certdb/certdb.c:2539
4 nss3.dll NSS_CMSSignedData_ImportCerts security/nss/lib/smime/cmssigdata.c:614
5 xul.dll nsCMSMessage::CommonVerifySignature(unsigned char*, unsigned int) comm/mailnews/mime/src/nsCMS.cpp:224
6 xul.dll nsCMSMessage::VerifyDetachedSignature(unsigned char*, unsigned int) comm/mailnews/mime/src/nsCMS.cpp:180
7 xul.dll SMimeVerificationTask::CalculateResult() comm/mailnews/mime/src/nsCMS.cpp:353
8 xul.dll mozilla::CryptoTask::Run() security/manager/ssl/CryptoTask.cpp:36
| Assignee | ||
Comment 36•7 years ago
|
||
(In reply to Kai Engert (:kaie:) from comment #29)
The first and the third stack are similar. After processing some S/MIME
signature data, we're trying to clean up. While doing so, we run into an
unexpected scenario. The internal NSS data structures are in an inconsistent
state, and we crash trying to dereference a NULL pointer - of a pointer that
should never be NULL.
Sorry, my above reasoning was wrong, but it's a memory corruption.
All stacks that have certificate.c:95 as the topmost code crash with the following code:
1 nssCertificate_Destroy(NSSCertificate *c) {
2 if (c) {
3 nssDecodedCert *dc = c->decoding;
Because we arrive at line 3, we know that c is non-null.
If we crash in line 3, pointer c points to invalid memory.
All crashes appear to happen while we verify an S/MIME signature. The crash occurrs on the thread named "SMimeVerify", that's expected. We perform the verification in the background, because it can be slow.
While looking at several crash reports, I noticed that at the time of the crash, we usually have at least two SMimeVerify threads running in parallel. In theory, that's fine. The user could have clicked on a first signed message, and then clicks on a second signed message, before the first verification has succeeded.
In theory, NSS should be fully thread safe, and allow the above concurrency. Lacking other ideas, we could attempt to avoid that concurrency, and allow only one SMimeVerify thread to actively make calls into NSS at any time, and see if it prevents this crash, or decreases its occurrence.
| Assignee | ||
Comment 37•7 years ago
|
||
How about using this patch for nightly, as an experiment?
Comment 38•7 years ago
|
||
Comment on attachment 9036649 [details] [diff] [review]
smime-verify-serialize-v1.patch
rs=jorgk, I'll land it tonight. Too bad I have switched off Nightlies due to the tree bustage since we don't know how badly TB is broken.
Updated•7 years ago
|
Updated•7 years ago
|
Comment 39•7 years ago
|
||
Comment 40•7 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/279f3823f223
experimental patch to investigate Thunderbird topcrash, serializes S/MIME verification. rs=jorgk
| Assignee | ||
Comment 41•7 years ago
|
||
We don't get many crash reports for nightly. Not seeing this crash in nightly, for a couple of days, seems normal. This could make it difficult to conclude whether this patch helps or not. Let's see how frequently we'll crash during the next week.
Links to related crash reports for nightly 66 (click "reports" on the pages):
https://is.gd/wr1kUg - https://is.gd/17PXKm - https://is.gd/6yzmJ4 - https://is.gd/B66Apf - https://is.gd/Xn6l0q
| Reporter | ||
Comment 42•7 years ago
•
|
||
(In reply to Kai Engert (:kaie:) from comment #41)
We don't get many crash reports for nightly. Not seeing this crash in nightly, for a couple of days, seems normal. This could make it difficult to conclude whether this patch helps or not.
This is typical for us - we often cannot draw conclusions until a patch hits beta channel. (nightly topcrashes are rare)
Actually, the signatures cited so far in this bug are even rare in beta - despite the high rate in release channel. But if the following two signatures are the same problem, then we can make a judgement when patch hits beta.
- nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature
- nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_ImportCerts | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature
Comment 43•7 years ago
|
||
I can stick it into TB 65 beta 3 which I'm planning to prepare tomorrow.
| Assignee | ||
Comment 44•7 years ago
|
||
(In reply to Wayne Mery (:wsmwk) from comment #42)
Actually, the signatures cited so far in this bug are even rare in beta - despite the high rate in release channel. But if the following two signatures are the same problem, then we can make a judgement when patch hits beta.
I think most of the crashes from the following query probably point to the same kind of issue:
https://is.gd/CZU16E
| Assignee | ||
Comment 45•7 years ago
|
||
Comment 46•7 years ago
|
||
Updated•7 years ago
|
Comment 47•7 years ago
|
||
| Reporter | ||
Comment 48•7 years ago
|
||
65.0bx crashes. Will need a few days of beta 4 to determine if the crashes gone, so should know by Monday Feb 4
this is the most common, with 0-8 crashes per day averaging 5/day - nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertificate | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature bp-c1ecea9d-a9fd-43f8-a234-791e10190108
nssCertificate_Destroy | NSSCertificate_Destroy | CERT_DestroyCertArray | NSS_CMSSignedData_ImportCerts | nsCMSMessage::CommonVerifySignature bp-5047eed3-a6ea-4089-b670-db9720190128
| Assignee | ||
Comment 49•7 years ago
|
||
What's the build ID of beta 4? Is it 20190123180341 ?
| Reporter | ||
Comment 50•7 years ago
|
||
(In reply to Kai Engert (:kaie:) from comment #49)
What's the build ID of beta 4? Is it 20190123180341 ?
| Assignee | ||
Comment 51•7 years ago
|
||
I don't see any crashes with the recent 65 betas, and no related crashes with 66 beta at all.
Wayne, can you confirm?
| Assignee | ||
Comment 52•7 years ago
|
||
(In reply to Dana Keeler (she/her) (use needinfo) (:keeler for reviews) from comment #39)
- static mozilla::Mutex *mLock;
fyi there's a static mutex type in the tree:
https://searchfox.org/mozilla-central/source/xpcom/base/StaticMutex.h
Dana, thanks a lot for pointing me to that, that's cleaner. If we decide to keep the mutex, I agree we should use that. Patch in bug 1522968 is updated.
| Reporter | ||
Comment 53•7 years ago
|
||
| Assignee | ||
Comment 54•7 years ago
|
||
Thanks Wayne, All crashes from 65beta are with build IDs that are older than beta 4.
I think the data confirms that our workaround helps.
If this workaround fixes the crash and memory corruption, it means that the S/MIME code inside Thunderbird isn't threadsafe. I've filed bug 1529003 to track that and get it potentially fixed at the NSS level. Bug 1529003 will require analysis, and it's not clear how much work that will be.
I suggest to keep the workaround for Thunderbird 68. Beta testing should show if the workaround has any negative effects.
At worst, if S/MIME verification is sometimes slow, users could experience delayed update of the signed/encrypted message status (icons shown).
If you'd like to consider applying the workaround to Thunderbird 60.x, we'd have to accept this risk.
Comment 55•7 years ago
|
||
Better slow than crashing ;-) - So not threadsafe leads to double-free?
| Assignee | ||
Comment 56•7 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #55)
So not threadsafe leads to double-free?
One thread might free it, and the data might get immediately overwritten, while another thread might still have a pointer to it, and read/write it.
| Assignee | ||
Comment 57•7 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #55)
Better slow than crashing ;-)
This patch backports the serialization to the esr60 branch (while using the better approach suggested by Dana).
Comment 58•7 years ago
|
||
Comment 59•7 years ago
|
||
| Assignee | ||
Comment 60•7 years ago
|
||
Of course you're right, because it's defined as a class member, thanks.
Comment 61•7 years ago
|
||
| Assignee | ||
Comment 62•7 years ago
|
||
Updated•7 years ago
|
Comment 63•7 years ago
|
||
Comment 64•7 years ago
|
||
| Reporter | ||
Comment 65•7 years ago
|
||
Agreed, the crash is gone for newer 66 betas
Great work!
Description
•