-
Notifications
You must be signed in to change notification settings - Fork 10
rmnet: fix PacketLen missing QMAP_UL_CHECKSUM size in QMAP header for V2/V3/V4 #61
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
Merged
+44
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4502,7 +4502,28 @@ VOID MPUSB_TLPTxPacket | |
| Qmap->PadCD |= (paddingBytes); | ||
| Qmap->MuxId = pAdapter->MuxId; | ||
| sendBytes += paddingBytes; | ||
| Qmap->PacketLen = RtlUshortByteSwap(sendBytes); | ||
| /* When QMAPEnabledV4/V2/V3 is active, the QMAP_UL_CHECKSUM structure | ||
| * (8 bytes) is placed between the QMAP header and the IP payload. The | ||
| * PacketLen field must cover all bytes that follow the QMAP header, so it | ||
| * must include sizeof(QMAP_UL_CHECKSUM). Without this fix, PacketLen is | ||
| * undersized by sizeof(QMAP_UL_CHECKSUM); IPA advances its frame-boundary | ||
| * pointer sizeof(QMAP_UL_CHECKSUM) bytes early, misreads trailing IP | ||
| * payload as the next QMAP header, and raises exception=4 | ||
| * (status.pkt_len < qmap.pkt_len). */ | ||
| if ((pAdapter->QMAPEnabledV4 == TRUE) | ||
| #ifdef QCUSB_MUX_PROTOCOL | ||
| #if defined(QCMP_QMAP_V2_SUPPORT) | ||
| || (pAdapter->QMAPEnabledV2 == TRUE) || (pAdapter->QMAPEnabledV3 == TRUE) | ||
| #endif | ||
| #endif | ||
| ) | ||
| { | ||
| Qmap->PacketLen = RtlUshortByteSwap((USHORT)(sendBytes + sizeof(QMAP_UL_CHECKSUM))); | ||
| } | ||
| else | ||
| { | ||
| Qmap->PacketLen = RtlUshortByteSwap((USHORT)sendBytes); | ||
| } | ||
| if (pAdapter->QMAPEnabledV4 == TRUE) | ||
| { | ||
| PQMAP_UL_CHECKSUM pULCheckSum = (PQMAP_UL_CHECKSUM)((PUCHAR)Qmap + sizeof(QMAP_STRUCT)); | ||
|
|
@@ -5798,7 +5819,28 @@ VOID MPUSB_TLPTxPacketEx | |
| Qmap->PadCD |= (paddingBytes); | ||
| Qmap->MuxId = pAdapter->MuxId; | ||
| sendBytes += paddingBytes; | ||
| Qmap->PacketLen = RtlUshortByteSwap(sendBytes); | ||
| /* When QMAPEnabledV4/V2/V3 is active, the QMAP_UL_CHECKSUM structure | ||
| * (8 bytes) is placed between the QMAP header and the IP payload. The | ||
| * PacketLen field must cover all bytes that follow the QMAP header, so it | ||
| * must include sizeof(QMAP_UL_CHECKSUM). Without this fix, PacketLen is | ||
| * undersized by sizeof(QMAP_UL_CHECKSUM); IPA advances its frame-boundary | ||
| * pointer sizeof(QMAP_UL_CHECKSUM) bytes early, misreads trailing IP | ||
| * payload as the next QMAP header, and raises exception=4 | ||
| * (status.pkt_len < qmap.pkt_len). */ | ||
| if ((pAdapter->QMAPEnabledV4 == TRUE) | ||
| #ifdef QCUSB_MUX_PROTOCOL | ||
| #if defined(QCMP_QMAP_V2_SUPPORT) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| || (pAdapter->QMAPEnabledV2 == TRUE) || (pAdapter->QMAPEnabledV3 == TRUE) | ||
| #endif | ||
| #endif | ||
| ) | ||
| { | ||
| Qmap->PacketLen = RtlUshortByteSwap((USHORT)(sendBytes + sizeof(QMAP_UL_CHECKSUM))); | ||
| } | ||
| else | ||
| { | ||
| Qmap->PacketLen = RtlUshortByteSwap((USHORT)sendBytes); | ||
| } | ||
| if (pAdapter->QMAPEnabledV4 == TRUE) | ||
| { | ||
| PQMAP_UL_CHECKSUM pULCheckSum = (PQMAP_UL_CHECKSUM)((PUCHAR)Qmap + sizeof(QMAP_STRUCT)); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a new QMAP version with UL checksum gets added later, it's easy to miss this block and silently get wrong PacketLen again. consider extracting the condition into a helper macro
For example, add this on top of the file,
#if defined(QCUSB_MUX_PROTOCOL) && defined(QCMP_QMAP_V2_SUPPORT)
#define QMAP_UL_CHECKSUM_ENABLED(pAdapter)
((pAdapter)->QMAPEnabledV4 || (pAdapter)->QMAPEnabledV2 || (pAdapter)->QMAPEnabledV3)
#else
#define QMAP_UL_CHECKSUM_ENABLED(pAdapter)
((pAdapter)->QMAPEnabledV4)
#endif
And then use it here,
if (QMAP_UL_CHECKSUM_ENABLED(pAdapter))
Qmap->PacketLen = RtlUshortByteSwap((USHORT)(sendBytes + sizeof(QMAP_UL_CHECKSUM)));
else
Qmap->PacketLen = RtlUshortByteSwap((USHORT)sendBytes);
This eliminates the #ifdef nesting inside the if condition, removes the duplication, and makes future QMAP version additions a single-point change.