Skip to content

[SoftCSA] Add double-buffered keys to eliminate data race in descrambling#3702

Merged
atvcaptain merged 2 commits intoopenatv:masterfrom
WXbet:softcsa-threading
Feb 10, 2026
Merged

[SoftCSA] Add double-buffered keys to eliminate data race in descrambling#3702
atvcaptain merged 2 commits intoopenatv:masterfrom
WXbet:softcsa-threading

Conversation

@WXbet
Copy link
Contributor

@WXbet WXbet commented Feb 10, 2026

setKey() (CWHandler thread) and descramble() (recorder thread) access
the same dvbcsa_bs_key_t concurrently. key_set_ecm() rewrites the
internal key schedule while decrypt() reads it, causing intermittent
audio dropouts and brief freezes.

Each parity now has two key slots. setKey() writes the inactive slot,
then atomically publishes the new index (release). descramble() snapshots
the active index once per call (acquire) and uses it throughout, so it
never sees a partially-written key schedule.

WXbet added 2 commits February 9, 2026 19:20
…ling

setKey() (CWHandler thread) and descramble() (recorder thread) access
the same dvbcsa_bs_key_t concurrently. key_set_ecm() rewrites the
internal key schedule while decrypt() reads it, causing intermittent
audio dropouts and brief freezes.

Each parity now has two key slots. setKey() writes the inactive slot,
then atomically publishes the new index (release). descramble() snapshots
the active index once per call (acquire) and uses it throughout, so it
never sees a partially-written key schedule.
- Check return value of ::write() calls to wake pipe
- Replace EWOULDBLOCK with EINTR (EAGAIN == EWOULDBLOCK on Linux,
  causing -Werror=logical-op failure)
@atvcaptain atvcaptain merged commit 08c2371 into openatv:master Feb 10, 2026
3 of 4 checks passed
atvcaptain pushed a commit that referenced this pull request Feb 10, 2026
…ling (#3702)

* [SoftCSA] Add double-buffered keys to eliminate data race in descrambling

setKey() (CWHandler thread) and descramble() (recorder thread) access
the same dvbcsa_bs_key_t concurrently. key_set_ecm() rewrites the
internal key schedule while decrypt() reads it, causing intermittent
audio dropouts and brief freezes.

Each parity now has two key slots. setKey() writes the inactive slot,
then atomically publishes the new index (release). descramble() snapshots
the active index once per call (acquire) and uses it throughout, so it
never sees a partially-written key schedule.

* [cwhandler] Fix build warnings treated as errors

- Check return value of ::write() calls to wake pipe
- Replace EWOULDBLOCK with EINTR (EAGAIN == EWOULDBLOCK on Linux,
  causing -Werror=logical-op failure)
@WXbet WXbet deleted the softcsa-threading branch February 11, 2026 21:56
jbleyel added a commit that referenced this pull request Feb 12, 2026
* master:
  Use windowTitle parameter instead of setTitle after init of MessageBox
  [CAHandler] Send CMD_NOT_SELECTED when last service is unregistered
  [SoftCSA] Suppress activation when CI module handles decryption
  Revert "[SoftCSA] Deactivate software descrambling when CI module handles decryption"
  pot update
  translation update
  [servicedvb] * re-enable precise recovery feature to fix time shift issues * add extra setting for hardware latency correction for DM9x0
  [ChannelSelection] Fix new crash https://www.opena.tv/viewtopic.php?p=597368&sid=6f7566164c0518ad0230b534dfb5889e#p597368
  translation update
  [SoftCSA] Add double-buffered keys to eliminate data race in descrambling (#3702)
  [cahandler] Skip CLIENT_INFO on reconnects for legacy softcams (#3700)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants