From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mx.groups.io with SMTP id smtpd.web08.27382.1627288092235293576 for ; Mon, 26 Jul 2021 01:28:12 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=lRgxG1q6; spf=pass (domain: linaro.org, ip: 209.85.216.42, mailfrom: masami.hiramatsu@linaro.org) Received: by mail-pj1-f42.google.com with SMTP id mt6so11929249pjb.1 for ; Mon, 26 Jul 2021 01:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=iBHGJoMcAFEBqSFb91r30b5X9wGg83eG/ML4KRQ8kZU=; b=lRgxG1q6FSIkgFlISSnpSNCb3JnRYNCAVN7P5YoZvj55DCZ7Agzjo2IwvTFdMob/o1 RnfpBRlG3BVHlpG15kfPI+XxSYoetX8Pyby2cYYp2DyMb88DorFiAJLtCDjb8B54eG16 UXMO0DvWRSW8cLYymzGTDkFNVI8znSgzgUwQeLn7c/sSWs71hk4E45oREkB9QHc068z5 qp39zWi0yyIDcCGHcwbTONCkvIraG4RcF+7eTunZ5PxPm+XihsV4tAiWAmIwvWXu/wQr tSAkH/k7ZxluM8ptL7pxwogg3Or5xRuDAbpvQPGM+l/ICe9lV53zaC86J496xd+Xu9nG TH9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=iBHGJoMcAFEBqSFb91r30b5X9wGg83eG/ML4KRQ8kZU=; b=nHHXnTY3qiJgWB0PZS1JQGKFhlm6eKwNZqHe3tnVWtwdVgqwhQefwQRtZMYOCYSuWk cQ3oNrvrtFWRaKVMDBrfXP3xX2Lpx48AKLouTWggfgQc0WpuZsv/7EzSjFptBTKrYH+d 47dl/iXRQ7YhqnRzzKJjnUPVsJo+VgORet67/Xqa90unLOgbMJUZNZDRLHYeDLsT0knx mov4u1Ws8tDnHrcYTVJTiB1w+zG4ThQrJMl5uH+0Kl+6jKmNcfaAb+sTSEBUpx0KFHG9 6QZ9JM3jgmFIB38repwR2lMqUw6PCQ6nUtXDP/HlVKmJSHIyQX+w3hrHxSVyRxwJDDI8 m0QA== X-Gm-Message-State: AOAM532plJQUBEHBzHvT8IQ+yMNkfdqfoE/haZdWHX3xmar2mkilq2Bu KkYIppSQcJpRVSAcyPZp/Uaqtw== X-Google-Smtp-Source: ABdhPJwrS8+g9xdyoGcEGP5Y695Ba6VIYUv6JPcvn6lrkgITOWSHdhl6z/PxGxrKXj/lG6Ay2JMEkQ== X-Received: by 2002:a65:64c4:: with SMTP id t4mr17275994pgv.222.1627288091825; Mon, 26 Jul 2021 01:28:11 -0700 (PDT) Return-Path: Received: from localhost.localdomain (122x208x150x49.ap122.ftth.ucom.ne.jp. [122.208.150.49]) by smtp.gmail.com with ESMTPSA id d15sm40863062pfl.82.2021.07.26.01.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 01:28:11 -0700 (PDT) From: "Masami Hiramatsu" To: Ard Biesheuvel , Leif Lindholm , Sumit Garg Cc: sakamoto.kazuhiko@socionext.com, masami.hiramatsu@linaro.org, devel@edk2.groups.io Subject: [edk2-platforms PATCH v2 1/2] Silicon/SynQuacer/OpteeRngDxe: Fix invalid parameter check Date: Mon, 26 Jul 2021 17:28:09 +0900 Message-Id: <162728808875.823177.3243304632405478704.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <162728807883.823177.7600899853841894479.stgit@localhost> References: <162728807883.823177.7600899853841894479.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Fix invalid parameter case according to the UEFI spec 2.9, section 37.5 EFI_RNG_PROTOCOL.GetRNG. The spec said, "RNGValue is null or RNGValueLength is zero." instead of "RNGValue is NULL and RNGValueLength is non-zero." This fixes the mOpteeRng::GetRNG() to check the invalid parameter case correctly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Masami Hiramatsu Reported-by: Kazuhiko Sakamoto --- Changes in v2: - Update changelog. --- .../SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c b/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c index 51c15b1b94..333a3e625c 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c +++ b/Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c @@ -98,8 +98,7 @@ GetInfo ( @retval EFI_NOT_READY There is not enough random data available to satisfy the length requested by RNGValueLength. - @retval EFI_INVALID_PARAMETER RNGValue is NULL and RNGValueLength is - non-zero. + @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is zero. **/ STATIC @@ -119,7 +118,7 @@ GetRNG ( UINTN OutSize; UINTN WaitMiliSeconds; - if ((Value == NULL) && (ValueLength != 0)) { + if ((Value == NULL) || (ValueLength == 0)) { return EFI_INVALID_PARAMETER; }