From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by mx.groups.io with SMTP id smtpd.web11.2749.1601568950505080640 for ; Thu, 01 Oct 2020 09:15:50 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Pu2KQk8C; 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.143, mailfrom: jbobek@nvidia.com) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 01 Oct 2020 09:14:07 -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; Thu, 1 Oct 2020 16:15:36 +0000 From: "Jan Bobek" To: CC: Leif Lindholm , Ard Biesheuvel , Michael D Kinney , Liming Gao , Zhiguang Liu , Jeff Brasen , Ashish Singhal Subject: [PATCH v2 1/1] MdePkg/BaseLib: Fix invalid memory access in AArch64 SetJump/LongJump Date: Thu, 1 Oct 2020 10:15:07 -0600 Message-ID: <20201001161507.48710-2-jbobek@nvidia.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001161507.48710-1-jbobek@nvidia.com> References: <20201001161507.48710-1-jbobek@nvidia.com> MIME-Version: 1.0 Return-Path: jbobek@nvidia.com X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601568847; bh=F6ham3dTjyU/KN0Y2F5FuU7xkwXLQ8gAIA+2JYhxb/g=; 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=Pu2KQk8CXkwKJd7kVM2X4uRzPgPXyWWEOWhrIeogDKzhzl4w7bsc37HNmfack98fO 76Lk95vy1lt8qLf96pdd96ygsCuM3+ymwVJfjHKWKBEFpN/sa4nasfVGrlLE/fJejL SknLRh3sOlSbsWshpecDwmlLWLohjwC/zYIjtzledG0/UDLLrKiShyNFWBOTekd5/A hpTyOAfZrQj2Vza3VNUdOgwoAGxIyTTgC0UAYxnt3YgdtCb7VNV419FcrEH0wDUtPd sBNIyXgQH3NsO7Hy8mDLPSDKeqBV6idzVymstZgf1tICkLVpqNLpYiYRjAKJyvJ+qX qKImL8JJJZcmg== 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 is 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 72cea259e913..deefdf526b95 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*/ =20 #define FPR_LAYOUT \ - REG_PAIR ( d8, d9, 112); \ - REG_PAIR (d10, d11, 128); \ - REG_PAIR (d12, d13, 144); \ - REG_PAIR (d14, d15, 160); + REG_PAIR ( d8, d9, 104); \ + REG_PAIR (d10, d11, 120); \ + REG_PAIR (d12, d13, 136); \ + REG_PAIR (d14, d15, 152); =20 #/** # Saves the current CPU context that can be restored with a call to LongJ= ump() and returns 0.# diff --git a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm b/MdePkg/Li= brary/BaseLib/AArch64/SetJumpLongJump.asm index 20dd0f1b850f..df70f298998e 100644 --- a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm +++ b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.asm @@ -19,10 +19,10 @@ REG_ONE (x16, #96) /*IP0*/ =20 #define FPR_LAYOUT \ - REG_PAIR ( d8, d9, #112); \ - REG_PAIR (d10, d11, #128); \ - REG_PAIR (d12, d13, #144); \ - REG_PAIR (d14, d15, #160); + REG_PAIR ( d8, d9, #104); \ + REG_PAIR (d10, d11, #120); \ + REG_PAIR (d12, d13, #136); \ + REG_PAIR (d14, d15, #152); =20 ;/** ; Saves the current CPU context that can be restored with a call to LongJ= ump() and returns 0.# --=20 2.28.0