diff --git a/changelog/11453.txt b/changelog/11453.txt new file mode 100644 index 000000000..8549b536a --- /dev/null +++ b/changelog/11453.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fix race that allowed remounting on path used by another mount +``` diff --git a/vault/mount.go b/vault/mount.go index b5f250ec7..ee024b806 100644 --- a/vault/mount.go +++ b/vault/mount.go @@ -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 { diff --git a/vault/mount_test.go b/vault/mount_test.go index cd1f8f942..5484376b3 100644 --- a/vault/mount_test.go +++ b/vault/mount_test.go @@ -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()