Skip to content

Commit

Permalink
[Server] Close race condition between bind and the use of that bind.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 authored and gganis committed Nov 23, 2021
1 parent 2ca9e4f commit 2319787
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/XrdXrootd/XrdXrootdXeq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ int XrdXrootdProtocol::do_Bind()
return Response.Send(kXR_NotAuthorized, "cross-host bind not allowed");
}

// We need to hold the parent's stream mutex to prevent inspection or
// modification of other parallel binds that may occur
//
XrdSysMutexHelper smHelper(pp->streamMutex);

// Find a slot for this path in parent protocol
//
for (i = 1; i < maxStreams && pp->Stream[i]; i++) {}
Expand All @@ -313,8 +318,6 @@ int XrdXrootdProtocol::do_Bind()
pp->Stream[i] = this;
Stream[0] = pp;
PathID = i;
sprintf(buff, "FD %d#%d bound", Link->FDnum(), i);
eDest.Log(SYS_LOG_01, "Xeq", buff, lp->ID);

// Construct a login name for this bind session
//
Expand All @@ -328,6 +331,12 @@ int XrdXrootdProtocol::do_Bind()
Status = XRD_BOUNDPATH;
clientPV = pp->clientPV;

// Document the bind
//
smHelper.UnLock();
sprintf(buff, "FD %d#%d bound", Link->FDnum(), i);
eDest.Log(SYS_LOG_01, "Xeq", buff, lp->ID);

// Get the required number of parallel I/O objects
//
pioFree = XrdXrootdPio::Alloc(maxPio);
Expand Down

0 comments on commit 2319787

Please sign in to comment.