Skip to content

pipe: Fix ListenPipe/DialPipe race#125

Merged
lowenna merged 1 commit intomicrosoft:masterfrom
jstarks:listenpipe
Apr 8, 2019
Merged

pipe: Fix ListenPipe/DialPipe race#125
lowenna merged 1 commit intomicrosoft:masterfrom
jstarks:listenpipe

Conversation

@jstarks
Copy link
Member

@jstarks jstarks commented Apr 8, 2019

ListenPipe can fail if there is a concurrent DialPipe because there is a
race window where DialPipe can connect to the initial server named pipe
before it is connected to and closed by ListenPipe.

To fix this, use the lower-level NT API for creating the server pipe,
since this API allows for specifying that a server pipe should initially
be in the disconnected state instead of the listening state. This allows
us to avoid the race condition by creating the pipe in the correct state
initially, so there is no longer a need to create a dummy client
connection.

ListenPipe can fail if there is a concurrent DialPipe because there is a
race window where DialPipe can connect to the initial server named pipe
before it is connected to and closed by ListenPipe.

To fix this, use the lower-level NT API for creating the server pipe,
since this API allows for specifying that a server pipe should initially
be in the disconnected state instead of the listening state. This allows
us to avoid the race condition by creating the pipe in the correct state
initially, so there is no longer a need to create a dummy client
connection.
@jstarks jstarks requested review from jterry75 and lowenna April 8, 2019 17:09
@lowenna
Copy link
Contributor

lowenna commented Apr 8, 2019

Looks scarily good to me.

@lowenna
Copy link
Contributor

lowenna commented Apr 8, 2019

@jterry75 I'll vendor this into hcsshim.

@lowenna lowenna merged commit 84b4ab4 into microsoft:master Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants