mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 01:32:33 +00:00
Fix: non-login requests shouldn't care about login roles for lease quotas. Also fix a potential deadlock (#21110)
* Use a deadlock-detecting mutex for auth/mountsLock * Remove call to DetermineRoleFromLoginRequest: we shouldn't be trying to apply roles to non-login lease quotas.
This commit is contained in:
4
changelog/21110.txt
Normal file
4
changelog/21110.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
```release-note:bug
|
||||
core/quotas (enterprise): Fix a case where we were applying login roles to lease count quotas in a non-login context.
|
||||
Also fix a related potential deadlock.
|
||||
```
|
||||
@@ -361,7 +361,7 @@ type Core struct {
|
||||
|
||||
// mountsLock is used to ensure that the mounts table does not
|
||||
// change underneath a calling function
|
||||
mountsLock sync.RWMutex
|
||||
mountsLock locking.DeadlockRWMutex
|
||||
|
||||
// mountMigrationTracker tracks past and ongoing remount operations
|
||||
// against their migration ids
|
||||
@@ -373,7 +373,7 @@ type Core struct {
|
||||
|
||||
// authLock is used to ensure that the auth table does not
|
||||
// change underneath a calling function
|
||||
authLock sync.RWMutex
|
||||
authLock locking.DeadlockRWMutex
|
||||
|
||||
// audit is loaded after unseal since it is a protected
|
||||
// configuration
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
@@ -34,6 +33,7 @@ import (
|
||||
"github.com/hashicorp/vault/helper/experiments"
|
||||
"github.com/hashicorp/vault/helper/hostutil"
|
||||
"github.com/hashicorp/vault/helper/identity"
|
||||
"github.com/hashicorp/vault/helper/locking"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/helper/metricsutil"
|
||||
"github.com/hashicorp/vault/helper/monitor"
|
||||
@@ -1720,7 +1720,7 @@ func (b *SystemBackend) handleTuneWriteCommon(ctx context.Context, path string,
|
||||
return nil, logical.ErrReadOnly
|
||||
}
|
||||
|
||||
var lock *sync.RWMutex
|
||||
var lock *locking.DeadlockRWMutex
|
||||
switch {
|
||||
case strings.HasPrefix(path, credentialRoutePrefix):
|
||||
lock = &b.Core.authLock
|
||||
|
||||
@@ -1021,11 +1021,9 @@ func (c *Core) handleRequest(ctx context.Context, req *logical.Request) (retResp
|
||||
}
|
||||
|
||||
leaseGenerated := false
|
||||
loginRole := c.DetermineRoleFromLoginRequest(req.MountPoint, req.Data, ctx)
|
||||
quotaResp, quotaErr := c.applyLeaseCountQuota(ctx, "as.Request{
|
||||
Path: req.Path,
|
||||
MountPath: strings.TrimPrefix(req.MountPoint, ns.Path),
|
||||
Role: loginRole,
|
||||
NamespacePath: ns.Path,
|
||||
})
|
||||
if quotaErr != nil {
|
||||
@@ -1165,7 +1163,7 @@ func (c *Core) handleRequest(ctx context.Context, req *logical.Request) (retResp
|
||||
return nil, auth, retErr
|
||||
}
|
||||
|
||||
leaseID, err := registerFunc(ctx, req, resp, loginRole)
|
||||
leaseID, err := registerFunc(ctx, req, resp, "")
|
||||
if err != nil {
|
||||
c.logger.Error("failed to register lease", "request_path", req.Path, "error", err)
|
||||
retErr = multierror.Append(retErr, ErrInternalError)
|
||||
|
||||
Reference in New Issue
Block a user