[VAULT-1441] Fix race that allowed remounting on path used by another mount (#11453)

* remount concurrent test fix

* changelog

* Update changelog/11453.txt

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
This commit is contained in:
Hridoy Roy 2021-04-24 09:05:41 -07:00 committed by GitHub
parent 490474a502
commit 22cab6185d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 19 deletions

3
changelog/11453.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
core: Fix race that allowed remounting on path used by another mount
```

View File

@ -938,12 +938,13 @@ func (c *Core) remount(ctx context.Context, src, dst string, updateStorage bool)
c.logger.Error("failed to update mounts table", "error", err)
return logical.CodedError(500, "failed to update mounts table")
}
c.mountsLock.Unlock()
// Remount the backend
if err := c.router.Remount(ctx, src, dst); err != nil {
c.mountsLock.Unlock()
return err
}
c.mountsLock.Unlock()
// Un-taint the path
if err := c.router.Untaint(ctx, dst); err != nil {

View File

@ -472,16 +472,6 @@ func TestCore_RemountConcurrent(t *testing.T) {
t.Fatalf("err: %v", err)
}
mount3 := &MountEntry{
Table: mountTableType,
Path: "test3/",
Type: "noop",
}
if err := c2.mount(namespace.RootContext(nil), mount3); err != nil {
t.Fatalf("err: %v", err)
}
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
@ -492,14 +482,6 @@ func TestCore_RemountConcurrent(t *testing.T) {
}
}()
wg.Add(1)
go func() {
defer wg.Done()
err := c2.remount(namespace.RootContext(nil), "test2", "foo", true)
if err != nil {
t.Logf("err: %v", err)
}
}()
wg.Add(1)
go func() {
defer wg.Done()