From 02a765743ef516de0660b48062bad97a5cac6d2b Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Tue, 2 Aug 2022 12:21:32 -0700 Subject: [PATCH] ssh/tailssh: fix deadlock in expandDelegateURL Also rename it to expandDelegateURLLocked, previously it was trying to acquire the mutex while holding the mutex. Fixes #5235 Signed-off-by: Maisem Ali --- ssh/tailssh/tailssh.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ssh/tailssh/tailssh.go b/ssh/tailssh/tailssh.go index 7d6ad72e6..9ba4183d0 100644 --- a/ssh/tailssh/tailssh.go +++ b/ssh/tailssh/tailssh.go @@ -696,7 +696,7 @@ func (c *conn) resolveTerminalActionLocked(s ssh.Session, cr *contextReader) (ac } }() }) - url = c.expandDelegateURL(url) + url = c.expandDelegateURLLocked(url) var err error action, err = c.fetchSSHAction(ctx, url) if err != nil { @@ -711,12 +711,10 @@ func (c *conn) resolveTerminalActionLocked(s ssh.Session, cr *contextReader) (ac } } -func (c *conn) expandDelegateURL(actionURL string) string { +func (c *conn) expandDelegateURLLocked(actionURL string) string { nm := c.srv.lb.NetMap() - c.mu.Lock() ci := c.info lu := c.localUser - c.mu.Unlock() var dstNodeID string if nm != nil { dstNodeID = fmt.Sprint(int64(nm.SelfNode.ID))