llvm-project/lldb
Med Ismail Bennani ef74c8002a [lldb/plugin] Fix heap-use-after-free in ScriptedProcess::ReadMemory
This commit should fix a heap-use-after-free bug that was caught by the
sanitizer bot.

The issue is that we were reading memory from a second target into a
`SBData` object in Python, that was passed to lldb's internal
`ScriptedProcess::DoReadMemory` C++ method.

The ScriptedPythonInterface then extracts the underlying `DataExtractor`
from the `SBData` object, and is used to read the memory with the
appropriate address size and byte order.

Unfortunately, it seems that even though the DataExtractor object was
still valid, it pointed to invalid, possibly garbage-collected memory
from Python.

To mitigate this, the patch uses `SBData::SetDataWithOwnership` to copy
the pointed buffer to lldb's heap memory which prevents the
use-after-free error.

rdar://84511405

Differential Revision: https://reviews.llvm.org/D115654

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-12-13 11:05:07 -08:00
..
bindings [lldb/API] Add SetDataWithOwnership method to SBData 2021-12-13 11:05:06 -08:00
cmake Quote some more destination paths with variables 2021-12-13 17:29:08 +00:00
docs [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
examples [lldb/plugins] Add arm64(e) support to ScriptedProcess 2021-12-06 16:11:59 -08:00
include/lldb [lldb/API] Add SetDataWithOwnership method to SBData 2021-12-13 11:05:06 -08:00
packages/Python [lldb] Fix broken skipUnlessUndefinedBehaviorSanitizer decorator 2021-11-30 13:03:33 -08:00
resources [lldb] Remove stale LLDB-Info.plist 2021-01-08 10:12:16 -08:00
scripts Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
source [lldb/API] Add SetDataWithOwnership method to SBData 2021-12-13 11:05:06 -08:00
test [lldb/plugin] Fix heap-use-after-free in ScriptedProcess::ReadMemory 2021-12-13 11:05:07 -08:00
third_party/Python/module [lldb][NFC] Inclusive language: replace master/slave names for ptys 2021-11-12 10:54:18 -06:00
tools [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00
unittests [llvm][lldb] Remove unused SmallVectorMemoryBuffer.h includes 2021-12-09 11:32:13 +01:00
utils [lldb] Match test dependencies name to other LLVM projects. 2021-05-21 00:10:27 -07:00
.clang-format
.clang-tidy [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
.gitignore
CMakeLists.txt [lldb] remove usage of distutils, fix python path on debian/ubuntu 2021-11-17 13:14:30 -08:00
CODE_OWNERS.txt
LICENSE.TXT
use_lldb_suite_root.py