Karol Lewandowski [Wed, 3 Oct 2018 09:29:30 +0000 (11:29 +0200)]
Fix: Do not index buffer[] with negative index in case of read failure
Issue reported by Coverity.
Change-Id: Ie9cd66d2801770a096bb1849d11c860533508174
Karol Lewandowski [Wed, 3 Oct 2018 09:27:57 +0000 (11:27 +0200)]
util: Remove unused file_exist()
Change-Id: I1e20fc6cd55c9685db304a9aa40b58af56df0c00
Karol Lewandowski [Tue, 25 Sep 2018 11:38:58 +0000 (13:38 +0200)]
util: Allow functions to be called from c++
Change-Id: If4dc6b6e494096713e76a1345ab3753a6914e1c2
Karol Lewandowski [Wed, 3 Oct 2018 09:15:31 +0000 (11:15 +0200)]
util: Add nullvec2str
This function will be used to convert char *arr[] arrays
(like argv[] and envp[]) arrays to simple strings.
Change-Id: I352f2cc35ee5f06f6a9e6bc81b45702ea11f711d
Karol Lewandowski [Tue, 25 Sep 2018 11:13:32 +0000 (13:13 +0200)]
util: Remove unused cat_file()
Change-Id: Ie56ce502a4a1d6ca27574bf7f05b0f097079eaa2
Karol Lewandowski [Thu, 20 Sep 2018 09:55:38 +0000 (11:55 +0200)]
util: Dead code removal
Change-Id: I42bd0466c365c84b0720291504e10d86cb9859fe
Karol Lewandowski [Fri, 14 Sep 2018 21:42:34 +0000 (23:42 +0200)]
crash-manager: Use same constant for minicoredumper, crash-stack and zip command timeouts
Change-Id: I50d41e850d32cf40ee403f93020db67700002d3c
Mateusz Moscicki [Fri, 14 Sep 2018 14:04:41 +0000 (16:04 +0200)]
Release 5.0.5
Changes from last version:
- Code improvements
- Fixed SVACE and Coverity warnings
- Run zip and crash-stack commands with timeout
Change-Id: I84784e44c9baef654159ab55cb70aeaeaa150b42
Mateusz Moscicki [Wed, 12 Sep 2018 10:36:37 +0000 (12:36 +0200)]
Fix Coverity warnings: #1020601 #1020599 #1020595 #1020587
Change-Id: I6cd513db97ad4f67f259f11e088be3e68c8dc319
Mateusz Moscicki [Mon, 10 Sep 2018 13:41:20 +0000 (15:41 +0200)]
Fix after security review
* File: src/shared/util.c
Function: write_fd
Write in function may return EINTR correctly. Function does not
support this case correctly. If the interrupt occurs program will not
dump all data to file. The interrupt may come from child process
(SIGCHILD).
* File: src/shared/util.c
Function: fprintf_fd
You may replace fprintf_fd with standard library function dprintf.
* File: src/shared/util.c
Functions: dump_file_write_fd, copy_file, cat_file
Functions don’t support EINTR correctly (write in function write_fd
may be interrupt). In this functions it is not clear who will generate
signal to interrupt write call, so this is not security risk now. You
may replace loop with standard library function sendfile.
* File: crash-manager.c
Function: launch_crash_popup
Memory leak: value conn was allocated but was not deallocated.
* File: crash-manager.c
Function: prepare_paths
Invalid strings are stored in crash_crash_path and crash_temp_path.
Both strings are truncated by 1 byte.
Change-Id: Ie174b5ee043321861912f1b9233f0f6a6afd027e
Mateusz Moscicki [Wed, 5 Sep 2018 08:42:58 +0000 (10:42 +0200)]
Use dynamic allocated memory instead of fixed-size arrays
Change-Id: I03e91bf530204de6f03f1db79e2aa9bdd2608f95
Mateusz Moscicki [Fri, 31 Aug 2018 13:40:54 +0000 (15:40 +0200)]
Add timeout to the zip command
Change-Id: I52db6f8ccd1a2103da030c10898ec33c4a9bcc57
Mateusz Moscicki [Fri, 31 Aug 2018 12:04:49 +0000 (14:04 +0200)]
Add timeout to run the crash-stack
In case the crash-stack hangs, the crash-manager will still be able to
create a raport.
Change-Id: I62b3022dc1aec6507821473619c73cf90337643f
Mateusz Moscicki [Fri, 31 Aug 2018 10:44:13 +0000 (12:44 +0200)]
Merge move_dump_dir() and move_info_file()
Change-Id: I246bf743eefb199577bd00d6b3fd0defa6948eff
Mateusz Moscicki [Fri, 31 Aug 2018 10:07:56 +0000 (12:07 +0200)]
Stop using crash_info struct as a global variable
Change-Id: I1dee72cb7abf29e7ff2bf5bdc4e0852bda1329b1
Mateusz Moscicki [Thu, 30 Aug 2018 11:38:39 +0000 (13:38 +0200)]
Use parsed command line arguments instead of raw string values
Change-Id: I28c9479c2d6cb5d754e7ff3ee37f8cab34235456
Karol Lewandowski [Wed, 29 Aug 2018 13:39:10 +0000 (13:39 +0000)]
Merge "Release 5.0.4" into tizen
Mateusz Moscicki [Wed, 29 Aug 2018 11:06:11 +0000 (13:06 +0200)]
Release 5.0.4
Changes from last version:
- crash-stack use the same function to read /proc/<pid>/exe symlink as
the crash-manager
- crash-manager: Simplify dump_core error reporting
Change-Id: Id5d65baedcfe73c88e7aadee2cc7aef62c91269c
Mateusz Mo?cicki [Wed, 29 Aug 2018 13:38:28 +0000 (13:38 +0000)]
Merge "crash-manager: Simplify dump_core error reporting" into tizen
Mateusz Moscicki [Tue, 28 Aug 2018 13:27:30 +0000 (15:27 +0200)]
Move the function to read /proc/<pid>/exe symlink to util.c
Change-Id: Ieb533fb66dd3d06eb5bbc827aa016a308cf892a3
Karol Lewandowski [Wed, 29 Aug 2018 08:36:21 +0000 (10:36 +0200)]
crash-manager: Simplify dump_core error reporting
Change-Id: If8ff95811e4e5f16cb3a7a2e48dfe34a0bd3b1cb
Mateusz Moscicki [Tue, 28 Aug 2018 12:22:37 +0000 (14:22 +0200)]
Release 5.0.3
This version contains fixes of SVACE warnings
Change-Id: Id51181c8bf839922b83d0d85d3596a414d005ee5
Mateusz Moscicki [Tue, 28 Aug 2018 10:35:24 +0000 (12:35 +0200)]
Fix SVACE warnings
Warnings:
352484, 352485, 352486, 352488, 352489, 352490, 352491, 352492, 352493,
352494, 352495, 352496, 352497, 352498, 352501, 352502, 352487, 358117,
358162
Change-Id: I205ddaee97836c3146b25bbb380e11464713cb25
Mateusz Moscicki [Thu, 23 Aug 2018 11:54:30 +0000 (13:54 +0200)]
Release 5.0.2
Changes from last version:
- For INFO report type D-Bus signal has a proper report path
- Update license (imported tbstack code is BSD-licensed)
- Move finding TID to crash-manager - fixes support on older kernels
Change-Id: Ie7e038d4740fcd442e5c599c9d22c91a24c2ce74
Mateusz Moscicki [Thu, 23 Aug 2018 11:51:11 +0000 (13:51 +0200)]
Update license information in spec file
Change-Id: Iee77a2f8580167eb6e7087465fd820f0fae575a1
Mateusz Moscicki [Thu, 23 Aug 2018 10:45:51 +0000 (12:45 +0200)]
Fix report path for INFO report type
Change-Id: I973c452cd08a4ac18d4ad7460b21ceb28d9d6364
Mateusz Moscicki [Tue, 14 Aug 2018 13:42:02 +0000 (15:42 +0200)]
Move finding TID to crash-manager
Additionally find_crash_tid() returns PID for single-threaded applications,
instead of -1.
Change-Id: Id6fcc652b95bddda954f25cd448f1e090918c231
Karol Lewandowski [Wed, 22 Aug 2018 05:43:14 +0000 (07:43 +0200)]
Release 5.0.1
Major version bump due to versioning scheme change. Major versions
will now follow major Tizen releases (eg. crash-worker 5 for Tizen 5).
New features:
- callstack resolver has been rewritten to not use ptrace
This was required to avoid races during resolve process (kernel
would wake up ptraced process).
Consequently, it's now possible to prepare crash report of VIP
process (whose failure causes system to be rebooted).
- New-style D-Bus signal ProcessCrashed is now emitted to notify
about the crash
- .info-only report type now can be selected via configuration
option ReportType
- Crash dump location can be changed by CrashReportPath config
option
- Saving core dump (for FULL/.zip reports) can be changed by
DumpCore option
Change-Id: I91e806d0d516e618802aee7a742120c0281034a1
Karol Lewandowski [Wed, 22 Aug 2018 10:30:45 +0000 (12:30 +0200)]
Normalize minicoredumper config variable naming
Change-Id: I5669d0d46fc15c8193b5e8ea11d1254838a8dfd1
Karol Lewandowski [Wed, 22 Aug 2018 10:28:48 +0000 (12:28 +0200)]
Move crash-manager.conf to /etc
This commit brings back config to /etc to avoid problems
with config not being available for crashes happening
during bootup (when /opt/ is not mounted yet)
Change-Id: Ib384f1fd28192dd199565d888c59f0a33d4d578d
Karol Lewandowski [Wed, 22 Aug 2018 07:02:41 +0000 (09:02 +0200)]
Fail early if can not run minicoredumper properly
Minicoredumper is essential for gathering report, so
it does not make much sense to continue when we can't
even pass right parameters (prstatus).
Change-Id: Id7560452110871190f243f7ff61f4e849351a8af
Karol Lewandowski [Wed, 22 Aug 2018 06:50:42 +0000 (08:50 +0200)]
Remove unsupported and misleading configuration options
- Remove TIZEN_FEATURE_PTRACE_CALLSTACK option
Crash report generation method has been reworked
and does not depend on ptrace anymore.
- Remove TIZEN_ENABLE_MINICOREDUMPER option
Minicoredumper is required to dump PRSTATUS, which
is later used by crash-manager (for D-Bus signal)
and by crash-stack (for callstack unwinding)
- Remove TIZEN_ENABLE_COREDUMP option
crash-pipe does not dump PRSTATUS so can not be
used as an option (see above).
Consequently, enabling/disabling coredumps has been
moved to configuration file (DumpCore=0/1).
Change-Id: If535acfe7e64fdde0a8b50afd8b3a1f44fda2490
Karol Lewandowski [Wed, 22 Aug 2018 10:53:19 +0000 (10:53 +0000)]
Merge changes I5ecf4873,I049952ab into tizen
* changes:
log_dump: dbus: Only root can own org.tizen.system.crash name
log_dump: Rework service file
Mateusz Moscicki [Fri, 20 Jul 2018 09:00:49 +0000 (11:00 +0200)]
Add report types
Depending on report type we save all zip archive with coredump, logs,
so_info and info file, or just only the *.info file. Report type can be set in
crash-manager.conf:
[CrashManager]
...
ReportType=INFO
...
Available report types:
* INFO - Save *.info file
* FULL - Save coredump, *.log, *.so_info and *info file as a ZIP archive (default)
Change-Id: I486049ac8eb928ebdc6ac513bdeac3c98aa4adcc
Mateusz Moscicki [Fri, 20 Jul 2018 10:58:22 +0000 (12:58 +0200)]
Split execute_crash_modules
Change-Id: Iae6af748786c68dcb45a50dc37275fe12e40d85d
Mateusz Moscicki [Thu, 19 Jul 2018 07:42:54 +0000 (09:42 +0200)]
Add ability to set report path in crash-manager.conf
To change default report path (/opt/usr/crash/dump/) modify the value in
crash-manager.conf:
[CrashManager]
...
CrashRootPath=/var/crash
...
Change-Id: I39b9bc178e989a1aad5727f5becdee74b1e1b13b
Mateusz Moscicki [Thu, 2 Aug 2018 09:16:56 +0000 (11:16 +0200)]
Add DBus signal emitting after report save
Interface: "org.tizen.system.crash.Crash"
Path: "/org/Tizen/System/Crash/Crash"
Signal: "ProcessCrashed"
Message (signature "sssssiia{sv}"), contains:
* process name
* exe path
* appid
* pkgid
* report path
* PID
* TID
* dictionary a{sv} contains registers values depends on the architecture:
* for x86:
* x86.eip
* for x86_64:
* x86_64.rip
* for armv7l:
* arm.pc
* arm.lr
* for aarch64:
* aarch64.pc
* aarch64.lr
Change-Id: I081a3f4982e2f0d4b01fd665b4dffcd3bab847f4
Mateusz Moscicki [Fri, 10 Aug 2018 08:41:39 +0000 (10:41 +0200)]
Save full cmd_line
Change-Id: I98ac10c8931a0e1c0b586c6e116279faa6ef9d44
Łukasz Stelmach [Mon, 6 Aug 2018 12:09:34 +0000 (14:09 +0200)]
log: Enable logging messages to a FILE* instead of dlog
For development purposes it is possible to write log messages to a FILE*
instead of dlog. To do it add the line below before including log.h.
#define LOG_FILE stderr
You may to choose any other FILE* than stderr but you need to make sure
it is available.
Change-Id: I500fd774b95d84b78c8bc46d4274ac1f94947f9c
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Łukasz Stelmach [Tue, 7 Aug 2018 13:51:52 +0000 (15:51 +0200)]
crash-stack: Use dlog-based macros for logging messages
Change-Id: I16bbfd1f6437b106e187633ddd00e65bbe74738f
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Łukasz Stelmach [Tue, 7 Aug 2018 13:54:30 +0000 (15:54 +0200)]
Integrate code from tbstack
Change-Id: I4f9b523b277fb464e60deaccba316ed94c750df9
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Łukasz Stelmach [Tue, 7 Aug 2018 11:46:13 +0000 (13:46 +0200)]
Support x86
Change-Id: I6cb87b61072be11341e6956357b05af63a620646
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Mateusz Moscicki [Tue, 7 Aug 2018 10:00:17 +0000 (12:00 +0200)]
Support Aarch64
Change-Id: Iad3979f7e5c73da9a35619c5a8a89f8a5257a780
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Łukasz Stelmach [Mon, 30 Jul 2018 12:12:42 +0000 (14:12 +0200)]
Support arm
Change-Id: I406030ffac77791b4cceb633d00c6adc60b72357
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Łukasz Stelmach [Fri, 27 Jul 2018 11:46:56 +0000 (13:46 +0200)]
crash-stack: import tbstack sources
Import files from tbstack project (commit
06b996baf444450dea117296f3b04fe5ba753222)
The code allows access to a crashed process via process_vm_readv()
(or reading /porc/PID/mem) instead of ptrace(2), which is not permited
for crashed processes.
Change-Id: I202454d03bdf5da6c419c921db839a0647c0ec2c
Origin: https://github.com/tbricks/tbstack/commit/
06b996baf444450dea117296f3b04fe5ba753222
Origin: https://github.com/tbricks/tbstack/pull/31/commits/
d0c7acfaa269e9183c41d120073aadca68b6f79d
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
[ Changed Origin & Commit after code has been merged to upstream repository
Commit:
d0c7acfaa269e9183c41d120073aadca68b6f79d ->
06b996baf444450dea117296f3b04fe5ba753222
Origin: ihttps://github.com/tbricks/tbstack/pull/31/commits/
d0c7acfaa269e9183c41d120073aadca68b6f79d -> https://github.com/tbricks/tbstack/commit/
06b996baf444450dea117296f3b04fe5ba753222 ]
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
Karol Lewandowski [Thu, 9 Aug 2018 07:05:56 +0000 (09:05 +0200)]
log_dump: dbus: Only root can own org.tizen.system.crash name
Change-Id: I5ecf48736cd0f0e4786075b766fc697d1a1e399a
Karol Lewandowski [Thu, 9 Aug 2018 06:58:38 +0000 (08:58 +0200)]
log_dump: Rework service file
This commit adjusts log_dump systemd service to
provide normal dbus-type unit.
Additionally, unused and erroneous "ENGINEER_MODE"
is removed.
Change-Id: I049952ab19d1e6a0b8ee8319cedb83226037814f
Karol Lewandowski [Tue, 31 Jul 2018 11:07:20 +0000 (13:07 +0200)]
Release 1.2.1
Bugfix release, includes:
* Fix off-by-one error in generating the so_info file
Change-Id: I4630757714e45db085980f2e002613df5375d9af
Mateusz Moscicki [Wed, 25 Jul 2018 07:18:00 +0000 (09:18 +0200)]
Fix off-by-one error in generating the so_info file
Change-Id: I65dba1b2be1237578df5679586f1449d4fa94023
Karol Lewandowski [Fri, 20 Jul 2018 10:01:28 +0000 (12:01 +0200)]
Release 1.2
This release brings following features:
* rewritten rpm interface - from using rpm command to direct librpm
usage - this offers considerable speed improvement
* waiting for /opt (or generally CRASH_ROOT_PATH) to appear -
useful for crashes occuring early during bootup
Minor fixes/debugging enchancements are provided.
Change-Id: Idb193bebc56c5f8d86fa360de1787cadb6a75583
Mateusz Moscicki [Tue, 17 Jul 2018 11:57:41 +0000 (13:57 +0200)]
Log message to dlog when wait_for_child returns non-zero value
Change-Id: Ib2b3df0939a13a553b05cc747e5b17a4e5fe580d
Mateusz Moscicki [Tue, 17 Jul 2018 11:43:39 +0000 (13:43 +0200)]
Add own implementation of getting rpm packages info
Calling the external rpm command is too slow, especially for binaries
with many shared object dependencies.
Change-Id: I48a86c0a0067bb2d37b7b7a12abae5d611c8b572
Mateusz Moscicki [Tue, 17 Jul 2018 08:30:31 +0000 (10:30 +0200)]
Copy /proc/<pid>/maps file to temporary directory
To save as much time as possible, we can parse maps file when coredump
is already saved and process is probably cleaned up.
Change-Id: I136d1c462fe2fe9c204deea09b1d0269cee32530
Mateusz Moscicki [Thu, 14 Jun 2018 11:18:22 +0000 (13:18 +0200)]
Add checking if CRASH_ROOT_PATH exists
When system booting, /opt may not be mounted yet. In this case if any
program will crash, the crash-manager will wait about 60 seconds for
/opt. After this time the the crash report will be lost.
Change-Id: I97e9541262d1a0f9844aa260ac23972f70e27638
Mateusz Moscicki [Mon, 2 Jul 2018 07:02:31 +0000 (09:02 +0200)]
Return exit code of the program invoked by run_command_write_fd_timeout()
Change-Id: Ib7f046aed8ca352463d6ba7559f947e487ad85b8
Mateusz Moscicki [Fri, 29 Jun 2018 11:31:38 +0000 (13:31 +0200)]
Fix reading /proc/<pid>/maps file
Macro is expanded by preprocessor, but sizeof() is evaluated at compile time.
Change-Id: I4ca20ff703cf89fba2137ec3eb24550d1013fdff
Karol Lewandowski [Mon, 18 Jun 2018 14:44:01 +0000 (16:44 +0200)]
packaging: Fix minicoredumper path
Change-Id: I5a57f9a3c0272ebed534aee7edd88d2c2f362b89
Karol Lewandowski [Mon, 18 Jun 2018 13:06:06 +0000 (15:06 +0200)]
Release crash-worker with minicoredumper
Change-Id: Ie72ab3379f50174e1c76c79da5af56cb8aaed5ad
Mateusz Moscicki [Thu, 22 Feb 2018 09:45:37 +0000 (10:45 +0100)]
crash-manager: add minicoredumper
minicoredumper strips unnecessary data from coredump
and makes use of sparse file mechanism, to quickly save
core files on disc.
Change-Id: Ic8e968b5e7a011f9a06794876c372063e968a354
Mateusz Moscicki [Tue, 20 Mar 2018 07:43:10 +0000 (08:43 +0100)]
Add *.so_info file to the report
*.so_info file contains paths, rpm package info (name, version, release,
architecture) and build IDs of mapped files that have a execute flag in
/proc/<pid>/maps.
Change-Id: I087a8d25efeb1f51a5e25d95cce5c60a8f2a607b
Karol Lewandowski [Fri, 15 Jun 2018 13:51:28 +0000 (13:51 +0000)]
Merge "Add timeout to run_command_write_fd and replace popen by execvpe" into tizen
Mateusz Moscicki [Thu, 14 Jun 2018 10:37:56 +0000 (12:37 +0200)]
Fix stack-buffer-overflow error
Lenghts in sscanf format string refer to actually read bytes, without
including space for null byte, E.g.:
...
char buff[5+1];
sscanf(other_buff, "%5s", buff);
...
Change-Id: I203e1bc04ba1e352029849e5bd29a7a6ca8a5763
Sunmin Lee [Mon, 18 Sep 2017 04:27:50 +0000 (13:27 +0900)]
Fix vulnerabilities
Change-Id: Ia7d8565ef86cfef9d8b61e2e11020b6f1b49ed1d
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Mateusz Moscicki [Wed, 16 May 2018 06:23:00 +0000 (08:23 +0200)]
Add timeout to run_command_write_fd and replace popen by execvpe
dump_systemstate runs many external commands. When one hungs,
dump_systemstate will block the crash-worker.
execvpe replaced popen because popen passes command to /bin/sh, and this
can potentially allow to run the malicious command if attacker can
modify the fragment of cmd, e.g:
void read_file(char *filename)
{
...
sprintf(buff, "cat %s", filename);
popen(buff, "r");
...
}
main()
{
char filename[] = "/etc/passwd;rm -rf /";
read_file(filename);
}
Change-Id: Id7b37c058869c27d3c4d282d9d2dd30d5b9ec80c
Mateusz Moscicki [Wed, 30 May 2018 11:33:20 +0000 (13:33 +0200)]
crash-pipe: Fix write the coredump to the file
splice returns EINVAL if (loff_t)(len + out.pos) is negative number.
This was the case on aarch64 and x86_64.
Change-Id: Ic52d08efce3fca555a83319c8161c3656b553cc1
Mateusz Moscicki [Wed, 30 May 2018 11:31:21 +0000 (13:31 +0200)]
Revert "crash-pipe: Fix write the coredump to the file"
This reverts commit
70c1372b5a85a64d5ea7c5bb20b99429213942be.
Change-Id: I553b4c6ef2e5aa9cdc80e4d58ecd318dc0a2d532
Mateusz Moscicki [Fri, 20 Apr 2018 06:35:39 +0000 (08:35 +0200)]
Stop setting the PR_SET_DUMPABLE flag for crash-manager processes
prctl(PR_SET_DUMPABLE, 0) is not neccessary. Kernel runs the
crash-manager and sets RLIMIT_CORE to 1 for the process. This is special
value that prevents from running crash-manager recursively.
Change-Id: I33df7c28c6ce939f2903d02af673734d473b649e
Karol Lewandowski [Tue, 29 May 2018 08:09:53 +0000 (08:09 +0000)]
Merge "crash-pipe: Fix write the coredump to the file" into tizen
Mateusz Moscicki [Mon, 28 May 2018 10:46:32 +0000 (12:46 +0200)]
crash-pipe: Fix write the coredump to the file
splice len parameter is size_t type. On some architectures (eg. aarch64)
splice returned EINVAL when the parameter len was ssize_t variable and
was equal SSIZE_MAX
Change-Id: Id84038662dcd2969a33af1e276a3b4500a780f29
Mateusz Moscicki [Fri, 11 May 2018 13:34:42 +0000 (15:34 +0200)]
Set the default DBus policy for send and own to deny
Change-Id: I49230b5c711cf7c4158f6de2fb448638035d750b
Sunmin Lee [Thu, 28 Sep 2017 10:05:07 +0000 (19:05 +0900)]
Fix potentially undefined behavior
The documentation does not describe the behavior of the access()
function for a NULL path argument, which can be returned by mkdtemp()
Change-Id: I9c5c08eb424f5e9bdab248682b00e9cb895c7afa
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
[ Cherry-picked from tizen_4.0 branch, extended commit message ]
Signed-off-by: Mateusz Moscicki <m.moscicki2@partner.samsung.com>
Mateusz Moscicki [Mon, 26 Feb 2018 12:22:47 +0000 (13:22 +0100)]
crash-manager: don't store in zip archive files referred by symlinks
minicoredump (will be introduced in next commit) has an option to save
/proc/<pid>/ files in report. As /proc/<pid>/fd/* contains symlinks, the
created archive will contain the contents of these fds. This is
undesirable as files might be quite big and contain private (sensitive)
data.
This commit adds -y option to zip, which will allow storing symlinks to
actual files instead of their contents (as it was available originally
under /proc/<pid>/)"
Change-Id: I0a7c9211eab1acd39da7db3930e967ddab5eceef
Mateusz Moscicki [Thu, 22 Feb 2018 09:40:41 +0000 (10:40 +0100)]
crash-manager: fix get cmd_path
This commit fixes issue with report not being generated for processes
started using a relative path (e.g.: ./test-app).
In above case cmdline contained only './test-app' string and based on
that it was impossible to determine the full path to a binary.
Consequently, crash-manager assumed crashed program binary did not
exist and did not generate the report.
This commit changes the logic as follows:
cinfo->cmd_name is read from /proc/<pid>/cmdline
cinfo->cmd_path is read from /proc/<pid>/exe
Change-Id: If1b7557b53417d2703a81644939692fee5c801ee
Mateusz Moscicki [Mon, 26 Feb 2018 07:17:53 +0000 (08:17 +0100)]
Fixed code style
Code has been changed to avoid messages:
(CODE_SMELL/Warning) Remove this unused "ret" local variable.
(CODE_SMELL/Warning) Remove this unused "command" local variable.
In addition, the code has been modified to remove unnecessary bracket.
Change-Id: I5bf9820d16f7b7947844e078eba9a1bab11ddd6c
Mateusz Moscicki [Wed, 14 Feb 2018 07:17:02 +0000 (08:17 +0100)]
crash-stack: fixed copying data from bufferfile to outputfile
Reading the last chunk of data sets the feof indicator.
Change-Id: I396a3d6e1c398c7201ef8bc7dfa1ec9c1b7ddb8a
Michal Bloch [Thu, 28 Sep 2017 14:38:52 +0000 (16:38 +0200)]
Improve error handling
* handle reallocation failures in scan dump.
* generate a log if unlinking a failed dump file also fails
* fix a memory leak when passing duplicate `--save-core` parameter to crash-pipe; generate a log in that case
* explicitly free a resource on exit
Change-Id: I71b22b3375c6c9ab9a43dab41e80eadc3fa599f6
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
Karol Lewandowski [Thu, 28 Sep 2017 14:59:53 +0000 (14:59 +0000)]
Merge "svace fixes: insufficient error handling" into tizen
Karol Lewandowski [Tue, 26 Sep 2017 11:29:32 +0000 (13:29 +0200)]
svace fixes: insufficient error handling
This commit brings fixes for folowing SVACE-reported issues:
* UNCHECKED_FUNC_RES.FREAD: Return value of fread function was compared to zero at crash-stack.c:836, but ferror/feof wasn't called.
Result was compared with zero at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:836
* HANDLE_LEAK: The handle 'fd' was created at crash-manager.c:508 by calling function 'open' and lost at crash-manager.c:515.
[acquire] Call of open at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-manager/crash-manager.c:508
[leaked] leaked at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-manager/crash-manager.c:515
* DEREF_OF_NULL.CONST: Pointer '&tail->next', which was assigned NULL value at crash-stack.c:642, is dereferenced at crash-stack.c:692.
[dereference] Variable '&tail->next' is dereferenced at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:692
[null] Assign null at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:642
* RACE.NO_UMASK: Function 'umask(077)' needs to be called before 'mkstemp' at crash-stack.c:964, to prevent a potential race condition vulnerability.
function call at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:964
Change-Id: Ief6dd93ec8d795fccffbc2d823a6af8fcf63c965
Kichan Kwon [Thu, 28 Sep 2017 01:46:21 +0000 (10:46 +0900)]
dump_systemstate : add journal log
- Log only latest 1024 logs from last boot
Change-Id: I535402a6807d2c4a21fb08a2ba874473f49045f6
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
Sunmin Lee [Wed, 13 Sep 2017 05:36:18 +0000 (14:36 +0900)]
Fix bugs
- Fix misspelling for m4 condition
- Do not install unused services: tizen-debug-on/off
Change-Id: I09296e1365407c93ebb6dd9897ccc5b9e346bddd
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Sunmin Lee [Tue, 12 Sep 2017 07:28:52 +0000 (16:28 +0900)]
Remove unused file
Remove unused file
Change-Id: Iabe9ee9e49cf9f4272c3a3691f48f3c75ff0a281
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
ByungSoo Kim [Mon, 21 Aug 2017 14:24:00 +0000 (23:24 +0900)]
log_dump: assign CAP_SYS_PTRACE capability
When log_dump has system_fw permission,
memps which is forked from /usr/bin/dump_systemstate can't read
/proc/self/maps and /proc/self/smaps.
It requires CAP_SYS_PTRACE capability.
So, it should have CAP_SYS_PTRACE capability and inheritance attribute.
Change-Id: If2bd16964dba8e616e4a4fcc5cd489feb4c40b21
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
minsoo kim [Mon, 21 Aug 2017 05:49:32 +0000 (14:49 +0900)]
crash-worker: add dump_systemstate memps
Change-Id: I50fbdc296a0ab8dfab96cfde29b0c3afa94eb1e7
Signed-off-by: minsoo kim <ms203.kim@samsung.com>
minsoo kim [Mon, 3 Jul 2017 05:04:22 +0000 (14:04 +0900)]
crash-worker: add supplementarygroups log systemd-journal
To gather dlog, journal log, add supplementarygroups to service
But dbus activation not applied suppplementarygroup,
So rearrange service role
org.tizen.system.crash.service : dbus activation
log_dump.service : log_dump daemon
Change-Id: I93e2bb5142a83f6dfa9ad56197916855988501ee
Signed-off-by: minsoo kim <ms203.kim@samsung.com>
minsoo kim [Wed, 10 May 2017 02:09:09 +0000 (11:09 +0900)]
crash-worker: change permission to none root process
for reduce root permission, change to system_fw
Change-Id: I04fafa89d2a4e0a1e3bc5a6e0019b2aebb428235
Signed-off-by: minsoo kim <ms203.kim@samsung.com>
Sunmin Lee [Wed, 9 Aug 2017 10:38:41 +0000 (19:38 +0900)]
Apply ASLR to executables: crash-pipe, crash-stack
Change-Id: Ia4a0452832a705f6fbac8034d7da93297883e4bc
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Karol Lewandowski [Tue, 23 May 2017 13:01:36 +0000 (15:01 +0200)]
packaging: Disable sys-assert
Ptrace-based mechanism (crash-stack) should be used as default
and only mechanism for crash-report generation.
Change-Id: I102fc02e5538dcf9f21d7b72ff8892e1b3500265
Kunhoon Baik [Tue, 27 Jun 2017 07:07:40 +0000 (16:07 +0900)]
Preparation of debug & release package
Some vendor would like to have different crash management policy for debug and release image.
Thus, Tizen will provide crash-manager debug and release package.
This patch is the preparation for the package separation.
In case of crash-manager debug, following CFLAGS will be enabled.
export CFLAGS+=" -DTIZEN_ENGINEER_MODE"
export CFLAGS+=" -DTIZEN_ENABLE_COREDUMP"
In the future, export CFLAGS+=" -DTIZEN_DEBUG_ENABLE" may be added.
Basically, default Tizen image will include crash management policy for debug mode.
cf) .debugmode file will be used for just crash-popup control for 3.0 compatibility.
Change-Id: I892d1f0d5de65da0abb3e002fa235989f43def56
minsoo kim [Fri, 26 May 2017 09:58:35 +0000 (18:58 +0900)]
log_dump: selective mode for dbus activation
log_dump running root in debug mode, and none_root with normal mode.
Simplify org.tizen.system.crash.service conditional compile by using m4
Change-Id: I04b734f722266264434b27e9fe7b17cdc73263f1
Signed-off-by: minsoo kim <ms203.kim@samsung.com>
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Sunmin Lee [Fri, 9 Jun 2017 03:58:48 +0000 (12:58 +0900)]
Adjust buffer size for address
The addr gets string of address consisting of begin/end
address and '-', null character.
So the length of addrees buffer should be set to:
ADDR_LEN * 2 + 2 (at least)
Change-Id: I6cdb8530be50c4c29fbb51a5dcb5fa8e094e5352
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Sunmin Lee [Thu, 8 Jun 2017 05:05:57 +0000 (14:05 +0900)]
Fix sscanf vulnerability
Specify a limit on the input string length
and keep the last byte for null character.
Change-Id: I717ac2ae565f2627e5de26426ec24c6ccf772c5e
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Karol Lewandowski [Tue, 16 May 2017 13:25:06 +0000 (15:25 +0200)]
crash-stack: Fix Tizen Coding Style violations
Rules at: https://wiki.tizen.org/wiki/Native_Platform_Coding_Idiom_and_Style_Guide
This commit brings no functional changes.
Change-Id: Ic95fd2d1e5508d602fa24ea33933448c52ce625d
Karol Lewandowski [Thu, 11 May 2017 13:47:18 +0000 (15:47 +0200)]
crash-stack: Change "ThreadID" heuristic to work on aarch64
Commit
82e3caa86 ("crash-stack: Find crashed tid by wchan")
introduced heuristic method of finding correct thread id, if
it was not passed by the kernel as parameter to crash-manager.
This commit modifies this heuristic to also consider "pipe_wait"
function in kernel to signify crashed thread. This is what was
observed to be true on aarch64.
Change-Id: Iefa6d028f459ff9491f8e184433f913f39a096eb
Karol Lewandowski [Fri, 5 May 2017 13:03:20 +0000 (15:03 +0200)]
crash-worker: Generate core only if /opt/etc/.debugmode file is present
Additionally, this patch moves actual path definition to one place.
Change-Id: I984ac2c67d8a22ed749f2b1945a1cef237b88ace
Karol Lewandowski [Tue, 25 Apr 2017 06:48:19 +0000 (06:48 +0000)]
Merge "Removing dependency of tizen-debug-on/off service from sys-assert" into tizen
Karol Lewandowski [Mon, 24 Apr 2017 15:34:18 +0000 (17:34 +0200)]
Removing dependency of tizen-debug-on/off service from sys-assert
Tizen-debug-on/off service should control enabling/disabling coredump generation.
When Tizen-debug-off service is executed, only callstack should be generated.
Thus, although disabling sys-assert, the services should be remained.
TODO : For disabling sys-assert, the services should be changed properly.
Change-Id: I617356cd31b51dbe4f103cb3118fefe454e717db
Karol Lewandowski [Sat, 22 Apr 2017 10:47:35 +0000 (10:47 +0000)]
Merge "spec: change group(system -> root) on tizen-debug-off.[service|socket]" into tizen
INSUN PYO [Thu, 20 Apr 2017 05:09:37 +0000 (14:09 +0900)]
spec: change group(system -> root) on tizen-debug-off.[service|socket]
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I32605d431b3ff16cce61ae2dde7be262a1eac56f
Karol Lewandowski [Wed, 15 Mar 2017 15:43:03 +0000 (16:43 +0100)]
crash-pipe: Drop all reporting functionality
Reporting is handled by crash-stack.
Change-Id: I6066c5a414fd2e98efbcc0ddc57f2f967cbfb859
Karol Lewandowski [Wed, 15 Mar 2017 15:39:51 +0000 (16:39 +0100)]
crash-pipe: Introduce option to copy core using splice(2)
Linux splice(2) avoids user-space copy and is effectively faster than
regular read(2) + write(2).
According to (ftrace) test below splice is about 20% faster.
sysctl -w kernel.core_pattern='|/usr/libexec/core-pipe --save-core /opt/usr/share/temp/core.%p'
cd /sys/fs/kernel/tracing/
echo do_coredump > set_ftrace_filter
echo function_graph > current_tracer
cat trace_pipe
/* splice */
2) $ 2183078 us | } /* do_coredump */
4) $ 2127946 us | } /* do_coredump */
1) $ 2377004 us | } /* do_coredump */
1) $ 2088114 us | } /* do_coredump */
/* read/write */
1) $ 3088297 us | } /* do_coredump */
1) $ 2953330 us | } /* do_coredump */
1) $ 2647784 us | } /* do_coredump */
3) $ 2271315 us | }
Change-Id: Id2c681a364ce96d98c70329abdf4a64f6d0b405d