Skip to content

Commit

Permalink
[VAULT-1441] Fix race that allowed remounting on path used by another…
Browse files Browse the repository at this point in the history
… mount (#11453)

* remount concurrent test fix

* changelog

* Update changelog/11453.txt

Co-authored-by: Nick Cabatoff <[email protected]>

Co-authored-by: Nick Cabatoff <[email protected]>
  • Loading branch information
Hridoy Roy and ncabatoff authored Apr 24, 2021
1 parent 0d2ae70 commit efd19a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
3 changes: 3 additions & 0 deletions changelog/11453.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core: Fix race that allowed remounting on path used by another mount
```
3 changes: 2 additions & 1 deletion vault/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 0 additions & 18 deletions vault/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()
Expand Down

0 comments on commit efd19a2

Please sign in to comment.