From 0cc4ad5390a4fe07765e5b8ede4e632626d1ee1b Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 19 Dec 2016 15:26:30 +0900 Subject: [PATCH 01/16] crash-manager: consider backward compatibility for crash-stack Though the crash-stack is available about tid option, previous kernel has not supported this feature. Therefore the crash-manager should call crash-stack considering backward compatibility. Change-Id: I779783ed46760b88a6d454a05710b29cd4418a44 Signed-off-by: Sunmin Lee --- src/crash-manager/99-crash-manager.conf.in | 2 +- src/crash-manager/crash-manager.c | 32 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/crash-manager/99-crash-manager.conf.in b/src/crash-manager/99-crash-manager.conf.in index a58a81c..e036787 100644 --- a/src/crash-manager/99-crash-manager.conf.in +++ b/src/crash-manager/99-crash-manager.conf.in @@ -1,3 +1,3 @@ # Tizen crash-manager -kernel.core_pattern=|/usr/bin/crash-manager %p %i %u %g %s %t %e %E +kernel.core_pattern=|/usr/bin/crash-manager %p %u %g %s %t %e %E %i kernel.core_pipe_limit=10 diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index ec4d840..43994ba 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -211,7 +211,7 @@ static int make_dump_dir(void) return 0; } -static int set_crash_info(char *argv[]) +static int set_crash_info(int argc, char *argv[]) { int ret; char *temp_dir_ret; @@ -219,10 +219,11 @@ static int set_crash_info(char *argv[]) struct tm loc_tm; crash_info.pid_info = argv[1]; - crash_info.tid_info = argv[2]; - crash_info.cmd_info = argv[7]; + crash_info.cmd_info = argv[6]; + if (argc > 8) + crash_info.tid_info = argv[8]; - time_val = atoll(argv[6]); + time_val = atoll(argv[5]); localtime_r(&time_val, &loc_tm); strftime(crash_info.time_info, sizeof(crash_info.time_info), "%Y%m%d%H%M%S", &loc_tm); @@ -459,12 +460,19 @@ static void execute_crash_modules(int argc, char *argv[], int debug) /* Execute crash-stack */ /* - ret = snprintf(command, sizeof(command), - "%s --pid %s --tid %s >> %s", - CRASH_STACK_PATH, - crash_info.pid_info, - crash_info.tid_info, - crash_info.info_path); + if (argc > 8) + ret = snprintf(command, sizeof(command), + "%s --pid %s --tid %s >> %s", + CRASH_STACK_PATH, + crash_info.pid_info, + crash_info.tid_info, + crash_info.info_path); + else + ret = snprintf(command, sizeof(command), + "%s --pid %s >> %s", + CRASH_STACK_PATH, + crash_info.pid_info, + crash_info.info_path); if (ret < 0) { _E("Failed to snprintf for crash-stack command"); return; @@ -762,7 +770,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); /* Set crash info */ - if (set_crash_info(argv) < 0) + if (set_crash_info(argc, argv) < 0) exit(EXIT_FAILURE); #ifdef SYS_ASSERT @@ -772,7 +780,7 @@ int main(int argc, char *argv[]) /* .dbugmode: launch crash-popup */ if (access(DEBUGMODE_FILE, F_OK) == 0) - launch_crash_popup(argv[8]); + launch_crash_popup(argv[7]); /* Exec dump_systemstate */ dump_system_state(); -- 2.7.4 From 37b99923a1301b3c1a82e1b5616814a3c108fd2f Mon Sep 17 00:00:00 2001 From: Adrian Szyndela Date: Fri, 16 Dec 2016 13:27:35 +0100 Subject: [PATCH 02/16] crash-stack: fixed attaching to thread It is not necessary to attach to parent process main thread to resolve stack in another thread. This commit also solves hanging up on 'D' (and 'Z') processes - main thread is not attachable, when a crash occurs in another thread. Change-Id: Ic3a085951acb4057fcdd4a476693954d1d3a522b --- src/crash-stack/crash-stack.c | 51 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index 63a2b4a..894e876 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -290,14 +290,14 @@ void __find_symbol_in_elf(ProcInfo *proc_info, Dwarf_Addr mapping_start) close(fd); } -static int __attachable(pid_t pid) +static int __attachable(pid_t pid, pid_t tid) { /* read /proc//stat */ - char buf[20]; + char buf[40]; FILE *f; char status; - snprintf(buf, sizeof(buf), "/proc/%d/stat", pid); + snprintf(buf, sizeof(buf), "/proc/%d/task/%d/stat", pid, tid); f = fopen(buf, "r"); if (NULL == f) @@ -312,13 +312,13 @@ static int __attachable(pid_t pid) return status != 'D'; } -static void __print_proc_file(pid_t pid, const char *name) +static void __print_proc_file(pid_t pid, pid_t tid, const char *name) { char buf[1024]; FILE *f; int r; - snprintf(buf, sizeof(buf), "/proc/%d/%s", pid, name); + snprintf(buf, sizeof(buf), "/proc/%d/task/%d/%s", pid, tid, name); fprintf(outputfile, "%s:\n", buf); @@ -339,14 +339,14 @@ static void __print_proc_file(pid_t pid, const char *name) fprintf(outputfile, "\n"); } -static void __print_not_attachable_process_info(pid_t pid) +static void __print_not_attachable_process_info(pid_t pid, pid_t tid) { - fprintf(outputfile, "ERROR: can't attach to process %d - process is in uninterruptible sleep state\n", pid); + fprintf(outputfile, "ERROR: can't attach to process %d, thread %d - thread is in uninterruptible sleep state\n", pid, tid); fprintf(outputfile, "Giving some /proc info instead:\n\n"); - __print_proc_file(pid, "wchan"); + __print_proc_file(pid, tid, "wchan"); fprintf(outputfile, "\n"); - __print_proc_file(pid, "syscall"); - __print_proc_file(pid, "stack"); + __print_proc_file(pid, tid, "syscall"); + __print_proc_file(pid, tid, "stack"); } /** @@ -360,16 +360,16 @@ static Dwfl *__open_dwfl_with_pid(pid_t pid, pid_t tid) int status; pid_t stopped_pid; - status = __attachable(pid); + status = __attachable(pid, tid); if (-1 == status) { - fprintf(errfile, "failed to read /proc/%d/stat: %m\n", pid); + fprintf(errfile, "failed to read /proc/%d/task/%d/stat: %m\n", pid, tid); return NULL; } if (!status) { - __print_not_attachable_process_info(pid); + __print_not_attachable_process_info(pid, tid); return NULL; } @@ -378,23 +378,18 @@ static Dwfl *__open_dwfl_with_pid(pid_t pid, pid_t tid) return NULL; } - if (pid != tid) - if (ptrace(PTRACE_SEIZE, pid, NULL, PTRACE_O_TRACEEXIT) != 0) { - fprintf(errfile, "PTRACE_SEIZE failed on PID %d: %m\n", pid); - return NULL; - } - ptrace(PTRACE_INTERRUPT, tid, 0, 0); - ptrace(PTRACE_INTERRUPT, pid, 0, 0); - stopped_pid = waitpid(pid, &status, 0); - if (stopped_pid == -1 || stopped_pid != pid || !WIFSTOPPED(status)) { + stopped_pid = waitpid(tid, &status, __WALL); + if (stopped_pid == -1 || stopped_pid != tid || !WIFSTOPPED(status)) { fprintf(errfile, "waitpid failed: %m, stopped_pid=%d, status=%d\n", stopped_pid, status); return NULL; } - if (ptrace(PTRACE_GETSIGINFO, pid, NULL, &__siginfo) != 0) + if (ptrace(PTRACE_GETSIGINFO, tid, NULL, &__siginfo) != 0) { + fprintf(errfile, "ptrace GETSIGINFO failed: %m, pid=%d, tid=%d\n", pid, tid); return NULL; + } static const Dwfl_Callbacks proc_callbacks = { .find_elf = dwfl_linux_proc_find_elf, @@ -405,19 +400,19 @@ static Dwfl *__open_dwfl_with_pid(pid_t pid, pid_t tid) Dwfl *dwfl = dwfl_begin(&proc_callbacks); if (dwfl == NULL) { - fprintf(errfile, "process %d : Can't start dwfl (%s)\n", pid, dwfl_errmsg(-1)); + fprintf(errfile, "process %d : Can't start dwfl (%s)\n", tid, dwfl_errmsg(-1)); return NULL; } - if (dwfl_linux_proc_report(dwfl, pid) < 0) { - fprintf(errfile, "process %d : dwfl report failed (%s)\n", pid, dwfl_errmsg(-1)); + if (dwfl_linux_proc_report(dwfl, tid) < 0) { + fprintf(errfile, "process %d : dwfl report failed (%s)\n", tid, dwfl_errmsg(-1)); dwfl_end(dwfl); return NULL; } #if _ELFUTILS_PREREQ(0,158) - if (dwfl_linux_proc_attach(dwfl, pid, true) < 0) { - fprintf(errfile, "process %d : dwfl attach failed (%s)\n", pid, dwfl_errmsg(-1)); + if (dwfl_linux_proc_attach(dwfl, tid, true) < 0) { + fprintf(errfile, "process %d : dwfl attach failed (%s)\n", tid, dwfl_errmsg(-1)); dwfl_end(dwfl); return NULL; } -- 2.7.4 From c954427bb005de2308e92d8f70284b1301fe35c3 Mon Sep 17 00:00:00 2001 From: Rafal Pietruch Date: Thu, 15 Dec 2016 16:28:17 +0100 Subject: [PATCH 03/16] crash-stack: use libunwind for i686 and x86_64 Change-Id: I0022cc3ac772ba26ed67f7d64d45c3ab4e22db88 --- src/crash-stack/CMakeLists.txt | 28 +++-- src/crash-stack/crash-stack-libelf-helpers.c | 46 ------- src/crash-stack/crash-stack-libelf.c | 180 --------------------------- src/crash-stack/crash-stack-libunw.c | 9 +- src/crash-stack/crash-stack-x86.c | 24 ++-- 5 files changed, 30 insertions(+), 257 deletions(-) delete mode 100644 src/crash-stack/crash-stack-libelf.c diff --git a/src/crash-stack/CMakeLists.txt b/src/crash-stack/CMakeLists.txt index ccf845e..499c9dc 100644 --- a/src/crash-stack/CMakeLists.txt +++ b/src/crash-stack/CMakeLists.txt @@ -4,22 +4,24 @@ option(WITH_CORE_DUMP "builds with support for core dump files (with GPL2 licens set(CRASH_STACK_BIN "crash-stack") # Common source code files -set(CRASH_STACK_SRCS crash-stack.c crash-stack-libelf-helpers.c) +set(CRASH_STACK_SRCS crash-stack.c) + # Add architecture dependent source files -if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libunw.c) - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-arm.c) +if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-aarch64.c) + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf-helpers.c) + else() - if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-aarch64.c) - elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf.c) - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86.c) - elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686") - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf.c) + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libunw.c) + + if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-arm.c) + + elseif ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") + OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")) set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86.c) + else() - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf.c) set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-stub.c) endif() endif() @@ -28,7 +30,7 @@ endif() add_executable(${CRASH_STACK_BIN} ${CRASH_STACK_SRCS}) # Set architecture dependent options for the binary - it must be already added -if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") +if (NOT (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")) include(FindPkgConfig) pkg_check_modules(LIBUNWIND_PTRACE REQUIRED libunwind-ptrace) set_property(TARGET ${CRASH_STACK_BIN} APPEND_STRING PROPERTY COMPILE_FLAGS ${LIBUNWIND_PTRACE_CFLAGS_OTHER}) diff --git a/src/crash-stack/crash-stack-libelf-helpers.c b/src/crash-stack/crash-stack-libelf-helpers.c index ab95350..8239a05 100644 --- a/src/crash-stack/crash-stack-libelf-helpers.c +++ b/src/crash-stack/crash-stack-libelf-helpers.c @@ -92,49 +92,3 @@ bool _crash_stack_libelf_read_value(Dwfl *dwfl, Elf *core, pid_t pid, return false; } - -Dwarf_Addr _crash_stack_libelf_get_prologue_pc(Dwfl *dwfl, Dwarf_Addr current_pc, Mappings *mappings) -{ - Dwarf_Addr result = 0; - Dwfl_Module *module = dwfl_addrmodule(dwfl, current_pc); - if (module) { - GElf_Sym sym; - dwfl_module_addrsym(module, current_pc, &sym, NULL); - result = sym.st_value; - } - if (0 == result) { - int i; - for (i=0; i < mappings->elems; i++) { - if (mappings->tab[i].m_start <= current_pc && current_pc < mappings->tab[i].m_end) { - /* go through symbols to find the nearest */ - Elf_Scn *scn = NULL; - Elf *elf = mappings->tab[i].m_elf; - while ((scn = elf_nextscn(elf, scn)) != NULL) { - GElf_Shdr shdr_mem; - GElf_Shdr *shdr = gelf_getshdr(scn, &shdr_mem); - if (shdr != NULL && (shdr->sh_type == SHT_SYMTAB || shdr->sh_type == SHT_DYNSYM)) { - Elf_Data *sdata = elf_getdata(scn, NULL); - unsigned int nsyms = sdata->d_size / (gelf_getclass(elf) == ELFCLASS32 ? - sizeof(Elf32_Sym) : - sizeof(Elf64_Sym)); - unsigned int cnt; - uintptr_t address_offset = current_pc; - if (shdr->sh_type == SHT_DYNSYM) - address_offset -= mappings->tab[i].m_start; - for (cnt = 0; cnt < nsyms; ++cnt) { - GElf_Sym sym_mem; - Elf32_Word xndx; - GElf_Sym *sym = gelf_getsymshndx(sdata, NULL, cnt, &sym_mem, &xndx); - if (sym != NULL && sym->st_shndx != SHN_UNDEF) { - if (sym->st_value <= address_offset && address_offset < sym->st_value + sym->st_size) { - return sym->st_value; - } - } - } - } - } - } - } - } - return result; -} diff --git a/src/crash-stack/crash-stack-libelf.c b/src/crash-stack/crash-stack-libelf.c deleted file mode 100644 index c341c96..0000000 --- a/src/crash-stack/crash-stack-libelf.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * - * Copyright (c) 2016 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Adrian Szyndela - */ -/** - * @file crash-stack-libelf.c - * @brief unwinding call stacks, functions specific for archs that use only libelf - */ -#include "crash-stack.h" -#include -#include -#include - -/** - * @brief Convenience type for registers of different sizes - */ -typedef union { - uint16_t reg16; ///< 16-bit register - uint32_t reg32; ///< 32-bit register - uint64_t reg64; ///< 64-bit register -} Register; - -static Register g_pc; ///< storage for program counter value -static Register g_sp; ///< storage for stack pointer value - -#if _ELFUTILS_PREREQ(0,158) -/** - * @brief Callback for modern elfutils; called on each found frame. - * - * @param state state of the calls tack traversal - * @param arg user data - pointer to callstack database - */ -static int __frame_callback(Dwfl_Frame *state, void *arg) -{ - Callstack *callstack = (Callstack*)arg; - Dwarf_Addr address; - dwfl_frame_pc(state, &address, NULL); - callstack->proc[callstack->elems++].addr = address; - return callstack->elems < MAX_CALLSTACK_LEN ? DWARF_CB_OK : DWARF_CB_ABORT; -} - -/** - * @brief Callback for modern elfutils; called on each found thread. - * - * @param thread thread handle - * @param thread_arg user data - pointer to callstack database - */ -static int __thread_callback(Dwfl_Thread *thread, void *thread_arg) -{ - dwfl_thread_getframes(thread, __frame_callback, thread_arg); - return DWARF_CB_ABORT; -} -#endif - -/** - * @brief common names for program counter/instruction pointer - */ -static const char *pc_names[] = { - "pc", "rip", "eip", "ip" -}; - -/** - * @brief common names for stack pointer - */ -static const char *sp_names[] = { - "sp", "rsp", "esp" -}; - -/** - * @brief Helper functions that checks if a name is present in array of names - * - * @param name name to look for - * @param names array of names - * @param elems number of elements in names - * @returns true if name is found in names, false otherwise - */ -static bool __is_in(const char *name, const char **names, int elems) -{ - int nit; - for (nit = 0; nit < elems; ++nit) { - if (strcmp(name, names[nit]) == 0) - return true; - } - return false; -} - -/** - * @brief Helper macro for looking for name in array of names - */ -#define IS_IN(name,names) __is_in((name), (names), sizeof(names)/sizeof(names[0])) - -void *_get_place_for_register_value(const char *regname, int regnum) -{ - if (IS_IN(regname, pc_names)) return &g_pc; - else if (IS_IN(regname, sp_names)) return &g_sp; - - return 0; -} - -/** - * @brief Tries to heuristically gather call stack information. - * - * @remarks This function walks through the stack of the given process, and checks - * if found addresses are addresses belonging to functions. If so, it treats - * such address as an element of the call stack. - * While it gathers some useful information, it gathers also "false positives". - * @remarks It should be used as a last resort - when no other method is available. - * - * @param dwfl dwfl handle - * @param core core file handle, NULL if live process is analyzed - * @param pid PID of the analyzed process, 0 if core dump file is analyzed - * @param mappings module mappings database - * @param callstack call stack database - */ -static void _explore_stack_in_search_of_functions(Dwfl *dwfl, Elf *core, pid_t pid, - Mappings *mappings, Callstack *callstack) -{ - Dwarf_Addr stack_pointer = sizeof(uintptr_t) == 4 ? g_sp.reg32 : g_sp.reg64; - Dwarf_Addr stack_max_lookup = stack_pointer + 8*1024*1024; - bool data_remaining = true; - do { - uintptr_t value; - data_remaining = _crash_stack_libelf_read_value(dwfl, core, pid, stack_pointer, - &value, sizeof(value), mappings); - if (data_remaining) { - Dwarf_Addr bias; - /* check presence of address in text sections */ - Dwfl_Module *module = dwfl_addrmodule(dwfl, value); - if (module != NULL) { - Dwarf_Addr elfval = value; - GElf_Sym sym; - GElf_Word shndxp = -1; - dwfl_module_addrsym(module, value, &sym, &shndxp); - Elf_Scn *scn = dwfl_module_address_section(module, &elfval, &bias); - if (scn != 0 || shndxp != -1) { - callstack->proc[callstack->elems++].addr = value; - if (callstack->elems >= MAX_CALLSTACK_LEN) - return; - } - else { - /* check also inside [pie] and [exe] */ - int i; - for (i = 0; i < mappings->elems; i++) { - if (mappings->tab[i].m_start <= elfval && elfval < mappings->tab[i].m_end) { - callstack->proc[callstack->elems++].addr = value; - break; - } - } - } - } - } - stack_pointer += sizeof(uintptr_t); - } while (data_remaining && stack_pointer < stack_max_lookup); -} - -void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, Callstack *callstack) -{ - callstack->elems = 0; -#if _ELFUTILS_PREREQ(0,158) - dwfl_getthreads(dwfl, __thread_callback, callstack); -#else - callstack->proc[callstack->elems++].addr = sizeof(uintptr_t) == 4 ? g_pc.reg32 : g_pc.reg64; - _explore_stack_in_search_of_functions(dwfl, core, pid, mappings, callstack); -#endif -} - diff --git a/src/crash-stack/crash-stack-libunw.c b/src/crash-stack/crash-stack-libunw.c index 23e3df3..f013e63 100644 --- a/src/crash-stack/crash-stack-libunw.c +++ b/src/crash-stack/crash-stack-libunw.c @@ -33,6 +33,7 @@ void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, C unw_addr_space_t as = 0; void *ui = 0; do { + //init before return callstack->elems = 0; as = unw_create_addr_space(&_UPT_accessors, 0); @@ -48,11 +49,8 @@ void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, C break; char proc_name[MAXPROCNAMELEN]; - int n; - // MaxDeep as proposed in libunwind tests/test-ptrace.c file - // guard against bad unwind info in old libraries - static const int MaxDeep = 64; - for (n = 0; n < MaxDeep; ++n) { + for (; callstack->elems < sizeof(callstack->proc)/sizeof(callstack->proc[0]); + ++callstack->elems) { unw_word_t ip; if (unw_get_reg(&cursor, UNW_REG_IP, &ip) < 0) @@ -66,7 +64,6 @@ void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, C callstack->proc[callstack->elems].name = strdup(proc_name); callstack->proc[callstack->elems].offset = off; - ++callstack->elems; if (unw_step(&cursor) <= 0) break; } diff --git a/src/crash-stack/crash-stack-x86.c b/src/crash-stack/crash-stack-x86.c index b63f279..a72a198 100644 --- a/src/crash-stack/crash-stack-x86.c +++ b/src/crash-stack/crash-stack-x86.c @@ -33,20 +33,20 @@ void *_crash_stack_get_memory_for_ptrace_registers(size_t *size) return &g_registers; } -void _crash_stack_set_ptrace_registers(void *regbuf) +void *_get_place_for_register_value(const char *regname, int regnum) { - void *rsp = _get_place_for_register_value("rsp", 0); - void *rip = _get_place_for_register_value("rip", 0); - - struct user_regs_struct *regs = regbuf; + /* Function is not used for x86 anymore, make it dummy + * It is still called by generic __get_registers_core function + * The return value is checked for NULL in __get_registers_core. + */ + return NULL; +} -#if defined(__x86_64__) - memcpy(rsp, ®s->rsp, sizeof(regs->rsp)); - memcpy(rip, ®s->rip, sizeof(regs->rip)); -#else - memcpy(rsp, ®s->esp, sizeof(regs->esp)); - memcpy(rip, ®s->eip, sizeof(regs->eip)); -#endif +void _crash_stack_set_ptrace_registers(void *regbuf) +{ + /* Make it dummy as it not used for x86 anymore + * However it is still called by generic __get_registers_ptrace functions + */ } void _crash_stack_print_regs(FILE* outputfile) -- 2.7.4 From 254636d7f4be7df048ec4c17cc9159da661a2d97 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Thu, 22 Dec 2016 17:58:58 +0900 Subject: [PATCH 04/16] Fix handle leak Fix handle leak of file pointer at crash-stack Change-Id: I2d68e04ad84ea7263e3c45cc91ef295557532bde Signed-off-by: Sunmin Lee --- src/crash-stack/crash-stack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index 71d2f15..82be10d 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -298,8 +298,10 @@ static int __attachable(pid_t pid, pid_t tid) return -1; /* check if status is D */ - if (fscanf(f, "%*d %*s %c", &status) != 1) + if (fscanf(f, "%*d %*s %c", &status) != 1) { + fclose(f); return -1; + } fclose(f); -- 2.7.4 From 0a9ed365d2bc330f710f1c2e0be8ec4867be56b8 Mon Sep 17 00:00:00 2001 From: Kunhoon Baik Date: Mon, 4 Jul 2016 20:01:31 +0900 Subject: [PATCH 05/16] Remove SIGSEGV handling SIGSEGV (signal number - 11) may occur double crash when sys-assert tries to unwind backtrace. like that If the double crash is generated, it causes useless backtrace of corefile (double crashed memory dump) Thus, sys-assert does not handle SIGSEGV. Change-Id: I826ee2bab796fc87b2b4a003683315514af96339 --- src/sys-assert/sys-assert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys-assert/sys-assert.c b/src/sys-assert/sys-assert.c index 5f8f30c..0c1bbf2 100644 --- a/src/sys-assert/sys-assert.c +++ b/src/sys-assert/sys-assert.c @@ -88,7 +88,7 @@ int sig_to_handle[] = { SIGILL, SIGTRAP, SIGABRT, SIGBUS, - SIGFPE, SIGSEGV, SIGSTKFLT, SIGXCPU, SIGXFSZ, SIGSYS }; + SIGFPE, SIGSTKFLT, SIGXCPU, SIGXFSZ, SIGSYS }; #define NUM_SIG_TO_HANDLE \ ((int)(sizeof(sig_to_handle)/sizeof(sig_to_handle[0]))) -- 2.7.4 From cb172a80debe9debc352651aad2a84051a067c74 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 26 Dec 2016 20:31:43 +0900 Subject: [PATCH 06/16] crash-stack: Make ptrace callstack feature selective In Tizen 3.0, the crash-stack using ptrace to generate callstack will be offered as a choice. Developers can enable this feature through setting a variable as on: TIZEN_FEATURE_PTRACE_CALLSTACK Change-Id: I7dfbf563144174abcd5e50677eb8943cdb8d8ebe Signed-off-by: Sunmin Lee --- CMakeLists.txt | 4 +++- packaging/crash-worker.spec | 8 +++++++- src/crash-manager/crash-manager.c | 2 ++ src/crash-manager/crash-manager.h.in | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dc9668..a3ca59d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,9 @@ IF("${SYS_ASSERT}" STREQUAL "ON") ENDIF("${SYS_ASSERT}" STREQUAL "ON") ADD_SUBDIRECTORY(src/crash-pipe) -ADD_SUBDIRECTORY(src/crash-stack) +IF(TIZEN_FEATURE_PTRACE_CALLSTACK STREQUAL on) + ADD_SUBDIRECTORY(src/crash-stack) +ENDIF() ADD_SUBDIRECTORY(src/dump_systemstate) ADD_SUBDIRECTORY(src/log_dump) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index c6d1b9b..a7dddc6 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -2,6 +2,7 @@ %define on_off() %{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}} %define _with_sys_assert on +%define TIZEN_FEATURE_PTRACE_CALLSTACK off %bcond_with doc %bcond_with core_dump %bcond_with sys_assert @@ -96,10 +97,13 @@ export CFLAGS+=" -Werror" -DCRASH_PATH=%{crash_path} \ -DCRASH_TEMP=%{crash_temp} \ -DCRASH_PIPE_PATH=%{_libexecdir}/crash-pipe \ +%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on" -DCRASH_STACK_PATH=%{_libexecdir}/crash-stack \ +%endif -DSYS_ASSERT=%{on_off sys_assert} \ -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \ - -DWITH_CORE_DUMP=%{on_off core_dump} + -DWITH_CORE_DUMP=%{on_off core_dump} \ + -DTIZEN_FEATURE_PTRACE_CALLSTACK=%{TIZEN_FEATURE_PTRACE_CALLSTACK} make %{?jobs:-j%jobs} %if %{with doc} @@ -170,7 +174,9 @@ sed -i "/${pattern}/D" %{_sysconfdir}/ld.so.preload %endif %{_libexecdir}/crash-pipe +%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on" %{_libexecdir}/crash-stack +%endif #upgrade script %attr(-,root,root) %{upgrade_script_path}/500.crash-manager-upgrade.sh diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 43994ba..9a02e4d 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -458,6 +458,7 @@ static void execute_crash_modules(int argc, char *argv[], int debug) } system_command(command); +#ifdef TIZEN_FEATURE_PTRACE_CALLSTACK /* Execute crash-stack */ /* if (argc > 8) @@ -479,6 +480,7 @@ static void execute_crash_modules(int argc, char *argv[], int debug) } system_command(command); */ +#endif /* TIZEN_FEATURE_PTRACE_CALLSTACK */ } static int lock_dumpdir(void) diff --git a/src/crash-manager/crash-manager.h.in b/src/crash-manager/crash-manager.h.in index 90de995..772177e 100644 --- a/src/crash-manager/crash-manager.h.in +++ b/src/crash-manager/crash-manager.h.in @@ -23,7 +23,9 @@ #define CRASH_PATH "@CRASH_PATH@" #define CRASH_TEMP "@CRASH_TEMP@" #define SYS_ASSERT "@SYS_ASSERT@" +#ifdef TIZEN_FEATURE_PTRACE_CALLSTACK #define CRASH_STACK_PATH "@CRASH_STACK_PATH@" +#endif #define CRASH_PIPE_PATH "@CRASH_PIPE_PATH@" #define DEBUG 1 -- 2.7.4 From 01688ae10a3769975b8e51d01d4345285547ed5b Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 27 Dec 2016 11:25:12 +0900 Subject: [PATCH 07/16] log_dump: Restrict dbus permission log_dump can be activated using dbus method call. Because this feature should be used by administrator only, restrict the dbus activation permission. Change-Id: Ib63ea10fd5101af146e35cf9ef47e96f91a3229f Signed-off-by: Sunmin Lee --- packaging/crash-worker.spec | 5 +++-- src/log_dump/CMakeLists.txt | 2 ++ src/log_dump/log_dump.conf | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/log_dump/log_dump.conf diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index a7dddc6..6422083 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -165,8 +165,9 @@ sed -i "/${pattern}/D" %{_sysconfdir}/ld.so.preload %attr(0644,root,system) %{_unitdir}/tizen-debug-on.service %attr(0644,root,system) %{_unitdir}/tizen-debug-off.service %{TZ_SYS_ETC}/crash-manager.conf -%{_prefix}/lib/sysctl.d/99-crash-manager.conf -%{_datadir}/dbus-1/system-services/org.tizen.system.crash.service +%attr(-,root,root) %{_sysconfdir}/dbus-1/system.d/log_dump.conf +%attr(-,root,root) %{_prefix}/lib/sysctl.d/99-crash-manager.conf +%attr(-,root,root) %{_datadir}/dbus-1/system-services/org.tizen.system.crash.service %if %{with sys_assert} %{_libdir}/libsys-assert.so diff --git a/src/log_dump/CMakeLists.txt b/src/log_dump/CMakeLists.txt index 7fa6891..20202b6 100644 --- a/src/log_dump/CMakeLists.txt +++ b/src/log_dump/CMakeLists.txt @@ -28,6 +28,8 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${log_dump_pkgs_LDFLAGS} -pie) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.system.crash.service DESTINATION /usr/share/dbus-1/system-services) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/log_dump.conf + DESTINATION /etc/dbus-1/system.d) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/log_dump/log_dump.conf b/src/log_dump/log_dump.conf new file mode 100644 index 0000000..3d3e8e0 --- /dev/null +++ b/src/log_dump/log_dump.conf @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + -- 2.7.4 From 19a4af3a67bdaaf2987c318d02e9fb0260fb7c57 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 27 Dec 2016 16:44:49 +0900 Subject: [PATCH 08/16] Separate package dependencies of crash-stack According to experimental variable, exclude unused package dependencies from crash-worker.spec. + Bug fix: "crash-stack: Make ptrace callstack feature selective" Change-Id: If8746a74fb937f7929538a995d6f1cf392e19bd4 Signed-off-by: Sunmin Lee --- packaging/crash-worker.spec | 4 ++++ src/crash-manager/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index a7dddc6..8a8735b 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -25,9 +25,11 @@ BuildRequires: cmake %if %{with sys_assert} BuildRequires: pkgconfig(libunwind) %endif +%if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on" BuildRequires: libelf-devel libelf BuildRequires: libebl-devel libebl BuildRequires: libdw-devel libdw +%endif %ifarch %{arm} BuildRequires: pkgconfig(libunwind-ptrace) %endif @@ -39,6 +41,8 @@ Requires(post): coreutils Requires(post): tar Requires(post): gzip Requires: zip +Requires: libelf +Requires: libdw # If you need support for core dump files (see building below), # you should add this dependency # Requires: libebl diff --git a/src/crash-manager/CMakeLists.txt b/src/crash-manager/CMakeLists.txt index 361ac34..24ead7e 100644 --- a/src/crash-manager/CMakeLists.txt +++ b/src/crash-manager/CMakeLists.txt @@ -1,6 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(crash-manager C) +IF(TIZEN_FEATURE_PTRACE_CALLSTACK STREQUAL on) + ADD_DEFINITIONS(-DTIZEN_FEATURE_PTRACE_CALLSTACK) +ENDIF() + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) SET(CRASH_MANAGER_SRCS crash-manager.c -- 2.7.4 From 8e2f5635896514fb5469276caf54870dad681f73 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 27 Dec 2016 19:33:55 +0900 Subject: [PATCH 09/16] Adjust smack label In response to security issue, restrict smack label of crash-manager. In addition, adjust crash directories label to accord with work of crash-worker. Change-Id: I97390d50337fd36a746e260f3f6ebc29c6990526 Signed-off-by: Sunmin Lee --- packaging/crash-worker.manifest | 3 ++- packaging/crash-worker.spec | 10 +++++----- src/crash-manager/CMakeLists.txt | 1 - src/crash-manager/crash-manager.c | 7 ------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packaging/crash-worker.manifest b/packaging/crash-worker.manifest index 8e0f4fd..c6cdebc 100644 --- a/packaging/crash-worker.manifest +++ b/packaging/crash-worker.manifest @@ -4,6 +4,7 @@ - + + diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index d2a83e3..b436ad6 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -16,7 +16,6 @@ License: Apache-2.0 and PD Source0: %{name}-%{version}.tar.gz Source1001: crash-worker.manifest BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(capi-system-info) @@ -142,10 +141,11 @@ fi /sbin/ldconfig %endif -/usr/bin/chsmack -a "System::Shared" -t %{crash_path} -/usr/bin/chsmack -a "System::Shared" -t %{crash_temp} -/usr/bin/chsmack -a "System::Shared" -t %{crash_dump_gen} -/usr/bin/chsmack -a "System::Shared" -t %{crash_dump_gen}/module.d +/usr/bin/chsmack -a "System" -t %{crash_path} +/usr/bin/chsmack -a "System" -t %{crash_temp} +/usr/bin/chsmack -a "System" -t %{crash_dump_gen} +/usr/bin/chsmack -a "System" -t %{crash_dump_gen}/module.d +/usr/bin/chsmack -a "System::Shared" -t %{crash_all_log} /usr/bin/chsmack -a "_" %{crash_dump_gen}/module.d/* %postun diff --git a/src/crash-manager/CMakeLists.txt b/src/crash-manager/CMakeLists.txt index 24ead7e..357fcaa 100644 --- a/src/crash-manager/CMakeLists.txt +++ b/src/crash-manager/CMakeLists.txt @@ -14,7 +14,6 @@ SET(CRASH_MANAGER_SRCS INCLUDE(FindPkgConfig) pkg_check_modules(crash-manager_pkgs REQUIRED dlog - libsmack libtzplatform-config iniparser gio-2.0 diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 9a02e4d..c003c07 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -188,9 +187,6 @@ static int make_dump_dir(void) _E("Failed to mkdir for %s", CRASH_PATH); return -1; } - smack_setlabel(CRASH_PATH, "System::Shared", - SMACK_LABEL_ACCESS); - smack_setlabel(CRASH_PATH, "1", SMACK_LABEL_TRANSMUTE); } if (!stat(CRASH_TEMP, &st)) { @@ -203,9 +199,6 @@ static int make_dump_dir(void) _E("Failed to mkdir for %s", CRASH_TEMP); return -1; } - smack_setlabel(CRASH_TEMP, "System::Shared", - SMACK_LABEL_ACCESS); - smack_setlabel(CRASH_TEMP, "1", SMACK_LABEL_TRANSMUTE); } return 0; -- 2.7.4 From 700c19f007eac4940be732a13f031e46ec644ac1 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 27 Dec 2016 20:15:52 +0900 Subject: [PATCH 10/16] Remove PD License Change-Id: Iaa3daf6bf96c5ae59ad77515a0f942f4d4a71586 Signed-off-by: Sunmin Lee --- packaging/crash-worker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index b436ad6..20f6898 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -12,7 +12,7 @@ Summary: Crash-manager Version: 0.3.0 Release: 1 Group: Framework/system -License: Apache-2.0 and PD +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: crash-worker.manifest BuildRequires: pkgconfig(dlog) -- 2.7.4 From 7435d1df3bd919fe6b0f9c3cb0399dbe545d2686 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 27 Dec 2016 14:49:41 +0900 Subject: [PATCH 11/16] crash-stack: Simplify signal info It is hard to get signal info which caused dump using ptrace. Therefore, crash-stack prints signal number only which came from core_pattern. Change-Id: I6cd865a89d3e2c5dd83cfe134bb8cddec4f7f81f Signed-off-by: Sunmin Lee --- src/crash-manager/crash-manager.c | 8 +++++-- src/crash-stack/crash-stack.c | 45 ++++++++++++--------------------------- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index c003c07..8c64d78 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -88,6 +88,7 @@ static struct crash_info { char *cmd_info; char *pid_info; char *tid_info; + char *sig_info; char time_info[80]; char temp_dir[PATH_MAX]; char name[FILENAME_MAX]; @@ -212,6 +213,7 @@ static int set_crash_info(int argc, char *argv[]) struct tm loc_tm; crash_info.pid_info = argv[1]; + crash_info.sig_info = argv[4]; crash_info.cmd_info = argv[6]; if (argc > 8) crash_info.tid_info = argv[8]; @@ -456,16 +458,18 @@ static void execute_crash_modules(int argc, char *argv[], int debug) /* if (argc > 8) ret = snprintf(command, sizeof(command), - "%s --pid %s --tid %s >> %s", + "%s --pid %s --tid %s --sig %s >> %s", CRASH_STACK_PATH, crash_info.pid_info, crash_info.tid_info, + crash_info.sig_info, crash_info.info_path); else ret = snprintf(command, sizeof(command), - "%s --pid %s >> %s", + "%s --pid %s --sig %s >> %s", CRASH_STACK_PATH, crash_info.pid_info, + crash_info.sig_info, crash_info.info_path); if (ret < 0) { _E("Failed to snprintf for crash-stack command"); diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index 82be10d..250e780 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -56,7 +56,6 @@ #define STR_ANONY "[anony]" #define STR_ANONY_LEN 8 -static siginfo_t __siginfo; static FILE *outputfile = NULL; ///< global output stream static FILE *errfile = NULL; ///< global error stream @@ -66,6 +65,7 @@ static FILE *errfile = NULL; ///< global error stream enum { OPT_PID, OPT_TID, + OPT_SIGNUM, OPT_OUTPUTFILE, OPT_ERRFILE }; @@ -76,6 +76,7 @@ enum { const struct option opts[] = { { "pid", required_argument, 0, OPT_PID }, { "tid", required_argument, 0, OPT_TID }, + { "sig", required_argument, 0, OPT_SIGNUM }, { "output", required_argument, 0, OPT_OUTPUTFILE }, { "erroutput", required_argument, 0, OPT_ERRFILE }, { 0, 0, 0, 0 } @@ -382,11 +383,6 @@ static Dwfl *__open_dwfl_with_pid(pid_t pid, pid_t tid) return NULL; } - if (ptrace(PTRACE_GETSIGINFO, tid, NULL, &__siginfo) != 0) { - fprintf(errfile, "ptrace GETSIGINFO failed: %m, pid=%d, tid=%d\n", pid, tid); - return NULL; - } - static const Dwfl_Callbacks proc_callbacks = { .find_elf = dwfl_linux_proc_find_elf, .find_debuginfo = dwfl_standard_find_debuginfo, @@ -443,17 +439,14 @@ static int __get_registers_ptrace(pid_t pid) } /** - * @brief Get information about the signal that stopped the process - * - * @param pid pid of the live process - * @return 0 on success, -1 otherwise + * @brief Print signal number causing dump */ -static int __get_signal_ptrace(pid_t pid) +static void __crash_stack_print_signal(int signo) { const char* const signal_table[] = { [SIGHUP]="SIGHUP", [SIGINT]="SIGINT", [SIGQUIT]="SIGQUIT", [SIGILL]="SIGILL", [SIGTRAP]="SIGTRAP", [SIGABRT]="SIGABRT", - [SIGIOT]="SIGIOT", [SIGBUS]="SIGBUS", [SIGFPE]="SIGFPE", + /* [SIGIOT]="SIGIOT", */ [SIGBUS]="SIGBUS", [SIGFPE]="SIGFPE", [SIGKILL]="SIGKILL", [SIGUSR1]="SIGUSR1", [SIGSEGV]="SIGSEGV", [SIGUSR2]="SIGUSR2", [SIGPIPE]="SIGPIPE", [SIGALRM]="SIGALRM", [SIGTERM]="SIGTERM", [SIGSTKFLT]="SIGSTKFLT", [SIGCHLD]="SIGCHLD", @@ -465,23 +458,9 @@ static int __get_signal_ptrace(pid_t pid) }; printf("Signal: %d\n" - "\t(%s)\n" - "\tsi_code: %d\n", - __siginfo.si_signo, - signal_table[__siginfo.si_signo], - __siginfo.si_code); - switch (__siginfo.si_code) { - case SI_TKILL: - case SI_USER: - printf("\tsignal sent by %s (sent by pid %d, uid %d)", - __siginfo.si_code == SI_TKILL ? "tkill" : "kill", - __siginfo.si_pid, __siginfo.si_uid); - break; - case SI_KERNEL: - printf("\tsignal sent by the kernel\n"); - break; - } - return 0; + "\t(%s)\n", + signo, + signal_table[signo]); } /** @@ -987,6 +966,7 @@ static void __crash_stack_print_meminfo(FILE* outputfile, pid_t pid) int main(int argc, char **argv) { int c; + int signo = 0; pid_t pid = 0; pid_t tid = 0; @@ -1000,6 +980,9 @@ int main(int argc, char **argv) case OPT_TID: tid = atoi(optarg); break; + case OPT_SIGNUM: + signo = atoi(optarg); + break; case OPT_OUTPUTFILE: outputfile = fopen(optarg, "w"); break; @@ -1043,8 +1026,8 @@ int main(int argc, char **argv) __crash_stack_print_exe(outputfile, pid); /* Now, get registers */ - if (-1 == __get_signal_ptrace(pid)) - return 4444; + __crash_stack_print_signal(signo); + if (-1 == __get_registers_ptrace(tid)) return 3333; -- 2.7.4 From 8e3dae0b649c19e51d76e2af6cea8ebcb6eb4a78 Mon Sep 17 00:00:00 2001 From: Kunhoon Baik Date: Tue, 27 Dec 2016 22:00:35 +0900 Subject: [PATCH 12/16] crash-stack: libunwind used on aarch64 Make use of "ptrace: Add support for GETREGSET" patch to libunwind https://lists.nongnu.org/archive/html/libunwind-devel/2016-07/msg00001.html Depends-On: I2e720e6697fbc1facf1d7547b398f5665b17731e Change-Id: I0ce3886d271c9b78d2a44b99a628ccc502e6e400 --- packaging/crash-worker.spec | 9 +++------ src/crash-stack/CMakeLists.txt | 30 +++++++++++------------------- src/crash-stack/crash-stack-aarch64.c | 24 ------------------------ 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 20f6898..b385024 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -21,17 +21,14 @@ BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(glib-2.0) BuildRequires: cmake -%if %{with sys_assert} -BuildRequires: pkgconfig(libunwind) -%endif + +BuildRequires: pkgconfig(libunwind-ptrace) %if "%{TIZEN_FEATURE_PTRACE_CALLSTACK}" == "on" BuildRequires: libelf-devel libelf BuildRequires: libebl-devel libebl BuildRequires: libdw-devel libdw %endif -%ifarch %{arm} -BuildRequires: pkgconfig(libunwind-ptrace) -%endif + %if %{with doc} BuildRequires: doxygen %endif diff --git a/src/crash-stack/CMakeLists.txt b/src/crash-stack/CMakeLists.txt index 499c9dc..807d898 100644 --- a/src/crash-stack/CMakeLists.txt +++ b/src/crash-stack/CMakeLists.txt @@ -4,37 +4,29 @@ option(WITH_CORE_DUMP "builds with support for core dump files (with GPL2 licens set(CRASH_STACK_BIN "crash-stack") # Common source code files -set(CRASH_STACK_SRCS crash-stack.c) +set(CRASH_STACK_SRCS crash-stack.c crash-stack-libunw.c) # Add architecture dependent source files if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-aarch64.c) - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf-helpers.c) -else() - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libunw.c) - - if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-arm.c) +elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-arm.c) - elseif ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") - OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")) - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86.c) +elseif ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") + OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")) + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86.c) - else() - set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-stub.c) - endif() +else() + set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-stub.c) endif() # Binary add_executable(${CRASH_STACK_BIN} ${CRASH_STACK_SRCS}) -# Set architecture dependent options for the binary - it must be already added -if (NOT (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")) - include(FindPkgConfig) - pkg_check_modules(LIBUNWIND_PTRACE REQUIRED libunwind-ptrace) - set_property(TARGET ${CRASH_STACK_BIN} APPEND_STRING PROPERTY COMPILE_FLAGS ${LIBUNWIND_PTRACE_CFLAGS_OTHER}) -endif() +include(FindPkgConfig) +pkg_check_modules(LIBUNWIND_PTRACE REQUIRED libunwind-ptrace) +set_property(TARGET ${CRASH_STACK_BIN} APPEND_STRING PROPERTY COMPILE_FLAGS ${LIBUNWIND_PTRACE_CFLAGS_OTHER}) # Set compilation options for core dump support if (${WITH_CORE_DUMP} STREQUAL "ON") diff --git a/src/crash-stack/crash-stack-aarch64.c b/src/crash-stack/crash-stack-aarch64.c index 420cb9b..3209356 100644 --- a/src/crash-stack/crash-stack-aarch64.c +++ b/src/crash-stack/crash-stack-aarch64.c @@ -61,30 +61,6 @@ void _crash_stack_set_ptrace_registers(void *regbuf) memcpy(_get_place_for_register_value("x30", 0), ®s->regs[30], sizeof(regs->regs[30])); } -void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, Callstack *callstack) -{ - callstack->elems = 0; - callstack->proc[callstack->elems++].addr = g_regs.pc; - callstack->proc[callstack->elems++].addr = g_regs.x30; - - bool end = false; - - do { - uint64_t newx29, newx30; - bool read29 = _crash_stack_libelf_read_value(dwfl, core, pid, - g_regs.x29, - &newx29, sizeof(newx29), mappings); - bool read30 = _crash_stack_libelf_read_value(dwfl, core, pid, - g_regs.x29 + sizeof(newx29), - &newx30, sizeof(newx30), mappings); - if (read29 && read30) { - callstack->proc[callstack->elems++].addr = newx30; - g_regs.x29 = newx29; - } - else end = true; - } while (!end); -} - void *_get_place_for_register_value(const char *regname, int regnum) { if (strcmp(regname, "pc") == 0 || REG_PC == regnum) -- 2.7.4 From b3c3dbff0e023132684879ad1d2c7f5727b29475 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 28 Dec 2016 10:20:32 +0900 Subject: [PATCH 13/16] Fix vulnerability Check range of signo before use it Change-Id: Icae63a7185a897ba6688b45715b208c2d92df1b7 Signed-off-by: Sunmin Lee --- src/crash-stack/crash-stack.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index 250e780..7471e86 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -454,9 +454,14 @@ static void __crash_stack_print_signal(int signo) [SIGTTIN]="SIGTTIN", [SIGTTOU]="SIGTTOU", [SIGURG]="SIGURG", [SIGXCPU]="SIGXCPU", [SIGXFSZ]="SIGXFSZ", [SIGVTALRM]="SIGVTALRM", [SIGPROF]="SIGPROF", [SIGWINCH]="SIGWINCH", [SIGIO]="SIGIO", - [SIGPWR]="SIGPWR", [SIGSYS]="SIGSYS", [SIGUNUSED]="SIGUNUSED", + [SIGPWR]="SIGPWR", [SIGSYS]="SIGSYS", /* [SIGUNUSED]="SIGUNUSED", */ }; + if (SIGHUP > signo || signo > SIGSYS) { + fprintf(errfile, "Invalid signal number: %d\n", signo); + return; + } + printf("Signal: %d\n" "\t(%s)\n", signo, -- 2.7.4 From fbe2344b1b9729a845a8701d25086eca33147336 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 28 Dec 2016 14:35:13 +0900 Subject: [PATCH 14/16] Change internal modules work - crash-pipe: create core file only - crash-stack: create .info file (call-stack) Change-Id: I71ba012f426e5d055f3acfc2b2820b5fcb2e17ec Signed-off-by: Sunmin Lee --- src/crash-manager/crash-manager.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 8c64d78..c3c2ed0 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -422,43 +422,27 @@ static void dump_system_state(void) static void execute_crash_modules(int argc, char *argv[], int debug) { - int ret, i, length; - char arg_append[PATH_MAX]; + int ret; char command[PATH_MAX]; - length = 0; - arg_append[0] = '\0'; - for (i = 1; i < argc && length + strlen(argv[i]) + 1 < PATH_MAX; i++) { - strncat(arg_append, argv[i], strlen(argv[i])); - strncat(arg_append, " ", 1); - length += strlen(argv[i]) + 1; - } - /* Execute crash-pipe */ - if (debug) - ret = snprintf(command, sizeof(command), - "%s --save-core %s --report %s > %s", - CRASH_PIPE_PATH, - crash_info.core_path, arg_append, - crash_info.info_path); - else + if (debug) { ret = snprintf(command, sizeof(command), - "%s --report %s > %s", + "%s --save-core %s", CRASH_PIPE_PATH, - arg_append, - crash_info.info_path); - if (ret < 0) { - _E("Failed to snprintf for crash-pipe command"); - return; + crash_info.core_path); + if (ret < 0) { + _E("Failed to snprintf for crash-pipe command"); + return; + } + system_command(command); } - system_command(command); #ifdef TIZEN_FEATURE_PTRACE_CALLSTACK /* Execute crash-stack */ - /* if (argc > 8) ret = snprintf(command, sizeof(command), - "%s --pid %s --tid %s --sig %s >> %s", + "%s --pid %s --tid %s --sig %s > %s", CRASH_STACK_PATH, crash_info.pid_info, crash_info.tid_info, @@ -466,7 +450,7 @@ static void execute_crash_modules(int argc, char *argv[], int debug) crash_info.info_path); else ret = snprintf(command, sizeof(command), - "%s --pid %s --sig %s >> %s", + "%s --pid %s --sig %s > %s", CRASH_STACK_PATH, crash_info.pid_info, crash_info.sig_info, @@ -476,7 +460,6 @@ static void execute_crash_modules(int argc, char *argv[], int debug) return; } system_command(command); - */ #endif /* TIZEN_FEATURE_PTRACE_CALLSTACK */ } -- 2.7.4 From 7de8af5d021577a3c00d45e8f153ef216e89f1e3 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 2 Jan 2017 13:26:55 +0900 Subject: [PATCH 15/16] Deal with Toolchain upgrade According to Tizen toolchain will be upgraded in 4.0, several build issues should be resolved. This patch deals with "Language rules stricting". Change-Id: I1993fb3b2a285c341f8b8b92ec32a428704ddc5a Signed-off-by: Sunmin Lee --- src/crash-manager/CMakeLists.txt | 2 +- src/dump_systemstate/CMakeLists.txt | 2 +- src/log_dump/CMakeLists.txt | 2 +- src/sys-assert/CMakeLists.txt | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/crash-manager/CMakeLists.txt b/src/crash-manager/CMakeLists.txt index 357fcaa..9ac26d1 100644 --- a/src/crash-manager/CMakeLists.txt +++ b/src/crash-manager/CMakeLists.txt @@ -23,7 +23,7 @@ FOREACH(flag ${crash-manager_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-deprecated-declarations") CONFIGURE_FILE(crash-manager.h.in crash-manager.h @ONLY) ADD_EXECUTABLE(${PROJECT_NAME} ${CRASH_MANAGER_SRCS}) diff --git a/src/dump_systemstate/CMakeLists.txt b/src/dump_systemstate/CMakeLists.txt index d15805b..d889526 100755 --- a/src/dump_systemstate/CMakeLists.txt +++ b/src/dump_systemstate/CMakeLists.txt @@ -16,7 +16,7 @@ ENDFOREACH(flag) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-deprecated-declarations") MESSAGE("FLAGS: ${CMAKE_C_FLAGS}") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) diff --git a/src/log_dump/CMakeLists.txt b/src/log_dump/CMakeLists.txt index 20202b6..8504860 100644 --- a/src/log_dump/CMakeLists.txt +++ b/src/log_dump/CMakeLists.txt @@ -20,7 +20,7 @@ FOREACH(flag ${log_dump_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-deprecated-declarations") CONFIGURE_FILE(log_dump.h.in log_dump.h @ONLY) ADD_EXECUTABLE(${PROJECT_NAME} ${LOG_DUMP_SRCS}) diff --git a/src/sys-assert/CMakeLists.txt b/src/sys-assert/CMakeLists.txt index e6c7ca0..11672d0 100644 --- a/src/sys-assert/CMakeLists.txt +++ b/src/sys-assert/CMakeLists.txt @@ -48,6 +48,8 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") + FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") IF("${ARCH}" STREQUAL "arm") @@ -69,4 +71,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tizen-debug-on.service DESTINATION /us INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tizen-debug-off.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) \ No newline at end of file + GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -- 2.7.4 From 4b7c85115819ea91a3415114b12b3ed009419878 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 18 Jan 2017 14:23:37 +0900 Subject: [PATCH 16/16] (Modified) Deal with Toolchain upgrade (Revert "Deal with Toolchain upgrade") This patch substitutes deprecated function "readdir_r" with "readdir" rather than ignoring warning. Change-Id: I3b4d3f9c28cc60c851f30332aa88780078471085 Signed-off-by: Sunmin Lee --- src/crash-manager/CMakeLists.txt | 2 +- src/crash-stack/crash-stack.c | 3 +-- src/dump_systemstate/CMakeLists.txt | 2 +- src/log_dump/CMakeLists.txt | 2 +- src/shared/util.c | 18 ++++-------------- src/sys-assert/CMakeLists.txt | 4 +--- src/sys-assert/sys-assert.c | 3 +-- 7 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/crash-manager/CMakeLists.txt b/src/crash-manager/CMakeLists.txt index 9ac26d1..357fcaa 100644 --- a/src/crash-manager/CMakeLists.txt +++ b/src/crash-manager/CMakeLists.txt @@ -23,7 +23,7 @@ FOREACH(flag ${crash-manager_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-deprecated-declarations") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") CONFIGURE_FILE(crash-manager.h.in crash-manager.h @ONLY) ADD_EXECUTABLE(${PROJECT_NAME} ${CRASH_MANAGER_SRCS}) diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index 7471e86..b64df73 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -687,7 +687,6 @@ static void __crash_stack_print_threads(FILE* outputfile, pid_t pid, pid_t tid) { int threadnum=1; DIR *dir; - struct dirent entry; struct dirent *dentry=NULL; char task_path[PATH_MAX]; struct stat sb; @@ -710,7 +709,7 @@ static void __crash_stack_print_threads(FILE* outputfile, pid_t pid, pid_t tid) if (!dir) { fprintf(errfile, "[crash-stack] cannot open %s\n", task_path); } else { - while (readdir_r(dir, &entry, &dentry) == 0 && dentry) { + while ((dentry = readdir(dir))) { if (strcmp(dentry->d_name, ".") == 0 || strcmp(dentry->d_name, "..") == 0) continue; diff --git a/src/dump_systemstate/CMakeLists.txt b/src/dump_systemstate/CMakeLists.txt index d889526..d15805b 100755 --- a/src/dump_systemstate/CMakeLists.txt +++ b/src/dump_systemstate/CMakeLists.txt @@ -16,7 +16,7 @@ ENDFOREACH(flag) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-deprecated-declarations") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") MESSAGE("FLAGS: ${CMAKE_C_FLAGS}") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) diff --git a/src/log_dump/CMakeLists.txt b/src/log_dump/CMakeLists.txt index 8504860..20202b6 100644 --- a/src/log_dump/CMakeLists.txt +++ b/src/log_dump/CMakeLists.txt @@ -20,7 +20,7 @@ FOREACH(flag ${log_dump_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-deprecated-declarations") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") CONFIGURE_FILE(log_dump.h.in log_dump.h @ONLY) ADD_EXECUTABLE(${PROJECT_NAME} ${LOG_DUMP_SRCS}) diff --git a/src/shared/util.c b/src/shared/util.c index 01445fd..b124572 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -292,7 +292,6 @@ int run_command_write_fd(char *cmd, int dfd) static int remove_dir_internal(int fd) { DIR *dir; - struct dirent e; struct dirent *de; int subfd, ret = 0; @@ -300,7 +299,7 @@ static int remove_dir_internal(int fd) if (!dir) return -1; - while ((ret = readdir_r(dir, &e, &de)) == 0 && de) { + while ((de = readdir(dir))) { if (de->d_type == DT_DIR) { if (!strncmp(de->d_name, ".", 2) || !strncmp(de->d_name, "..", 3)) continue; @@ -354,7 +353,6 @@ int remove_dir(const char *path, int del_dir) int get_exec_pid(const char *execpath) { DIR *dp; - struct dirent entry; struct dirent *dentry; int pid = -1, fd; int ret; @@ -369,10 +367,8 @@ int get_exec_pid(const char *execpath) } len = strlen(execpath) + 1; - if ((readdir_r(dp, &entry, &dentry)) != 0) - dentry = NULL; - while (dentry != NULL) { + while ((dentry = readdir(dp))) { if (!isdigit(dentry->d_name[0])) continue; @@ -404,7 +400,6 @@ int get_exec_pid(const char *execpath) int get_file_count(char *path) { DIR *dir; - struct dirent p; struct dirent *dp; int count = 0; @@ -412,10 +407,7 @@ int get_file_count(char *path) if (!dir) return 0; - if ((readdir_r(dir, &p, &dp)) != 0) - dp = NULL; - - while (dp != NULL) { + while ((dp = readdir(dir))) { const char *name = dp->d_name; /* always skip "." and ".." */ if (name[0] == '.') { @@ -433,12 +425,10 @@ int get_file_count(char *path) int get_directory_usage(char *path) { DIR *dir; - struct dirent e; struct dirent *de; struct stat st; size_t usage = 0; int fd = -1; - int ret; fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME); if (fd < 0) @@ -449,7 +439,7 @@ int get_directory_usage(char *path) return -1; } - while ((ret = readdir_r(dir, &e, &de)) == 0 && de) { + while ((de = readdir(dir))) { if (!strncmp(de->d_name, ".", 2) || !strncmp(de->d_name, "..", 3)) continue; if (fstatat(fd, de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0) { diff --git a/src/sys-assert/CMakeLists.txt b/src/sys-assert/CMakeLists.txt index 11672d0..e6c7ca0 100644 --- a/src/sys-assert/CMakeLists.txt +++ b/src/sys-assert/CMakeLists.txt @@ -48,8 +48,6 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") - FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") IF("${ARCH}" STREQUAL "arm") @@ -71,4 +69,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tizen-debug-on.service DESTINATION /us INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tizen-debug-off.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) \ No newline at end of file diff --git a/src/sys-assert/sys-assert.c b/src/sys-assert/sys-assert.c index 0c1bbf2..212e966 100644 --- a/src/sys-assert/sys-assert.c +++ b/src/sys-assert/sys-assert.c @@ -595,7 +595,6 @@ void sighandler(int signum, siginfo_t *info, void *context) pid_t pid; pid_t tid; DIR *dir; - struct dirent entry; struct dirent *dentry=NULL; char timestr[TIME_MAX_LEN]; char processname[NAME_MAX] = {0,}; @@ -773,7 +772,7 @@ void sighandler(int signum, siginfo_t *info, void *context) if (!dir) { fprintf(stderr, "[sys-assert]can't open %s\n", TASK_PATH); } else { - while (readdir_r(dir, &entry, &dentry) == 0 && dentry) { + while ((dentry = readdir(dir))) { if (strcmp(dentry->d_name, ".") == 0 || strcmp(dentry->d_name, "..") == 0) continue; -- 2.7.4