As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit f45fb8de authored by Igor Drozdov's avatar Igor Drozdov
Browse files

Fix race conditions in GSSAPI calls

The GSSAPI functions are using shared contextId value. We need
to use mutex to make sure that simultaneous calls to it work
correctly.
parent 2b2e560e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4,6 +4,7 @@ package sshd
import (
"fmt"
"sync"
"github.com/openshift/gssapi"
Loading
Loading
@@ -41,6 +42,7 @@ type OSGSSAPIServer struct {
Keytab string
ServicePrincipalName string
mutex sync.RWMutex
contextId *gssapi.CtxId
}
Loading
Loading
@@ -62,6 +64,9 @@ func (server *OSGSSAPIServer) AcceptSecContext(
needContinue bool,
err error,
) {
server.mutex.Lock()
defer server.mutex.Unlock()
tokenBuffer, err := lib.MakeBufferBytes(token)
if err != nil {
return
Loading
Loading
@@ -111,6 +116,9 @@ func (server *OSGSSAPIServer) VerifyMIC(
micField []byte,
micToken []byte,
) error {
server.mutex.Lock()
defer server.mutex.Unlock()
if server.contextId == nil {
return fmt.Errorf("gssapi: uninitialized contextId")
}
Loading
Loading
@@ -132,6 +140,9 @@ func (server *OSGSSAPIServer) VerifyMIC(
}
func (server *OSGSSAPIServer) DeleteSecContext() error {
server.mutex.Lock()
defer server.mutex.Unlock()
if server.contextId == nil {
return nil
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment