From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.10259.1595383265726560415 for ; Tue, 21 Jul 2020 19:01:05 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: samer.el-haj-mahmoud@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B1D21045; Tue, 21 Jul 2020 19:01:04 -0700 (PDT) Received: from U203705.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 578873F66F; Tue, 21 Jul 2020 19:01:04 -0700 (PDT) From: "Samer El-Haj-Mahmoud" To: devel@edk2.groups.io Cc: Leif Lindholm , Pete Batard , Andrei Warkentin , Ard Biesheuvel Subject: [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix GOP parameter handling Date: Tue, 21 Jul 2020 22:01:01 -0400 Message-Id: <20200722020103.11808-2-Samer.El-Haj-Mahmoud@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200722020103.11808-1-Samer.El-Haj-Mahmoud@arm.com> References: <20200722020103.11808-1-Samer.El-Haj-Mahmoud@arm.com> Handle incorrect parameters passed to DisplayDxe GOP functions QueryMode(), SetMode(), and Blt(). This fixes Blt_Conf and QueryMode_Conf failures reported by SCT tests at: https://github.com/pftf/RPi4/issues/73 Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Signed-off-by: Samer El-Haj-Mahmoud --- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c index b880ca827bd6..80d0f7b2cb3c 100644 --- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c +++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c @@ -1,5 +1,6 @@ /** @file * + * Copyright (c) 2020, ARM Limited. All rights reserved. * Copyright (c) 2017-2018, Andrei Warkentin * Copyright (c) Microsoft Corporation. All rights reserved. * @@ -170,7 +171,7 @@ DisplayQueryMode ( EFI_STATUS Status; GOP_MODE_DATA *Mode; - if (ModeNumber > mLastMode) { + if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) { return EFI_INVALID_PARAMETER; } @@ -227,7 +228,7 @@ DisplaySetMode ( EFI_PHYSICAL_ADDRESS FbBase; GOP_MODE_DATA *Mode = &mGopModeData[ModeNumber]; - if (ModeNumber > mLastMode) { + if (ModeNumber >= This->Mode->MaxMode) { return EFI_UNSUPPORTED; } @@ -299,6 +300,14 @@ DisplayBlt ( UINT8 *VidBuf, *BltBuf, *VidBuf1; UINTN i; + if ((UINTN)BltOperation >= EfiGraphicsOutputBltOperationMax) { + return EFI_INVALID_PARAMETER; + } + + if (Width == 0 || Height == 0) { + return EFI_INVALID_PARAMETER; + } + switch (BltOperation) { case EfiBltVideoFill: BltBuf = (UINT8*)BltBuffer; @@ -349,7 +358,7 @@ DisplayBlt ( break; default: - ASSERT_EFI_ERROR (EFI_SUCCESS); + return EFI_INVALID_PARAMETER; break; } -- 2.17.1