public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jeff Brasen" <jbrasen@nvidia.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [PATCH] uefi-sct/SctPkg: Correct issue with memory protection enabled.
Date: Tue, 22 Sep 2020 22:13:27 +0000	[thread overview]
Message-ID: <DM6PR12MB33408428FA3D46BECD089992CB3B0@DM6PR12MB3340.namprd12.prod.outlook.com> (raw)
In-Reply-To: <4d637a44c99f0aaa8d78b2def96114d7dc3b1bb6.1599844750.git.jbrasen@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 10582 bytes --]

Any comments on this change?


Thanks,

Jeff

________________________________
From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Friday, September 11, 2020 11:23 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Subject: [PATCH] uefi-sct/SctPkg: Correct issue with memory protection enabled.

On systems with memory protection enabled the modification of local
function initialization data results in permission issue. Make a copy of
data prior to modification.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../UnicodeCollationBBTestFunction.c          | 38 ++++++++++---------
 .../UnicodeCollation2BBTestFunction.c         | 38 ++++++++++---------
 2 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation/BlackBoxTest/UnicodeCollationBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation/BlackBoxTest/UnicodeCollationBBTestFunction.c
index 6fa11e6c..e0b4c1d9 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation/BlackBoxTest/UnicodeCollationBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation/BlackBoxTest/UnicodeCollationBBTestFunction.c
@@ -25,7 +25,7 @@ Abstract:
 --*/





-#include "SctLib.h"
+#include "SctLib.h"

 #include "UnicodeCollationBBTestMain.h"





@@ -337,6 +337,7 @@ BBTestStrLwrFunctionAutoTest (
                                         };



   CHAR16                               TestDataSav[MAX_SIZE_OF_STRING + 1];

+  CHAR16                               TestDataRw[MAX_SIZE_OF_STRING + 1];







@@ -368,14 +369,15 @@ BBTestStrLwrFunctionAutoTest (
     //

     // Backup current test data

     //

+    CopyUnicodeString (TestDataRw, TestData[Index]);

     CopyUnicodeString (TestDataSav, TestData[Index]);



     //

     // For each test data, test the StrLwr functionality.

     //

-    UnicodeCollation->StrLwr (UnicodeCollation, TestData[Index]);

+    UnicodeCollation->StrLwr (UnicodeCollation, TestDataRw);



-    if (CheckStrLwr (TestDataSav, TestData[Index])) {

+    if (CheckStrLwr (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -390,15 +392,15 @@ BBTestStrLwrFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );





-    CopyUnicodeString (TestDataSav, TestData[Index]);

-    UnicodeCollation->StrUpr (UnicodeCollation, TestData[Index]);

-    UnicodeCollation->StrLwr (UnicodeCollation, TestData[Index]);

+    CopyUnicodeString (TestDataSav, TestDataRw);

+    UnicodeCollation->StrUpr (UnicodeCollation, TestDataRw);

+    UnicodeCollation->StrLwr (UnicodeCollation, TestDataRw);



-    if (CheckStrEql (TestDataSav, TestData[Index])) {

+    if (CheckStrEql (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -413,7 +415,7 @@ BBTestStrLwrFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );

   };



@@ -458,6 +460,7 @@ BBTestStrUprFunctionAutoTest (
                                         };



   CHAR16                               TestDataSav[MAX_SIZE_OF_STRING + 1];

+  CHAR16                               TestDataRw[MAX_SIZE_OF_STRING + 1];







@@ -490,13 +493,14 @@ BBTestStrUprFunctionAutoTest (
     // Backup current test data

     //

     CopyUnicodeString (TestDataSav, TestData[Index]);

+    CopyUnicodeString (TestDataRw, TestData[Index]);



     //

     // For each test data, test the StrUpr functionality.

     //

-    UnicodeCollation->StrUpr (UnicodeCollation, TestData[Index]);

+    UnicodeCollation->StrUpr (UnicodeCollation, TestDataRw);



-    if (CheckStrUpr (TestDataSav, TestData[Index])) {

+    if (CheckStrUpr (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -511,14 +515,14 @@ BBTestStrUprFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );



-    CopyUnicodeString (TestDataSav, TestData[Index]);

-    UnicodeCollation->StrLwr (UnicodeCollation, TestData[Index]);

-    UnicodeCollation->StrUpr (UnicodeCollation, TestData[Index]);

+    CopyUnicodeString (TestDataSav, TestDataRw);

+    UnicodeCollation->StrLwr (UnicodeCollation, TestDataRw);

+    UnicodeCollation->StrUpr (UnicodeCollation, TestDataRw);



-    if (CheckStrEql (TestDataSav, TestData[Index])) {

+    if (CheckStrEql (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -533,7 +537,7 @@ BBTestStrUprFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );

   };



diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation2/BlackBoxTest/UnicodeCollation2BBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation2/BlackBoxTest/UnicodeCollation2BBTestFunction.c
index 653b263a..19ff6764 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation2/BlackBoxTest/UnicodeCollation2BBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UnicodeCollation2/BlackBoxTest/UnicodeCollation2BBTestFunction.c
@@ -25,7 +25,7 @@ Abstract:
 --*/





-#include "SctLib.h"
+#include "SctLib.h"

 #include "UnicodeCollation2BBTestMain.h"



 STATIC CONST STRICOLL_TEST_DATA_FIELD             mStriCollTestData[] ={

@@ -335,6 +335,7 @@ BBTestStrLwrFunctionAutoTest (
                                         };



   CHAR16                               TestDataSav[MAX_SIZE_OF_STRING + 1];

+  CHAR16                               TestDataRw[MAX_SIZE_OF_STRING + 1];







@@ -367,13 +368,14 @@ BBTestStrLwrFunctionAutoTest (
     // Backup current test data

     //

     CopyUnicodeString (TestDataSav, TestData[Index]);

+    CopyUnicodeString (TestDataRw, TestData[Index]);



     //

     // For each test data, test the StrLwr functionality.

     //

-    UnicodeCollation->StrLwr (UnicodeCollation, TestData[Index]);

+    UnicodeCollation->StrLwr (UnicodeCollation, TestDataRw);



-    if (CheckStrLwr (TestDataSav, TestData[Index])) {

+    if (CheckStrLwr (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -388,15 +390,15 @@ BBTestStrLwrFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );





-    CopyUnicodeString (TestDataSav, TestData[Index]);

-    UnicodeCollation->StrUpr (UnicodeCollation, TestData[Index]);

-    UnicodeCollation->StrLwr (UnicodeCollation, TestData[Index]);

+    CopyUnicodeString (TestDataSav, TestDataRw);

+    UnicodeCollation->StrUpr (UnicodeCollation, TestDataRw);

+    UnicodeCollation->StrLwr (UnicodeCollation, TestDataRw);



-    if (CheckStrEql (TestDataSav, TestData[Index])) {

+    if (CheckStrEql (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -411,7 +413,7 @@ BBTestStrLwrFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );

   };



@@ -456,6 +458,7 @@ BBTestStrUprFunctionAutoTest (
                                         };



   CHAR16                               TestDataSav[MAX_SIZE_OF_STRING + 1];

+  CHAR16                               TestDataRw[MAX_SIZE_OF_STRING + 1];







@@ -488,13 +491,14 @@ BBTestStrUprFunctionAutoTest (
     // Backup current test data

     //

     CopyUnicodeString (TestDataSav, TestData[Index]);

+    CopyUnicodeString (TestDataRw, TestData[Index]);



     //

     // For each test data, test the StrUpr functionality.

     //

-    UnicodeCollation->StrUpr (UnicodeCollation, TestData[Index]);

+    UnicodeCollation->StrUpr (UnicodeCollation, TestDataRw);



-    if (CheckStrUpr (TestDataSav, TestData[Index])) {

+    if (CheckStrUpr (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -509,14 +513,14 @@ BBTestStrUprFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );



-    CopyUnicodeString (TestDataSav, TestData[Index]);

-    UnicodeCollation->StrLwr (UnicodeCollation, TestData[Index]);

-    UnicodeCollation->StrUpr (UnicodeCollation, TestData[Index]);

+    CopyUnicodeString (TestDataSav, TestDataRw);

+    UnicodeCollation->StrLwr (UnicodeCollation, TestDataRw);

+    UnicodeCollation->StrUpr (UnicodeCollation, TestDataRw);



-    if (CheckStrEql (TestDataSav, TestData[Index])) {

+    if (CheckStrEql (TestDataSav, TestDataRw)) {

       AssertionType = EFI_TEST_ASSERTION_PASSED;

     } else {

       AssertionType = EFI_TEST_ASSERTION_FAILED;

@@ -531,7 +535,7 @@ BBTestStrUprFunctionAutoTest (
                    __FILE__,

                    (UINTN)__LINE__,

                    TestDataSav,

-                   TestData[Index]

+                   TestDataRw

                    );

   };



--
2.25.1


[-- Attachment #2: Type: text/html, Size: 22484 bytes --]

  reply	other threads:[~2020-09-22 22:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 17:23 [PATCH] uefi-sct/SctPkg: Correct issue with memory protection enabled Jeff Brasen
2020-09-22 22:13 ` Jeff Brasen [this message]
2020-09-23  8:59   ` [edk2-devel] " Laszlo Ersek
2020-09-23 15:56     ` Jeff Brasen
2020-09-29 14:05       ` Samer El-Haj-Mahmoud
2020-10-05 21:26         ` Jeff Brasen
2020-11-11 21:06           ` Samer El-Haj-Mahmoud
2020-11-24 18:42             ` G Edhaya Chandran

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=DM6PR12MB33408428FA3D46BECD089992CB3B0@DM6PR12MB3340.namprd12.prod.outlook.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