Page MenuHomePhabricator

[lldb] [Process/NetBSD] Fix handling piod_len from PT_IO calls
ClosedPublic

Authored by mgorny on Apr 30 2019, 6:54 AM.

Details

Summary

Fix bugs in piod_len return value processing in ReadMemory()
and WriteMemory() methods. In particular, add support for piod_len == 0
indicating EOF, and fix summing bytes_read/bytes_written when PT_IO does
partial reads/writes.

The EOF condition could happen if LLDB attempts to read past
vm.maxaddress, e.g. as a result of RBP containing large (invalid) value.
Previously, the 0 return caused the function to retry reading via PT_IO
indefinitely, effectively deadlooping lldb-server.

Partial reads probably did not occur in practice, yet they would cause
ReadMemory() to return incorrect bytes_read and/or overwrite previously
read data.

WriteMemory() suffered from analoguous problems.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny created this revision.Apr 30 2019, 6:54 AM
krytarowski accepted this revision.Apr 30 2019, 7:01 AM
This revision is now accepted and ready to land.Apr 30 2019, 7:01 AM
krytarowski requested changes to this revision.Apr 30 2019, 7:09 AM

I think there is a bug thought in the code.

  1. bytes_read should return the bytes transferred from the function, it returns the value from the previous iteration only
  2. bytes_read != 0 should be replaced with io.piod_len != 0
This revision now requires changes to proceed.Apr 30 2019, 7:09 AM
mgorny updated this revision to Diff 197325.Apr 30 2019, 7:39 AM
mgorny retitled this revision from [lldb] [Process/NetBSD] Fix handling EOF in PT_IO when reading memory to [lldb] [Process/NetBSD] Fix handling piod_len when reading memory.
mgorny edited the summary of this revision. (Show Details)
mgorny updated this revision to Diff 197326.Apr 30 2019, 7:46 AM
mgorny retitled this revision from [lldb] [Process/NetBSD] Fix handling piod_len when reading memory to [lldb] [Process/NetBSD] Fix handling piod_len from PT_IO calls.
mgorny edited the summary of this revision. (Show Details)

Also included fixes for WriteMemory().

krytarowski accepted this revision.Apr 30 2019, 8:38 AM
This revision is now accepted and ready to land.Apr 30 2019, 8:38 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2019, 9:33 AM