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

Backport of Clone things to prevent races. into release/1.10.x #15127

Conversation

hc-github-team-secure-vault-core
Copy link
Collaborator

Backport

This PR is auto-generated from #15123 to be assessed for backporting due to the inclusion of the label backport/1.10.x.

The below text is copied from the body of the original PR.


An example of one of the races is here: https://app.circleci.com/pipelines/github/hashicorp/vault-enterprise/12932/workflows/33d46609-5096-4018-9f06-a73a258ced2e/jobs/375638

While testing the fix for that (the one in identity_store_util) by running untilfail against TestReplicationApi_ApproleLocal_MultiNodeMultiLogin, I found this race:

WARNING: DATA RACE
Write at 0x00c0026c4308 by goroutine 435:
  github.com/hashicorp/vault/vault.(*IdentityStore).mergeEntity()
      /Users/ncc/hc/vault-enterprise/vault/identity_store_entities.go:804 +0x14c0
  github.com/hashicorp/vault/vault.(*IdentityStore).upsertEntityInTxn()
      /Users/ncc/hc/vault-enterprise/vault/identity_store_util.go:597 +0x12f8
  github.com/hashicorp/vault/vault.(*IdentityStore).processLocalAlias()
      /Users/ncc/hc/vault-enterprise/vault/identity_store_util.go:732 +0xd00
  github.com/hashicorp/vault/vault.(*replicationServiceHandler).RegisterLocalAliasRequest()
      /Users/ncc/hc/vault-enterprise/vault/replication_rpc_ent.go:914 +0x3c4
  github.com/hashicorp/vault/vault.(*standbyReplicationServiceHandler).RegisterLocalAliasRequest()
      <autogenerated>:1 +0x5c
  github.com/hashicorp/vault/vault._Replication_RegisterLocalAliasRequest_Handler()
      /Users/ncc/hc/vault-enterprise/vault/replication_services_ent_grpc.pb.go:641 +0x1f4
  google.golang.org/grpc.(*Server).processUnaryRPC()
      /Users/ncc/go/pkg/mod/google.golang.org/grpc@v1.44.0/server.go:1282 +0xf00
  google.golang.org/grpc.(*Server).handleStream()
      /Users/ncc/go/pkg/mod/google.golang.org/grpc@v1.44.0/server.go:1616 +0xc00
  google.golang.org/grpc.(*Server).serveStreams.func1.2()
      /Users/ncc/go/pkg/mod/google.golang.org/grpc@v1.44.0/server.go:921 +0xa4

Previous read at 0x00c0026c4308 by goroutine 285:
  google.golang.org/protobuf/internal/impl.appendStringNoZeroValidateUTF8()
      /Users/ncc/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/codec_gen.go:5021 +0x54
  google.golang.org/protobuf/internal/impl.(*MessageInfo).marshalAppendPointer()
      /Users/ncc/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/encode.go:139 +0x30c
  google.golang.org/protobuf/internal/impl.(*MessageInfo).marshal()
      /Users/ncc/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/encode.go:107 +0xac
  google.golang.org/protobuf/internal/impl.(*MessageInfo).marshal-fm()
      <autogenerated>:1 +0x84
  google.golang.org/protobuf/proto.MarshalOptions.marshal()
      /Users/ncc/go/pkg/mod/google.golang.org/protobuf@v1.27.1/proto/encode.go:163 +0x2bc
  google.golang.org/protobuf/proto.MarshalOptions.MarshalAppend()
      /Users/ncc/go/pkg/mod/google.golang.org/protobuf@v1.27.1/proto/encode.go:122 +0x78
  github.com/golang/protobuf/proto.marshalAppend()
      /Users/ncc/go/pkg/mod/github.com/golang/protobuf@v1.5.2/proto/wire.go:40 +0x90
  github.com/golang/protobuf/proto.Marshal()
      /Users/ncc/go/pkg/mod/github.com/golang/protobuf@v1.5.2/proto/wire.go:23 +0x4c
  github.com/hashicorp/vault/helper/identity.(*Alias).Clone()
      /Users/ncc/hc/vault-enterprise/helper/identity/identity.go:63 +0x1c
  github.com/hashicorp/vault/vault.(*IdentityStore).MemDBAliasByFactorsInTxn()
      /Users/ncc/hc/vault-enterprise/vault/identity_store_util.go:977 +0x1f8
  github.com/hashicorp/vault/vault.(*IdentityStore).MemDBAliasByFactors()
      /Users/ncc/hc/vault-enterprise/vault/identity_store_util.go:941 +0xd0
  github.com/hashicorp/vault/vault.(*IdentityStore).processLocalAlias()
      /Users/ncc/hc/vault-enterprise/vault/identity_store_util.go:670 +0x11c
  github.com/hashicorp/vault/vault.(*replicationServiceHandler).RegisterLocalAliasRequest()
      /Users/ncc/hc/vault-enterprise/vault/replication_rpc_ent.go:914 +0x3c4
  github.com/hashicorp/vault/vault.(*standbyReplicationServiceHandler).RegisterLocalAliasRequest()
      <autogenerated>:1 +0x5c
  github.com/hashicorp/vault/vault._Replication_RegisterLocalAliasRequest_Handler()
  google.golang.org/grpc.(*Server).processUnaryRPC() 
      /Users/ncc/go/pkg/mod/google.golang.org/grpc@v1.44.0/server.go:1282 +0xf00 
  google.golang.org/grpc.(*Server).handleStream() 
      /Users/ncc/go/pkg/mod/google.golang.org/grpc@v1.44.0/server.go:1616 +0xc00 
  google.golang.org/grpc.(*Server).serveStreams.func1.2() 
      /Users/ncc/go/pkg/mod/google.golang.org/grpc@v1.44.0/server.go:921 +0xa4 

@ncabatoff ncabatoff merged commit d0a86db into release/1.10.x May 19, 2022
@ncabatoff ncabatoff deleted the backport/fix-local-alias-race/painfully-diverse-tadpole branch May 19, 2022 13:21
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.

3 participants