[Lldb-commits] [PATCH] D131658: [LLDB] Fix out-of-bounds memory access in EmulationStateArm

Slava Gurevich via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 11 01:33:16 PDT 2022


fixathon added a comment.

Thank you. Yes, this does need a unit test



================
Comment at: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp:54
       uint32_t idx = i - dwarf_d0;
-      if (i < 16) {
+      if (idx < 16) {
         m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
----------------
Here index 'i' represents an offset starting at dwarf_d0, and index 'idx' is normalized to start at 0. 
"i" will always be greater than 16 causing the 'else' statement to always execute regardless of the intent.


================
Comment at: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp:95
     uint32_t idx = reg_num - dwarf_s0;
-    value = m_vfp_regs.d_regs[idx];
+    value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
----------------
Also clearly a typo as can be seen from the if condition, and the corresponding store code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131658/new/

https://reviews.llvm.org/D131658



More information about the lldb-commits mailing list