From nobody Tue May 7 21:42:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+54995+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54995+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1582801340; cv=none; d=zohomail.com; s=zohoarc; b=RHIYxCc8vbCMMRO2UoQotfSveTm1okuwZ9u85R/121be/tBkEVdIsrf0RmoGv1hXrRWrEXOacX4EBC9XM05YdA4qYaxbdmExkfPU8aLJjWVrAekR/NJZV7eF3dUCQOlmpZq5C2AM37yhjdxx2nhlgl/p29/kgMzG69TlLM6u1ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582801340; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=CDOfhUJM1vrc0WjQVXEVwV+FCUxTHyaWFFYiVY8HD2Y=; b=iDE4oAtPdJQLaQonuH0QjRLKHLidy6N8xQ8dowOpwBcHJTM+I4pdsdW648n6XMIEibMrAmJ5H7/GhgpYeB3n528oX7sHAmxyYy/Y6XkCISy3KK1aJoyBF1g/1f33RNMiHlGaHvIuGWmyfBFOCM8niNXuRb3+x6zLlTMuRNe8EzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54995+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1582801339603937.3832931833022; Thu, 27 Feb 2020 03:02:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id mmtZYY1788612xSK72VN8N4d; Thu, 27 Feb 2020 03:02:18 -0800 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.2425.1582801337989162158 for ; Thu, 27 Feb 2020 03:02:18 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2020 03:02:17 -0800 X-IronPort-AV: E=Sophos;i="5.70,491,1574150400"; d="scan'208";a="242011768" X-Received: from mrabeda-mobl.ger.corp.intel.com ([10.102.8.43]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Feb 2020 03:02:16 -0800 From: "Maciej Rabeda" To: devel@edk2.groups.io Cc: Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v1] ShellPkg: Fix 'ping' command Ip4 receive flow. Date: Thu, 27 Feb 2020 12:02:12 +0100 Message-Id: <20200227110212.1070-1-maciej.rabeda@linux.intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,maciej.rabeda@linux.intel.com X-Gm-Message-State: 8c1jKRyDmi2F15PGkIfwo4Ulx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1582801338; bh=V57C4LC1RJovomRrhsQOUgbbpZgguiYyoTsKaoHKQEE=; h=Cc:Date:From:Reply-To:Subject:To; b=DtIMSwaBh99jGgJ6rO4zm/+sIOzUMLa+vtlPdRyttlfyF6Z4PP8+VLSKGhWz5MYEH/p fd17pwmpehllc4N9P6jSkHaywhtbXYI4xqvsv+KRfFH1HlPIM2rKoVyF5//0WpVjWXNO7 fAnXd+D/6mb4GjNmjgr+dcnHDLL9bktbbSc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2032 '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 Cc: Zhichao Gao Signed-off-by: Maciej Rabeda Acked-by: Zhichao Gao Reviewed-by: Siyuan Fu --- ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPk= g/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 ( =20 ON_EXIT: =20 + // + // Recycle the packet before reusing RxToken + // + gBS->SignalEvent (Private->IpChoice =3D=3D PING_IP_CHOICE_IP6?((EFI_IP6_= RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal:((EFI_IP4_RECE= IVE_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 =3D EFI_SUCCESS; } - // - // Singal to recycle the each rxdata here, not at the end of process. - // - gBS->SignalEvent (Private->IpChoice =3D=3D PING_IP_CHOICE_IP6?((EFI_IP6_= RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal:((EFI_IP4_RECE= IVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal); } =20 /** --=20 2.24.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#54995): https://edk2.groups.io/g/devel/message/54995 Mute This Topic: https://groups.io/mt/71584586/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-