]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Ip4Dxe: fix ICMP echo reply memory leak
authorHeyi Guo <heyi.guo@linaro.org>
Mon, 11 Dec 2017 11:11:48 +0000 (19:11 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Tue, 12 Dec 2017 11:12:41 +0000 (19:12 +0800)
When UEFI receives ICMP echo packets it will enter Ip4IcmpReplyEcho
function, and then call Ip4Output. However, if Ip4Output gets some
error and exits early, e.g. fails to find the route entry, memory
buffer of "Data" gets no chance to be freed and memory leak will be
caused. If there is such an attacker in the network, we will see UEFI
runs out of memory and system hangs.

So we explicitly free the memory when error status is returned.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Junbiao Hong <hongjunbiao@huawei.com>
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c

index b4b086496cf048873a1ad3b5f6c6f4e9a6c58cad..ed6bdbe466422406ad9e5999b588d504122880fb 100644 (file)
@@ -267,6 +267,9 @@ Ip4IcmpReplyEcho (
              Ip4SysPacketSent,\r
              NULL\r
              );\r
+  if (EFI_ERROR (Status)) {\r
+    NetbufFree (Data);\r
+  }\r
 \r
 ON_EXIT:\r
   NetbufFree (Packet);\r