Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data race around static secret capability manager #28653

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

VioletHynes
Copy link
Contributor

@VioletHynes VioletHynes commented Oct 9, 2024

Description

Needed to copy the map behind the locking.

WARNING: DATA RACE
Write at 0x00c01a2f3470 by goroutine 86930:
  runtime.mapassign_faststr()
      /home/runner/actions-runner/_work/_tool/go/1.22.7/x64/src/runtime/map_faststr.go:203 +0x0
  github.com/hashicorp/vault/command/agentproxyshared/cache.(*LeaseCache).storeStaticSecretIndex()
      /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/command/agentproxyshared/cache/lease_cache.go:801 +0x5e4
  github.com/hashicorp/vault/command/agentproxyshared/cache.(*LeaseCache).cacheStaticSecret()
      /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/command/agentproxyshared/cache/lease_cache.go:696 +0x145e
  github.com/hashicorp/vault/command/agentproxyshared/cache.(*LeaseCache).Send()
      /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/command/agentproxyshared/cache/lease_cache.go:502 +0x22d6
  github.com/hashicorp/vault/command.(*ProxyCommand).Run.ProxyHandler.func13()
      /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/command/agentproxyshared/cache/handler.go:63 +0x5e5
  net/http.HandlerFunc.ServeHTTP()
      /home/runner/actions-runner/_work/_tool/go/1.22.7/x64/src/net/http/server.go:2171 +0x47
  net/http.(*ServeMux).ServeHTTP()
      /home/runner/actions-runner/_work/_tool/go/1.22.7/x64/src/net/http/server.go:2688 +0x1ef
  net/http.serverHandler.ServeHTTP()
      /home/runner/actions-runner/_work/_tool/go/1.22.7/x64/src/net/http/server.go:3142 +0x2a1
  net/http.(*conn).serve()
      /home/runner/actions-runner/_work/_tool/go/1.22.7/x64/src/net/http/server.go:2044 +0x13c4
  net/http.(*Server).Serve.gowrap3()
      /home/runner/actions-runner/_work/_tool/go/1.22.7/x64/src/net/http/server.go:3290 +0x4f

Previous read at 0x00c01a2f3470 by goroutine 87090:
  golang.org/x/exp/maps.Keys[go.shape.map[string]struct {},go.shape.string,go.shape.struct {}]()
      /home/runner/go/pkg/mod/golang.org/x/[email protected]/maps/maps.go:11 +0x27b
  github.com/hashicorp/vault/command/agentproxyshared/cache.(*StaticSecretCapabilityManager).StartRenewingCapabilities.func1()
      /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/command/agentproxyshared/cache/static_secret_capability_manager.go:148 +0x305
  github.com/gammazero/workerpool.worker()
      /home/runner/go/pkg/mod/github.com/gammazero/[email protected]/workerpool.go:237 +0x35
  github.com/gammazero/workerpool.(*WorkerPool).dispatch.gowrap2()
      /home/runner/go/pkg/mod/github.com/gammazero/[email protected]/workerpool.go:197 +0x4f

TODO only if you're a HashiCorp employee

  • Backport Labels: If this PR is in the ENT repo and needs to be backported, backport
    to N, N-1, and N-2, using the backport/ent/x.x.x+ent labels. If this PR is in the CE repo, you should only backport to N, using the backport/x.x.x label, not the enterprise labels.
    • If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Oct 9, 2024
@VioletHynes VioletHynes added backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.17.x backport/1.18.x pr/no-changelog pr/no-milestone and removed hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed labels Oct 9, 2024
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Oct 9, 2024
Copy link

github-actions bot commented Oct 9, 2024

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented Oct 9, 2024

Build Results:
All builds succeeded! ✅

@VioletHynes VioletHynes merged commit 210da8f into main Oct 9, 2024
90 checks passed
@VioletHynes VioletHynes deleted the violethynes/fix-data-race-2024-10-09 branch October 9, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.18.x hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog pr/no-milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants