ACK: [PATCH] uefi: uefirtmisc: Add null count argument check for GetNextHighMonotonicCount
ivanhu
ivan.hu at canonical.com
Wed Mar 25 06:14:11 UTC 2015
On 2015年03月24日 00:11, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Add a simple test for NULL count argumenent being passed into
> the run time service GetNextHighMonotonicCount
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> efi_runtime/efi_runtime.c | 9 ++++++---
> src/uefi/uefirtmisc/uefirtmisc.c | 28 ++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+), 3 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 638a817..31e5bb3 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -534,16 +534,19 @@ static long efi_runtime_get_nexthighmonocount(unsigned long arg)
> pgetnexthighmonotoniccount = (struct
> efi_getnexthighmonotoniccount __user *)arg;
>
> - status = efi.get_next_high_mono_count(&count);
> -
> if (copy_from_user(&pgetnexthighmonotoniccount_local,
> pgetnexthighmonotoniccount,
> sizeof(pgetnexthighmonotoniccount_local)))
> return -EFAULT;
> +
> + status = efi.get_next_high_mono_count(
> + pgetnexthighmonotoniccount_local.HighCount ? &count : NULL);
> +
> if (put_user(status, pgetnexthighmonotoniccount_local.status))
> return -EFAULT;
>
> - if (put_user(count, pgetnexthighmonotoniccount_local.HighCount))
> + if (pgetnexthighmonotoniccount_local.HighCount &&
> + put_user(count, pgetnexthighmonotoniccount_local.HighCount))
> return -EFAULT;
>
> if (status != EFI_SUCCESS)
> diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c
> index 91d7540..ab8b6c1 100644
> --- a/src/uefi/uefirtmisc/uefirtmisc.c
> +++ b/src/uefi/uefirtmisc/uefirtmisc.c
> @@ -211,9 +211,37 @@ static int uefirtmisc_test2(fwts_framework *fw)
> return FWTS_OK;
> }
>
> +static int uefirtmisc_test3(fwts_framework *fw)
> +{
> + uint64_t status;
> + long ioret;
> + struct efi_getnexthighmonotoniccount getnexthighmonotoniccount;
> +
> + getnexthighmonotoniccount.HighCount = NULL;
> + getnexthighmonotoniccount.status = &status;
> +
> + ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT, &getnexthighmonotoniccount);
> + if (ioret == -1) {
> + if (status == EFI_INVALID_PARAMETER) {
> + fwts_passed(fw, "Test with invalid NULL parameter returned "
> + "EFI_INVALID_PARAMETER as expected.");
> + return FWTS_OK;
> + }
> + fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextHighMonotonicCountInvalid",
> + "Failed to get correct return status from UEFI runtime service, expecting EFI_INVALID_PARAMETER.");
> + fwts_uefi_print_status_info(fw, status);
> + return FWTS_ERROR;
> + }
> + fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextHighMonotonicCountInvalid",
> + "Failed to get error return status from UEFI runtime service, expected EFI_INAVLID_PARAMETER.");
> + return FWTS_ERROR;
> +}
> +
> +
> static fwts_framework_minor_test uefirtmisc_tests[] = {
> { uefirtmisc_test1, "Test for UEFI miscellaneous runtime service interfaces." },
> { uefirtmisc_test2, "Stress test for UEFI miscellaneous runtime service interfaces." },
> + { uefirtmisc_test3, "Test GetNextHighMonotonicCount with invalid NULL parameter." },
> { NULL, NULL }
> };
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list