From ef74c8002ae86d95fd9d1927233102aac52d769c Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 13 Dec 2021 10:41:39 -0800 Subject: [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 --- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py | 1 - 1 file changed, 1 deletion(-) (limited to 'lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py') diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py index 603dc7fa6c12..2a5eff312214 100644 --- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py +++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py @@ -139,7 +139,6 @@ class ScriptedProcesTestCase(TestBase): @skipUnlessDarwin @skipIfOutOfTreeDebugserver - @skipIfAsan # rdar://85954489 def test_launch_scripted_process_stack_frames(self): """Test that we can launch an lldb scripted process from the command line, check its process ID and read string from memory.""" -- cgit v1.2.3