Skip to content

Commit

Permalink
ShellPkg: Fix 'ping' command Ip4 receive flow.
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2032

'ping' command's receive flow utilizes a single Rx token which it
attempts to reuse before recycling the previously received packet.
This causes a situation where under ICMP traffic,
Ping6OnEchoReplyReceived() function will receive an already
recycled packet with EFI_SUCCESS token status and finally
dereference invalid pointers from RxData structure.

Cc: Ray Ni <[email protected]>
Cc: Zhichao Gao <[email protected]>
Signed-off-by: Maciej Rabeda <[email protected]>
Reviewed-by: Siyuan Fu <[email protected]>
Acked-by: Zhichao Gao <[email protected]>
  • Loading branch information
Maciej Rabeda authored and mergify[bot] committed Apr 1, 2020
1 parent dd7523b commit 65c73df
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ Ping6OnEchoReplyReceived (

ON_EXIT:

//
// Recycle the packet before reusing RxToken
//
gBS->SignalEvent (Private->IpChoice == PING_IP_CHOICE_IP6?((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal:((EFI_IP4_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal);

if (Private->RxCount < Private->SendNum) {
//
// Continue to receive icmp echo reply packets.
Expand All @@ -632,10 +637,6 @@ Ping6OnEchoReplyReceived (
//
Private->Status = EFI_SUCCESS;
}
//
// Singal to recycle the each rxdata here, not at the end of process.
//
gBS->SignalEvent (Private->IpChoice == PING_IP_CHOICE_IP6?((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal:((EFI_IP4_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal);
}

/**
Expand Down

0 comments on commit 65c73df

Please sign in to comment.