net: fix rare race in Tor stream isolation credentials #37043

pull PiRK wants to merge 1 commits into bitcoin:master from PiRK:net-tor-credentials-race changing 1 files +2 −2
  1. PiRK commented at 11:25 AM on December 2, 2026: contributor

    TorStreamIsolationCredentialsGenerator::Generate() reads m_counter to format the credentials, then increments it in a separate operation. The increment is atomic but the read and the increment together are not, so two threads calling Generate() at the same time (e.g. the automatic and added-node connection threads) can get the same credentials, and their connections may then share a Tor circuit.

    Use the value returned by fetch_add(), so that each call gets a distinct counter value.

  2. net: fix race in Tor stream isolation credentials
    TorStreamIsolationCredentialsGenerator::Generate() reads m_counter to
    format the credentials, then increments it in a separate operation. The
    increment is atomic but the read and the increment together are not, so
    two threads calling Generate() at the same time (e.g. the automatic and
    added-node connection threads) can get the same credentials, and their
    connections may then share a Tor circuit.
    
    Use the value returned by fetch_add(), so that each call gets a distinct
    counter value.
    b44500fc8d
  3. DrahtBot added the label P2P on Dec 2, 2026
  4. DrahtBot commented at 11:25 AM on December 2, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-12-05 04:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me