public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "V V, Pranav" <pranav.v.v@intel.com>
To: devel@edk2.groups.io
Cc: bhavana.s@intel.com, tabassum.yasmin@intel.com, "V V,
	Pranav" <pranav.v.v@intel.com>
Subject: [edk2-devel] [PATCH] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4649
Date: Fri, 22 Mar 2024 09:20:42 +0530	[thread overview]
Message-ID: <c6749234716e5af91c4255cf61b81d558548c315.1711079382.git.pranav.v.v@intel.com> (raw)

The KeyLibGenerateSalt function fails to check the return value of RandomSeed and RandomBytes function
calls.
SavePasswordToVariable function also fails to check the status of calling function KeyLibGenerateSalt

Added a status check for all the above mentioned function's

Signed-off-by: V V Pranav <pranav.v.v@intel.com>
---
 .../UserAuthenticationDxeSmm/KeyService.c                 | 8 ++++++--
 .../UserAuthenticationDxeSmm/UserAuthenticationSmm.c      | 6 +++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/KeyService.c b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/KeyService.c
index 8b06e58ca5..f0a537e707 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/KeyService.c
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/KeyService.c
@@ -78,8 +78,12 @@ KeyLibGenerateSalt (
   if (SaltValue == NULL) {
     return FALSE;
   }
-  RandomSeed(NULL, 0);
-  RandomBytes(SaltValue, SaltSize);
+  if (!RandomSeed(NULL, 0)) {
+    return FALSE;
+  }
+  if (!RandomBytes(SaltValue, SaltSize)) {
+    return FALSE;
+  }
   return TRUE;
 }
 
diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
index 98f40c1812..1efae70e38 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
@@ -221,12 +221,16 @@ SavePasswordToVariable (
   EFI_STATUS                        Status;
   USER_PASSWORD_VAR_STRUCT          UserPasswordVarStruct;
   BOOLEAN                           HashOk;
+  BOOLEAN                           KeyLibGenerateSaltOk;
 
   //
   // If password is NULL, it means we want to clean password field saved in variable region.
   //
   if (Password != NULL) {
-    KeyLibGenerateSalt (UserPasswordVarStruct.PasswordSalt, sizeof(UserPasswordVarStruct.PasswordSalt));
+    KeyLibGenerateSaltOk = KeyLibGenerateSalt (UserPasswordVarStruct.PasswordSalt, sizeof(UserPasswordVarStruct.PasswordSalt));
+    if (!KeyLibGenerateSaltOk) {
+      return EFI_NOT_FOUND;
+    }
     HashOk = KeyLibGeneratePBKDF2Hash (
                HASH_TYPE_SHA256,
                (UINT8 *)Password,
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117023): https://edk2.groups.io/g/devel/message/117023
Mute This Topic: https://groups.io/mt/105079487/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



                 reply	other threads:[~2024-03-22  3:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6749234716e5af91c4255cf61b81d558548c315.1711079382.git.pranav.v.v@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox