Commit Graph
108 Commits
Author SHA1 Message Date
Lars Eggert e6b6879528 Bug 2046785 - Drop loaded tokens based on user pref r=kershaw,necko-reviewers
Init() may have dispatched a TLS token load based on the default pref.
Now that the user pref is known to disable persistence, invalidate that
load and drop any records it already inserted.

Differential Revision: https://phabricator.services.mozilla.com/D306171
2026-06-11 16:19:07 +00:00
Lars Eggert 56b15c43d2 Bug 2046074 - Only count still-valid token evictions in network.ssl_token_cache_evictions r=kershaw,necko-reviewers
The metric is meant to signal that the cache capacity is too low and useful
resumption tokens are being discarded. Counting evictions of no-longer-valid
tokens is not useful.

Differential Revision: https://phabricator.services.mozilla.com/D305592
2026-06-10 13:23:47 +00:00
Silaghi 957cdf35c5 Revert "Bug 2046074 - Only count still-valid token evictions in network.ssl_token_cache_evictions r=kershaw,necko-reviewers" for causing gtest failures at EvictionCountsOnlyValidTokens
This reverts commit 7cbe6bbcd4.
2026-06-10 11:10:35 +00:00
Lars Eggert 7cbe6bbcd4 Bug 2046074 - Only count still-valid token evictions in network.ssl_token_cache_evictions r=kershaw,necko-reviewers
The metric is meant to signal that the cache capacity is too low and useful
resumption tokens are being discarded. Counting evictions of no-longer-valid
tokens is not useful.

Differential Revision: https://phabricator.services.mozilla.com/D305592
2026-06-10 10:19:26 +00:00
Lars Eggert 0d6540bb2c Bug 2039802 - Dedupe/compress SSLTokensCache cert chains r=valentin,kershaw,necko-reviewers
Replace the cert fields in TokenCacheRecord with refcounted
CompressedCert objects shared within each record.
The on-disk format advances to version 3.

Differential Revision: https://phabricator.services.mozilla.com/D300715
2026-06-09 11:53:17 +00:00
rperta 5dd9629155 Revert "Bug 2039802 - Dedupe/compress SSLTokensCache cert chains r=valentin,necko-reviewers" for causing xpc failures in pthread_mutex_lock
This reverts commit c87020184d.
2026-05-26 17:13:23 +00:00
Lars Eggert c87020184d Bug 2039802 - Dedupe/compress SSLTokensCache cert chains r=valentin,necko-reviewers
Replace the cert fields in TokenCacheRecord with refcounted
CompressedCert objects shared within each record.
The on-disk format advances to version 3.

Differential Revision: https://phabricator.services.mozilla.com/D300715
2026-05-26 08:56:43 +00:00
agoloman 728c76e2dd Revert "Bug 2039802 - Dedupe/compress SSLTokensCache cert chains r=valentin,necko-reviewers" for causing xpc failures in pthread_mutex_lock.
This reverts commit da4bd325ec.
2026-05-25 20:17:42 +00:00
Lars Eggert da4bd325ec Bug 2039802 - Dedupe/compress SSLTokensCache cert chains r=valentin,necko-reviewers
Replace the cert fields in TokenCacheRecord with refcounted
CompressedCert objects shared within each record.
The on-disk format advances to version 3.

Differential Revision: https://phabricator.services.mozilla.com/D300715
2026-05-25 12:44:47 +00:00
Lars Eggert 208dcf1f58 Bug 2040637 - Reconcile ssl_tokens_cache_persistence pref with user.js r=kershaw,necko-reviewers
SSLTokensCache::Init() runs before user prefs (user.js) are applied, so it
sees the compile-time default for network.ssl_tokens_cache_persistence.

Init() now registers the profile-after-change observer unconditionally
(before the pref check). The handler reconciles persistence state with
the actual pref value: enabling write observers and the shutdown blocker
if the pref is now true (Bug 2040637), or tearing them down if Init()
set them up but the pref is now false (Bug 2034342).

Differential Revision: https://phabricator.services.mozilla.com/D301474
2026-05-22 11:35:17 +00:00
Norisz Fay 3dba5504dc Revert "Bug 2040637 - Reconcile ssl_tokens_cache_persistence pref with user.js r=kershaw,necko-reviewers" for causing xpcshell failure @ test_ssl_token_cache_persist_disabled.js
This reverts commit b642b7f69c.
2026-05-22 03:12:34 +00:00
Lars Eggert b642b7f69c Bug 2040637 - Reconcile ssl_tokens_cache_persistence pref with user.js r=kershaw,necko-reviewers
SSLTokensCache::Init() runs before user prefs (user.js) are applied, so it
sees the compile-time default for network.ssl_tokens_cache_persistence.

Init() now registers the profile-after-change observer unconditionally
(before the pref check). The handler reconciles persistence state with
the actual pref value: enabling write observers and the shutdown blocker
if the pref is now true (Bug 2040637), or tearing them down if Init()
set them up but the pref is now false (Bug 2034342).

Differential Revision: https://phabricator.services.mozilla.com/D301474
2026-05-22 02:22:56 +00:00
Serban Stanca 2e71ef8d0c Revert "Bug 2040637 - Reconcile ssl_tokens_cache_persistence pref with user.js r=kershaw,necko-reviewers" for causing build bustages.
This reverts commit 5df70deaab.
2026-05-21 15:46:02 +00:00
Lars Eggert 5df70deaab Bug 2040637 - Reconcile ssl_tokens_cache_persistence pref with user.js r=kershaw,necko-reviewers
SSLTokensCache::Init() runs before user prefs (user.js) are applied, so it
sees the compile-time default for network.ssl_tokens_cache_persistence.

Init() now registers the profile-after-change observer unconditionally
(before the pref check). The handler reconciles persistence state with
the actual pref value: enabling write observers and the shutdown blocker
if the pref is now true (Bug 2040637), or tearing them down if Init()
set them up but the pref is now false (Bug 2034342).

Differential Revision: https://phabricator.services.mozilla.com/D301474
2026-05-21 15:33:23 +00:00
Lars Eggert c4412b9feb Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-15 12:56:39 +00:00
Sandor Molnar 780c3d4e24 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing mochitest failures @ test_pushState_structuredclone.html
This reverts commit f04d14e7b7.
2026-05-14 17:21:47 +00:00
Lars Eggert f04d14e7b7 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-14 12:14:14 +00:00
Silaghi a17b82f6b7 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing gecko decision task failure
This reverts commit b750c27334.
2026-05-14 10:23:33 +00:00
Lars Eggert b750c27334 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-14 10:13:37 +00:00
Lars Eggert 6f3d767fd2 Bug 2037014 - Remove TLS token cache Rust shadow copy r=kershaw,necko-reviewers
At write time, CollectSnapshotLocked builds a transient
nsTArray<SslTokensPersistedRecord> under sLock and serializes it via
ssl_tokens_cache_serialize_snapshot (still under the lock), then releases
the lock and writes off-lock via ssl_tokens_cache_write_bytes. Cert/token
copies are transient (write-time only). SerializeForIPC now holds sLock
across the full snapshot+serialize, eliminating the stale-snapshot race.
This should reduce memory usage.

SslTokensState, STATE, the four shadow FFI fns, ssl_tokens_cache_write,
ssl_tokens_cache_serialize, and all shadow-maintenance calls are removed.
On-disk STCF v2 format unchanged.

Differential Revision: https://phabricator.services.mozilla.com/D298524
2026-05-12 19:55:29 +00:00
Sandor Molnar 598130ca38 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing failures @ test_pushState_structuredclone
This reverts commit d93a479043.
2026-05-12 11:21:55 +00:00
Lars Eggert d93a479043 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-12 05:21:58 +00:00
Alexandru Marc 3b21498da8 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing assertion failures @ nsHttpConnectionMgr
This reverts commit 7215907801.
2026-05-11 07:20:31 +00:00
Lars Eggert 7215907801 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-11 05:20:29 +00:00
Alexandru Marc cf9739f8cd Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing mochitest failures
This reverts commit 4eb26f8538.
2026-05-06 21:33:28 +00:00
Lars Eggert 4eb26f8538 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-06 20:03:15 +00:00
agoloman 93ff7882db Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing mochitest failures.
This reverts commit 275a188195.
2026-05-05 23:45:56 +00:00
Lars Eggert 275a188195 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-05 21:41:53 +00:00
Alexandru Marc 8bd9f598ce Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing mochitest failures @ test_pushState_structuredclone
This reverts commit 9b778f1f8f.
2026-05-04 21:32:54 +00:00
Lars Eggert 9b778f1f8f Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-04 20:35:56 +00:00
Silaghi d50b57a53e Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing mochitest failures at libc_poll
This reverts commit ef1a8ca58c.
2026-05-04 16:29:13 +00:00
Lars Eggert ef1a8ca58c Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-05-04 08:11:03 +00:00
rperta f282800d68 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing multiple wd failures
This reverts commit 11868f9efc.
2026-04-29 23:23:05 +00:00
Lars Eggert 11868f9efc Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-04-29 21:09:43 +00:00
Silaghi 517faa9677 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing bpgo and mda failures at /ProtocolUtils
This reverts commit aaf787248f.
2026-04-29 15:52:40 +00:00
Lars Eggert aaf787248f Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-04-29 14:43:29 +00:00
Alexandru Marc 05036feab6 Revert "Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers" for causing failures at ProtocolUtils
This reverts commit 0eab754180.
2026-04-29 10:36:50 +00:00
Lars Eggert 0eab754180 Bug 2035453 - Install 0-RTT token writer on profile-after-change r=kershaw,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D296961
2026-04-29 09:22:30 +00:00
Lars Eggert 20056cebcd Bug 2033907 - Persist cert chain data in ssl_tokens_cache.bin r=valentin,necko-reviewers
Extend SslTokensPersistedRecordFfi and PersistedRecord with server_cert,
succeeded_cert_chain, handshake_certs, and is_built_cert_chain_root_built_in_root
fields. Bump the on-disk format version to 2.

Add regression tests: PersistenceServerCertRoundTrip verifies all cert fields
survive a write/clear/load cycle; ResumedConnectionHasValidCertAfterReload and
ResumedConnectionEnablesCoalescing verify that RebuildCertificateInfoFromSSLTokenCache()
produces a valid cert and a populated succeeded-chain after disk reload.

Differential Revision: https://phabricator.services.mozilla.com/D295649
2026-04-26 08:34:52 +00:00
Lars Eggert be9e8189a9 Bug 2026701 - Annotate all mutex/monitor usages in netwerk r=valentin,necko-reviewers,webrtc-reviewers,cookie-reviewers,jesup,bwc
Eliminates most MOZ_UNANNOTATED occurrences in netwerk/, enabling
Clang's -Wthread-safety analyzer to enforce lock discipline across the
entire directory. The remaining occurrence (nsHttpChannel::mRCWNLock) is
intentionally left as MOZ_UNANNOTATED; it will be removed by D285971.

35 locks receive proper MOZ_GUARDED_BY/MOZ_REQUIRES annotations. 8 locks
are marked MOZ_ANNOTATED where annotation is genuinely not appropriate
(pure condition variables, write-once-then-read-without-lock patterns,
hot paths with intentional lockless reads).

Beyond mechanical marker removal, the annotations surfaced several real
access pattern issues that were fixed: lockless reads in nsUDPSocket,
nsServerSocket, TLSServerSocket, nsHttpConnection, HttpConnectionUDP,
HttpTransactionParent, HttpBackgroundChannelParent, nsHttpActivityDistributor,
and NetlinkService (Linux-only, surfaced by CI); plus a double-checked lockless
read in nsHostResolver::FromUnspecEntry. Initialization-time writes use
MOZ_PUSH_IGNORE_THREAD_SAFETY since no race is possible before the object
is shared.

Differential Revision: https://phabricator.services.mozilla.com/D290185
2026-04-24 09:12:31 +00:00
Lars Eggert ffb57c074b Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.

This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
  socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
  and application-background via SSLTokensCacheData; parent persists on the
  next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
  FlushSSLTokensCache() before writing the file during ProfileBeforeChange.

Differential Revision: https://phabricator.services.mozilla.com/D294106
2026-04-22 09:38:11 +00:00
Norisz Fay aa2762217b Revert "Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers" for causing nsIOService.cpp related failures
This reverts commit c257072410.
2026-04-21 21:12:19 +00:00
Lars Eggert c257072410 Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.

This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
  socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
  and application-background via SSLTokensCacheData; parent persists on the
  next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
  FlushSSLTokensCache() before writing the file during ProfileBeforeChange.

Differential Revision: https://phabricator.services.mozilla.com/D294106
2026-04-21 20:24:15 +00:00
Serban Stanca 69fbde744f Revert "Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers" for causing Linux build bustages.
This reverts commit b38dec6c3f.
2026-04-16 13:38:36 +00:00
Lars Eggert b38dec6c3f Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.

This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
  socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
  and application-background via SSLTokensCacheData; parent persists on the
  next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
  FlushSSLTokensCache() before writing the file during ProfileBeforeChange.

Differential Revision: https://phabricator.services.mozilla.com/D294106
2026-04-16 13:17:58 +00:00
pstanciu 5431ecc7f8 Revert "Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers" for causing build bustages @ rust.mk
This reverts commit 187d6d7171.
2026-04-16 11:25:44 +00:00
Lars Eggert 187d6d7171 Bug 2031594 - Forward SSL session tokens between socket and parent process r=kershaw,necko-reviewers
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.

This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
  socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
  and application-background via SSLTokensCacheData; parent persists on the
  next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
  FlushSSLTokensCache() before writing the file during ProfileBeforeChange.

Differential Revision: https://phabricator.services.mozilla.com/D294106
2026-04-16 11:03:48 +00:00
Lars Eggert fd3f821ad1 Bug 2024146 - Persist the SSL session token cache across restarts r=valentin,necko-reviewers,keeler,emz
Serialize SSLTokensCache to ssl_tokens_cache.bin so TLS session tickets
survive browser restarts, enabling 0-RTT on first connections. A new Rust
crate handles zlib-compressed (Adler-32 integrity) bincode serialization
and atomic tmp→rename writes. Cert chain data is excluded from the
persisted format.

The cache writes to disk when the application is backgrounded (covering
Android OOM kills), daily when idle, and at graceful shutdown via
nsIAsyncShutdownBlocker, keeping all file I/O off the main thread. The
background read uses nsAutoLowPriorityIO to yield disk bandwidth to
startup-critical reads. Consumed and evicted tokens are removed from the
Rust shadow immediately, bounding its memory use independently of write
frequency.

The cache is always partitioned by top-level site via OriginAttributes,
matching cookie-partitioning semantics. CLEAR_TLS_TOKEN_CACHE is part of
CLEAR_COOKIES_AND_SITE_DATA and CLEAR_FORGET_ABOUT_SITE.

Differential Revision: https://phabricator.services.mozilla.com/D288348
2026-04-10 12:10:36 +00:00
Sandor Molnar afb728ed15 Revert "Bug 2024146 - Persist the SSL session token cache across restarts r=valentin,necko-reviewers,keeler,emz" for causing mochitest crashes
This reverts commit 617c3db6aa.
2026-04-09 17:45:31 +00:00
Lars Eggert 617c3db6aa Bug 2024146 - Persist the SSL session token cache across restarts r=valentin,necko-reviewers,keeler,emz
Serialize SSLTokensCache to ssl_tokens_cache.bin so TLS session tickets
survive browser restarts, enabling 0-RTT on first connections. A new Rust
crate handles zlib-compressed (Adler-32 integrity) bincode serialization
and atomic tmp→rename writes. Cert chain data is excluded from the
persisted format.

The cache writes to disk when the application is backgrounded (covering
Android OOM kills), daily when idle, and at graceful shutdown via
nsIAsyncShutdownBlocker, keeping all file I/O off the main thread. The
background read uses nsAutoLowPriorityIO to yield disk bandwidth to
startup-critical reads. Consumed and evicted tokens are removed from the
Rust shadow immediately, bounding its memory use independently of write
frequency.

The cache is always partitioned by top-level site via OriginAttributes,
matching cookie-partitioning semantics. CLEAR_TLS_TOKEN_CACHE is part of
CLEAR_COOKIES_AND_SITE_DATA and CLEAR_FORGET_ABOUT_SITE.

Differential Revision: https://phabricator.services.mozilla.com/D288348
2026-04-09 14:05:24 +00:00