Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Path Removal Underflow #3624

Merged
merged 3 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/core/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ QuicPathInitialize(
{
CxPlatZeroMemory(Path, sizeof(QUIC_PATH));
Path->ID = Connection->NextPathId++; // TODO - Check for duplicates after wrap around?
Path->InUse = TRUE;
Path->MinRtt = UINT32_MAX;
Path->Mtu = Connection->Settings.MinimumMtu;
Path->SmoothedRtt = MS_TO_US(Connection->Settings.InitialRttMs);
Expand All @@ -53,8 +54,15 @@ QuicPathRemove(
_In_ uint8_t Index
)
{
CXPLAT_DBG_ASSERT(Index < Connection->PathsCount);
CXPLAT_DBG_ASSERT(Connection->PathsCount > 0);
CXPLAT_DBG_ASSERT(Connection->PathsCount <= QUIC_MAX_PATH_COUNT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we make this a teleassert too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but I really don't expect this assert to be invalid. I am not so sure about the next one, that's why I've made it a tel assert.

if (Index >= Connection->PathsCount) {
CXPLAT_TEL_ASSERTMSG(Index < Connection->PathsCount, "Invalid path removal!");
return;
}

const QUIC_PATH* Path = &Connection->Paths[Index];
CXPLAT_DBG_ASSERT(Path->InUse);
QuicTraceLogConnInfo(
PathRemoved,
Connection,
Expand All @@ -75,6 +83,7 @@ QuicPathRemove(
}

Connection->PathsCount--;
Connection->Paths[Connection->PathsCount].InUse = FALSE;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
Expand Down Expand Up @@ -250,6 +259,7 @@ QuicConnGetPathForDatagram(
(Connection->PathsCount - 1) * sizeof(QUIC_PATH));
}

CXPLAT_DBG_ASSERT(Connection->PathsCount < QUIC_MAX_PATH_COUNT);
QUIC_PATH* Path = &Connection->Paths[1];
QuicPathInitialize(Connection, Path);
Connection->PathsCount++;
Expand Down
5 changes: 5 additions & 0 deletions src/core/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ typedef struct QUIC_PATH {
//
uint8_t ID;

//
// Indicates the path object is actively in use.
//
BOOLEAN InUse : 1;

//
// Indicates this is the primary path being used by the connection.
//
Expand Down
Loading