[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:
parent
490474a502
commit
22cab6185d
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
core: Fix race that allowed remounting on path used by another mount
|
||||||
|
```
|
|
@ -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)
|
c.logger.Error("failed to update mounts table", "error", err)
|
||||||
return logical.CodedError(500, "failed to update mounts table")
|
return logical.CodedError(500, "failed to update mounts table")
|
||||||
}
|
}
|
||||||
c.mountsLock.Unlock()
|
|
||||||
|
|
||||||
// Remount the backend
|
// Remount the backend
|
||||||
if err := c.router.Remount(ctx, src, dst); err != nil {
|
if err := c.router.Remount(ctx, src, dst); err != nil {
|
||||||
|
c.mountsLock.Unlock()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.mountsLock.Unlock()
|
||||||
|
|
||||||
// Un-taint the path
|
// Un-taint the path
|
||||||
if err := c.router.Untaint(ctx, dst); err != nil {
|
if err := c.router.Untaint(ctx, dst); err != nil {
|
||||||
|
|
|
@ -472,16 +472,6 @@ func TestCore_RemountConcurrent(t *testing.T) {
|
||||||
t.Fatalf("err: %v", err)
|
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 := &sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
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)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
Loading…
Reference in New Issue