public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] ShellPkg: Fix 'ping' command Ip4 receive flow.
@ 2020-02-27 11:02 Maciej Rabeda
  2020-02-27 13:14 ` [edk2-devel] " Laszlo Ersek
  2020-03-25 11:34 ` Laszlo Ersek
  0 siblings, 2 replies; 14+ messages in thread
From: Maciej Rabeda @ 2020-02-27 11:02 UTC (permalink / raw)
  To: devel; +Cc: Ray Ni, Zhichao Gao

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 <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index 23567fa2c1bb..a3fa32515192 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -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.
@@ -632,10 +637,6 @@ ON_EXIT:
     //
     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);
 }
 
 /**
-- 
2.24.0.windows.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-03-31 17:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-27 11:02 [PATCH v1] ShellPkg: Fix 'ping' command Ip4 receive flow Maciej Rabeda
2020-02-27 13:14 ` [edk2-devel] " Laszlo Ersek
2020-02-27 17:40   ` Laszlo Ersek
2020-02-28  2:59     ` Liming Gao
2020-02-28 11:41       ` Maciej Rabeda
2020-02-28 11:50         ` Liming Gao
2020-02-28 12:35           ` Maciej Rabeda
2020-03-02 13:43             ` Liming Gao
2020-03-25 11:34 ` Laszlo Ersek
2020-03-26  3:16   ` Gao, Zhichao
2020-03-31  9:03     ` Maciej Rabeda
2020-03-31 11:53   ` Siyuan, Fu
2020-03-31 14:50     ` Gao, Zhichao
2020-03-31 17:42       ` Maciej Rabeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox