From cdea750576bc439ba869bc7f4831dc6d27980086 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 1 Nov 2017 15:00:40 -0700 Subject: [PATCH] crash_dump: don't inherit environment from parent. Bug: http://b/68381717 Test: debuggerd_test Change-Id: Ie1b342bc9901cb9ae9b79147899928a19052cbad --- debuggerd/debuggerd_test.cpp | 21 +++++++++++++++++++++ debuggerd/handler/debuggerd_handler.cpp | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 45e768dbc..8d0c98bb0 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -298,6 +299,26 @@ TEST_F(CrasherTest, smoke) { ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)"); } +TEST_F(CrasherTest, LD_PRELOAD) { + int intercept_result; + unique_fd output_fd; + StartProcess([]() { + setenv("LD_PRELOAD", "nonexistent.so", 1); + *reinterpret_cast(0xdead) = '1'; + }); + + StartIntercept(&output_fd); + FinishCrasher(); + AssertDeath(SIGSEGV); + FinishIntercept(&intercept_result); + + ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; + + std::string result; + ConsumeFd(std::move(output_fd), &result); + ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)"); +} + TEST_F(CrasherTest, abort) { int intercept_result; unique_fd output_fd; diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp index d41dc67be..d6b6d58d8 100644 --- a/debuggerd/handler/debuggerd_handler.cpp +++ b/debuggerd/handler/debuggerd_handler.cpp @@ -330,8 +330,8 @@ static int debuggerd_dispatch_pseudothread(void* arg) { async_safe_format_buffer(debuggerd_dump_type, sizeof(debuggerd_dump_type), "%d", get_dump_type(thread_info)); - execl(CRASH_DUMP_PATH, CRASH_DUMP_NAME, main_tid, pseudothread_tid, debuggerd_dump_type, - nullptr); + execle(CRASH_DUMP_PATH, CRASH_DUMP_NAME, main_tid, pseudothread_tid, debuggerd_dump_type, + nullptr, nullptr); fatal_errno("exec failed"); } else {