This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Fix out-of-bounds memory access in EmulationStateArm
ClosedPublic

Authored by fixathon on Aug 11 2022, 1:16 AM.

Details

Summary

Functionally broken code for reading and writing registers, likely due to typos,
and could cause out-of-bounds memory access.

Diff Detail

Event Timeline

fixathon created this revision.Aug 11 2022, 1:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2022, 1:16 AM
fixathon requested review of this revision.Aug 11 2022, 1:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2022, 1:16 AM
DavidSpickett accepted this revision.Aug 11 2022, 1:30 AM

LGTM and I'll add a test later that would break without this fix.

This revision is now accepted and ready to land.Aug 11 2022, 1:30 AM

Thank you. Yes, this does need a unit test

lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
54

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.

95

Also clearly a typo as can be seen from the if condition, and the corresponding store code.