From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=supreeth.venkatesh@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id A5F962194D3AE for ; Tue, 16 Oct 2018 02:48:38 -0700 (PDT) Received: by usa-sjc-mx-foss1.foss.arm.com (Postfix, from userid 105) id 0BD123700; Tue, 16 Oct 2018 03:33:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DCDCA339A; Sun, 14 Oct 2018 19:20:49 -0700 (PDT) Received: from [10.6.43.238] (bc-c3-3-14.eu.iaas.arm.com [10.6.43.238]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1AFF73F5B1; Sun, 14 Oct 2018 19:20:28 -0700 (PDT) To: Eric Jin , edk2-devel@lists.01.org Cc: Jiaxin Wu References: <20181013162717.11656-1-eric.jin@intel.com> From: Supreeth Venkatesh Message-ID: <878ac949-836a-6fd4-77dc-df28851034b0@arm.com> Date: Mon, 15 Oct 2018 03:20:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181013162717.11656-1-eric.jin@intel.com> Subject: Re: [PATCH] uefi-sct/SctPkg: Fix the Possible numeric underflow X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 09:48:39 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Reviewed-by: Supreeth Venkatesh On 10/13/2018 05:27 PM, Eric Jin wrote: > Possible numeric underflow when calculating the starting LBA for ReadBlocks_Func test > > Cc: Supreeth Venkatesh > Cc: Jiaxin Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Jin > --- > .../Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c | 6 +++++- > .../Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c | 6 +++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c > index 847ff9cb..e25743b7 100644 > --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c > +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c > @@ -1,7 +1,7 @@ > /** @file > > Copyright 2006 - 2016 Unified EFI, Inc.
> - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
> > This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD License > @@ -316,9 +316,13 @@ BBTestReadBlocksFunctionAutoTest ( > NewLba = IndexJ; > } else if (IndexJ < 2 * MAX_DIFFERENT_LBA_FOR_TEST) { > // from (LastBlock - MAX_DIFFERENT_LBA_FOR_TEST - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) to (LastBlock - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) > + if (LastBlock < MAX_DIFFERENT_LBA_FOR_TEST + MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) > + continue; > NewLba = IndexJ + LastBlock - 2 * MAX_DIFFERENT_LBA_FOR_TEST - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST; > } else { > // from (LastBlock/2 - MAX_DIFFERENT_LBA_FOR_TEST/2) to (LastBlock/2 + MAX_DIFFERENT_LBA_FOR_TEST/2) > + if (LastBlock < MAX_DIFFERENT_LBA_FOR_TEST) > + continue; > NewLba = IndexJ - 2 * MAX_DIFFERENT_LBA_FOR_TEST + (SctDivU64x32 (LastBlock, 2, &Remainder) - MAX_DIFFERENT_LBA_FOR_TEST / 2); > } > > diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c > index 2590c035..e8d4295e 100644 > --- a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c > +++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/BlockIo/BlackBoxTest/BlockIoBBTestFunction.c > @@ -1,7 +1,7 @@ > /** @file > > Copyright 2006 - 2016 Unified EFI, Inc.
> - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
> > This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD License > @@ -316,9 +316,13 @@ BBTestReadBlocksFunctionAutoTest ( > NewLba = IndexJ; > } else if (IndexJ < 2 * MAX_DIFFERENT_LBA_FOR_TEST) { > // from (LastBlock - MAX_DIFFERENT_LBA_FOR_TEST - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) to (LastBlock - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) > + if (LastBlock < MAX_DIFFERENT_LBA_FOR_TEST + MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) > + continue; > NewLba = IndexJ + LastBlock - 2 * MAX_DIFFERENT_LBA_FOR_TEST - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST; > } else { > // from (LastBlock/2 - MAX_DIFFERENT_LBA_FOR_TEST/2) to (LastBlock/2 + MAX_DIFFERENT_LBA_FOR_TEST/2) > + if (LastBlock < MAX_DIFFERENT_LBA_FOR_TEST) > + continue; > NewLba = IndexJ - 2 * MAX_DIFFERENT_LBA_FOR_TEST + (SctDivU64x32 (LastBlock, 2, &Remainder) - MAX_DIFFERENT_LBA_FOR_TEST / 2); > } >