From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by mx.groups.io with SMTP id smtpd.web10.10580.1601342011363633932 for ; Mon, 28 Sep 2020 18:13:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=n1 header.b=mmwIliyT; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 216.228.121.64, mailfrom: jbobek@nvidia.com) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 28 Sep 2020 18:12:40 -0700 Received: from titan.vdiclient.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 29 Sep 2020 01:13:19 +0000 From: "Jan Bobek" To: CC: Harry Liebel , Olivier Martin , Liming Gao , Jeff Brasen , Ashish Singhal Subject: [PATCH 1/1] MdePkg/BaseLib: Fix invalid memory access in AArch64 SetJump/LongJump Date: Mon, 28 Sep 2020 19:12:58 -0600 Message-ID: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Return-Path: jbobek@nvidia.com X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601341960; bh=CD84iGhO29pwz5jP5p9kW+BOCujpq1e1UjslJuIeANc=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy; b=mmwIliyTOn88xs6tiZ+gUcfhHeZeZiZpBU397RtBl2aqPgdFOE+7ApMrhQo/XgVNw lr/qyjRUXeHlMIM0TxUI+rlqkYr7KzGRRi/i74t4sAT7i0nLXkdMnRn0x3VrFJmKt0 8+y5RlVsSo+eaabvp7SJ4F+OygvLKPDeNS7LBv5xi5owIp0hxipORqjNNm4Tkk6qtB S6M8bWjKFIduJ/CjhP9IVAg8fPpRjQl494z8ME0MQpQKeJ1DFLAFrEk3e0kCHFwxul CxbmuCXYeJU/OlVHoZb5WTMaB4LSdaP1v7ym+0l1Ttx5VTAKupePIHrrnDIfyWN2lb gdJqS8JJ8oZlg== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Correct the memory offsets used in REG_ONE/REG_PAIR macros to synchronize them with definition of the BASE_LIBRARY_JUMP_BUFFER structure on AArch64. The REG_ONE macro declares only a single 64-bit register be read/written; however, the subsequent offset has previously been 16 bytes larger, creating an unused memory gap in the middle of the structure and causing SetJump/LongJump functions to read/write 8 bytes of memory past the end of the jump buffer struct. Signed-off-by: Jan Bobek --- MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S | 8 ++++---- MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S b/MdePkg/Libr= ary/BaseLib/AArch64/SetJumpLongJump.S index 72cea259e9..deefdf526b 100644 --- a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S +++ b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S @@ -20,10 +20,10 @@ GCC_ASM_EXPORT(InternalLongJump) REG_ONE (x16, 96) /*IP0*/=0D =0D #define FPR_LAYOUT \=0D - REG_PAIR ( d8, d9, 112); \=0D - REG_PAIR (d10, d11, 128); \=0D - REG_PAIR (d12, d13, 144); \=0D - REG_PAIR (d14, d15, 160);=0D + REG_PAIR ( d8, d9, 104); \=0D + REG_PAIR (d10, d11, 120); \=0D + REG_PAIR (d12, d13, 136); \=0D + REG_PAIR (d14, d15, 152);=0D =0D #/**=0D # Saves the current CPU context that can be restored with a call to LongJ= ump() and returns 0.#=0D diff --git a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm b/MdePkg/Li= brary/BaseLib/AArch64/SetJumpLongJump.asm index 20dd0f1b85..df70f29899 100644 --- a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm +++ b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm @@ -19,10 +19,10 @@ REG_ONE (x16, #96) /*IP0*/=0D =0D #define FPR_LAYOUT \=0D - REG_PAIR ( d8, d9, #112); \=0D - REG_PAIR (d10, d11, #128); \=0D - REG_PAIR (d12, d13, #144); \=0D - REG_PAIR (d14, d15, #160);=0D + REG_PAIR ( d8, d9, #104); \=0D + REG_PAIR (d10, d11, #120); \=0D + REG_PAIR (d12, d13, #136); \=0D + REG_PAIR (d14, d15, #152);=0D =0D ;/**=0D ; Saves the current CPU context that can be restored with a call to LongJ= ump() and returns 0.#=0D --=20 2.28.0