From 84f8b1c72205e3b9d1a2129227638a3c1ddb7444 Mon Sep 17 00:00:00 2001 From: klcf0220 Date: Mon, 14 Jul 2025 17:46:26 +0800 Subject: [PATCH] lite perf add inheritable Signed-off-by: klcf0220 --- interfaces/innerkits/dump_catcher/lite_perf.cpp | 5 +++++ .../innerkits/signal_handler/dfx_dumprequest.c | 4 ++-- .../innerkits/signal_handler/dfx_signal_handler.c | 14 -------------- .../signal_handler/include/dfx_dumprequest.h | 2 ++ .../signal_handler/libdfx_signalhandler.map | 1 + 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/interfaces/innerkits/dump_catcher/lite_perf.cpp b/interfaces/innerkits/dump_catcher/lite_perf.cpp index 28030d788..3ff21a945 100644 --- a/interfaces/innerkits/dump_catcher/lite_perf.cpp +++ b/interfaces/innerkits/dump_catcher/lite_perf.cpp @@ -358,6 +358,11 @@ bool LitePerf::Impl::ExecDumpPipe(const int (&pipefd)[2], const LitePerfParam& l } close(pipefd[PIPE_WRITE]); + if (DFX_InheritCapabilities() != 0) { + DFXLOGE("Failed to inherit Capabilities from parent."); + return false; + } + DFXLOGI("execl processdump -liteperf."); execl(PROCESSDUMP_PATH, "processdump", "-liteperf", nullptr); DFXLOGE("Failed to execl processdump -liteperf, errno(%{public}d)", errno); diff --git a/interfaces/innerkits/signal_handler/dfx_dumprequest.c b/interfaces/innerkits/signal_handler/dfx_dumprequest.c index a95c74b91..be28a8955 100644 --- a/interfaces/innerkits/signal_handler/dfx_dumprequest.c +++ b/interfaces/innerkits/signal_handler/dfx_dumprequest.c @@ -150,7 +150,7 @@ static void FillCrashExceptionAndReport(const int err) ReportException(&exception); } -static int32_t InheritCapabilities(void) +int32_t DFX_InheritCapabilities(void) { struct __user_cap_header_struct capHeader; (void)memset_s(&capHeader, sizeof(capHeader), 0, sizeof(capHeader)); @@ -272,7 +272,7 @@ static int DFX_ExecDump(void) } syscall(SYS_close, pipefd[1]); - if (InheritCapabilities() != 0) { + if (DFX_InheritCapabilities() != 0) { DFXLOGE("Failed to inherit Capabilities from parent."); FillCrashExceptionAndReport(CRASH_SIGNAL_EINHERITCAP); return INHERIT_CAP_FAIL; diff --git a/interfaces/innerkits/signal_handler/dfx_signal_handler.c b/interfaces/innerkits/signal_handler/dfx_signal_handler.c index bde299d24..85806a8e7 100644 --- a/interfaces/innerkits/signal_handler/dfx_signal_handler.c +++ b/interfaces/innerkits/signal_handler/dfx_signal_handler.c @@ -74,13 +74,6 @@ #define NSIG 64 #endif -#ifndef F_SETPIPE_SZ -#define F_SETPIPE_SZ 1031 -#endif - -#define NUMBER_SIXTYFOUR 64 -#define INHERITABLE_OFFSET 32 - void __attribute__((constructor)) InitHandler(void) { DFX_InstallSignalHandler(); @@ -95,13 +88,6 @@ static BOOL g_hasInit = FALSE; static int g_prevHandledSignal = SIGDUMP; static struct sigaction g_oldSigactionList[NSIG] = {}; static char g_appRunningId[MAX_APP_RUNNING_UNIQUE_ID_LEN]; -enum DumpPreparationStage { - CREATE_PIPE_FAIL = 1, - SET_PIPE_LEN_FAIL, - WRITE_PIPE_FAIL, - INHERIT_CAP_FAIL, - EXEC_FAIL, -}; const char* GetLastFatalMessage(void) __attribute__((weak)); fatal_msg_t *get_fatal_message(void) __attribute__((weak)); diff --git a/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h b/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h index 0e19989f0..d3d92dee6 100644 --- a/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h +++ b/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h @@ -23,6 +23,8 @@ extern "C" { void DfxDumpRequest(int signo, struct ProcessDumpRequest *request); +int32_t DFX_InheritCapabilities(void); + bool DFX_SetDumpableState(void); void DFX_RestoreDumpableState(void); diff --git a/interfaces/innerkits/signal_handler/libdfx_signalhandler.map b/interfaces/innerkits/signal_handler/libdfx_signalhandler.map index 9d8a0e24b..ac990f1df 100644 --- a/interfaces/innerkits/signal_handler/libdfx_signalhandler.map +++ b/interfaces/innerkits/signal_handler/libdfx_signalhandler.map @@ -10,6 +10,7 @@ DFX_SetCrashLogConfig; DFX_SetDumpableState; DFX_RestoreDumpableState; + DFX_InheritCapabilities; }; local: *; -- Gitee