import changes from mozilla nss repo:

- Bug 1641480, TLS 1.3: tighten CCS handling in compatibility mode, r=mt
- Bug 1672703, always tolerate the first CCS in TLS 1.3, r=mt
- Bug 1663661 - Guard against NULL token in nssSlot_IsTokenPresent. r=jcj
- Bug 1607449 - Lock cert->nssCertificate to prevent data race. r=jcj,keeler
- Bug 1679290 - Don't hold slot lock when taking session lock r=bbeurdouche
This commit is contained in:
roytam1 2020-12-02 10:52:47 +08:00
commit ecf2071a46
9 changed files with 184 additions and 29 deletions

View file

@ -2908,16 +2908,27 @@ CERT_LockCertTrust(const CERTCertificate *cert)
PZ_Lock(certTrustLock);
}
static PZLock *certTempPermLock = NULL;
static PZLock *certTempPermCertLock = NULL;
/*
* Acquire the cert temp/perm lock
* Acquire the cert temp/perm/nssCert lock
*/
void
CERT_LockCertTempPerm(const CERTCertificate *cert)
{
PORT_Assert(certTempPermLock != NULL);
PZ_Lock(certTempPermLock);
PORT_Assert(certTempPermCertLock != NULL);
PZ_Lock(certTempPermCertLock);
}
/* Maybe[Lock, Unlock] variants are only to be used by
* CERT_DestroyCertificate, since an application could
* call this after NSS_Shutdown destroys cert locks. */
void
CERT_MaybeLockCertTempPerm(const CERTCertificate *cert)
{
if (certTempPermCertLock) {
PZ_Lock(certTempPermCertLock);
}
}
SECStatus
@ -2941,10 +2952,10 @@ cert_InitLocks(void)
}
}
if (certTempPermLock == NULL) {
certTempPermLock = PZ_NewLock(nssILockCertDB);
PORT_Assert(certTempPermLock != NULL);
if (!certTempPermLock) {
if (certTempPermCertLock == NULL) {
certTempPermCertLock = PZ_NewLock(nssILockCertDB);
PORT_Assert(certTempPermCertLock != NULL);
if (!certTempPermCertLock) {
PZ_DestroyLock(certTrustLock);
PZ_DestroyLock(certRefCountLock);
certRefCountLock = NULL;
@ -2977,10 +2988,10 @@ cert_DestroyLocks(void)
rv = SECFailure;
}
PORT_Assert(certTempPermLock != NULL);
if (certTempPermLock) {
PZ_DestroyLock(certTempPermLock);
certTempPermLock = NULL;
PORT_Assert(certTempPermCertLock != NULL);
if (certTempPermCertLock) {
PZ_DestroyLock(certTempPermCertLock);
certTempPermCertLock = NULL;
} else {
rv = SECFailure;
}
@ -2999,16 +3010,24 @@ CERT_UnlockCertTrust(const CERTCertificate *cert)
}
/*
* Free the temp/perm lock
* Free the temp/perm/nssCert lock
*/
void
CERT_UnlockCertTempPerm(const CERTCertificate *cert)
{
PORT_Assert(certTempPermLock != NULL);
PRStatus prstat = PZ_Unlock(certTempPermLock);
PORT_Assert(certTempPermCertLock != NULL);
PRStatus prstat = PZ_Unlock(certTempPermCertLock);
PORT_AssertArg(prstat == PR_SUCCESS);
}
void
CERT_MaybeUnlockCertTempPerm(const CERTCertificate *cert)
{
if (certTempPermCertLock) {
PZ_Unlock(certTempPermCertLock);
}
}
/*
* Get the StatusConfig data for this handle
*/