From: Frederic Riss Date: Thu, 29 Mar 2018 03:49:41 +0000 (+0000) Subject: Prevent double release of mach ports X-Git-Tag: llvmorg-7.0.0-rc1~9416 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa37026db3169f68cd62023af5cc871dcb7225fc;p=platform%2Fupstream%2Fllvm.git Prevent double release of mach ports Summary: When a MIG routine returns KERN_FAILURE, the demux function will release any OOL resources like ports. In this case, task_port and thread_port will be released twice, potentially resulting in use after free of the ports. I don't think we can test this in any useful way rdar://problem/37331387 Reviewers: jasonmolenda Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D45011 llvm-svn: 328761 --- diff --git a/lldb/source/Plugins/Process/Darwin/MachException.cpp b/lldb/source/Plugins/Process/Darwin/MachException.cpp index 9f59207..d8a1b21 100644 --- a/lldb/source/Plugins/Process/Darwin/MachException.cpp +++ b/lldb/source/Plugins/Process/Darwin/MachException.cpp @@ -92,8 +92,6 @@ extern "C" kern_return_t catch_mach_exception_raise_state_identity( (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD), (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD)); } - mach_port_deallocate(mach_task_self(), task_port); - mach_port_deallocate(mach_task_self(), thread_port); return KERN_FAILURE; } diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp b/lldb/tools/debugserver/source/MacOSX/MachException.cpp index cc309e4..da2b2fe 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp @@ -86,8 +86,6 @@ extern "C" kern_return_t catch_mach_exception_raise_state_identity( (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD), (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD)); } - mach_port_deallocate(mach_task_self(), task_port); - mach_port_deallocate(mach_task_self(), thread_port); return KERN_FAILURE; }