]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/EbcDxe: Mitigate memcpy intrinsics
authorMarvin H?user <mhaeuser@posteo.de>
Sun, 15 Aug 2021 20:11:56 +0000 (04:11 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 30 Aug 2021 01:58:31 +0000 (01:58 +0000)
Assignments of structure values cause the emission of memcpy()
intrinsics by the CLANG38 toolchain. Substitute the assignments with
calls to CopyMem() to mitigate the issue.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin H?user <mhaeuser@posteo.de>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c
MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c
MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c

index 611b2de5d81f5512d0449e6e90a15cc9f332497b..e417f4870f3da853ab81107226e0951f4cf32026 100644 (file)
@@ -219,7 +219,11 @@ EdbCheckBreakpoint (
       //\r
       // If hit, record current breakpoint\r
       //\r
-      DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX] = DebuggerPrivate->DebuggerBreakpointContext[Index];\r
+      CopyMem (\r
+        &DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX],\r
+        &DebuggerPrivate->DebuggerBreakpointContext[Index],\r
+        sizeof (DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX])\r
+        );\r
       DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX].State = TRUE;\r
       //\r
       // Do not set Breakpoint flag. We record the address here just let it not patch breakpoint address when de-init.\r
index e0c797be247fd74858344dd831c3a5db7918c6fe..5d32c684066ef2ce183a45fa01efe710d6438a2d 100644 (file)
@@ -158,7 +158,11 @@ DebuggerBreakpointDel (
   // Delete this breakpoint\r
   //\r
   for (BpIndex = Index; BpIndex < DebuggerPrivate->DebuggerBreakpointCount - 1; BpIndex++) {\r
-    DebuggerPrivate->DebuggerBreakpointContext[BpIndex] = DebuggerPrivate->DebuggerBreakpointContext[BpIndex + 1];\r
+    CopyMem (\r
+      &DebuggerPrivate->DebuggerBreakpointContext[BpIndex],\r
+      &DebuggerPrivate->DebuggerBreakpointContext[BpIndex + 1],\r
+      sizeof (DebuggerPrivate->DebuggerBreakpointContext[BpIndex])\r
+      );\r
   }\r
   ZeroMem (\r
     &DebuggerPrivate->DebuggerBreakpointContext[BpIndex],\r
index 83257a2c25fe89cebe3af8fc7353f71415a57122..1bfe5240c760e09e23adc06f65f78ab9b53dbff3 100644 (file)
@@ -230,7 +230,11 @@ EbcDebuggerPushTraceDestEntry (
     //\r
     ASSERT (mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_TRACE_MAX].Type == Type);\r
     for (Index = 0; Index < EFI_DEBUGGER_TRACE_MAX; Index++) {\r
-      mDebuggerPrivate.TraceEntry[Index] = mDebuggerPrivate.TraceEntry[Index + 1];\r
+      CopyMem (\r
+        &mDebuggerPrivate.TraceEntry[Index],\r
+        &mDebuggerPrivate.TraceEntry[Index + 1],\r
+        sizeof (mDebuggerPrivate.TraceEntry[Index])\r
+        );\r
     }\r
     mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry;\r
     mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;\r