summaryrefslogtreecommitdiff
path: root/src/shared/elf-util.c
Commit message (Collapse)AuthorAgeFilesLines
* process-util: rename FORK_NULL_STDIO -> FORK_REARRANGE_STDIOYu Watanabe2023-02-211-0/+1
| | | | And make safe_fork_full() takes fds to be assigned to stdio.
* tree-wide: introduce PIPE_EBADF macroYu Watanabe2022-12-201-3/+3
|
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-191-1/+3
| | | | In some places, initialization is dropped when unnecesary.
* coredump: cescape invalid json data before loggingZbigniew Jędrzejewski-Szmek2022-12-141-2/+5
| | | | | | | | | | | In both cases, the json string is short, so we can print it, which is useful for diagnosing invalid data in packages. But we need escape non-printable characters. https://bugzilla.redhat.com/show_bug.cgi?id=2152685 I went over the rest of the codebase, and it seems that other calls to json_parse() don't have this problem.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* coredump: avoid deadlock when passing processed backtrace dataZbigniew Jędrzejewski-Szmek2022-10-191-6/+31
| | | | | | | | | | | | | | | | | | | | | | | We would deadlock when passing the data back from the forked-off process that was doing backtrace generation back to the coredump parent. This is because we fork the child and wait for it to exit. The child tries to write too much data to the output pipe, and and after the first 64k blocks on the parent because the pipe is full. The bug surfaced in Fedora because of a combination of four factors: - 87707784c70dc9894ec613df0a6e75e732a362a3 was backported to v251.5, which allowed coredump processing to be successful. - 1a0281a3ebf4f8c16d40aa9e63103f16cd23bb2a was NOT backported, so the output was very verbose. - Fedora has the ELF package metadata available, so a lot of output can be generated. Most other distros just don't have the information. - gnome-calendar crashes and has a bazillion modules and 69596 bytes of output are generated for it. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2135778. The code is changed to try to write data opportunistically. If we get partial information, that is still logged. In is generally better to log partial backtrace information than nothing at all.
* shared/json: use different return code for empty inputZbigniew Jędrzejewski-Szmek2022-10-191-1/+1
| | | | | It is useful to distinguish if json_parse_file() got no input or invalid input. Use different return codes for the two cases.
* elf-util: drop assertion for metadata in report_module_metadata()Yu Watanabe2022-10-141-16/+17
| | | | | | Fixes a bug introduced by 1a0281a3ebf4f8c16d40aa9e63103f16cd23bb2a. Fixes RHBZ#2134741 (https://bugzilla.redhat.com/show_bug.cgi?id=2134741).
* coredump: print build-id only when package version is missingZbigniew Jędrzejewski-Szmek2022-09-281-1/+1
| | | | | The build-id is quite verbose, and probably not very useful to a user when they already know the nvra of the package.
* coredump: shorten output about package metadata to one lineZbigniew Jędrzejewski-Szmek2022-09-281-21/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would print the whole thing in extenso. Users generally don't care, and would likely prefer to just get the compact identifier of the package that they can use in a bug report or package manager commands. Before: systemd-coredump[40645]: [🡕] Process 1975 (gnome-shell) of user 1000 dumped core. Module /usr/bin/gnome-shell (deleted) with build-id aafdb7d69a7efca937e490080ad9348541fc57d8 Metadata for module /usr/bin/gnome-shell (deleted) owned by FDO found: { "type" : "rpm", "name" : "gnome-shell", "version" : "43~rc-3.fc37", "architecture" : "x86_64", "osCpe" : "cpe:/o:fedoraproject:fedora:37" } Module /usr/lib64/gnome-shell/libgvc.so (deleted) with build-id 56cbb9862e1ee84ca1549b94f2b4cda03537613e Metadata for module /usr/lib64/gnome-shell/libgvc.so (deleted) owned by FDO found: { "type" : "rpm", "name" : "gnome-shell", "version" : "43~rc-2.fc37", "architecture" : "x86_64", "osCpe" : "cpe:/o:fedoraproject:fedora:37" } Module /usr/lib64/libLLVM-14.so (deleted) with build-id ffa7e43f48eb4c189304c0241b1862710de4c3a4 Metadata for module /usr/lib64/libLLVM-14.so (deleted) owned by FDO found: { "type" : "rpm", "name" : "gnome-shell", "version" : "43~rc-2.fc37", "architecture" : "x86_64", "osCpe" : "cpe:/o:fedoraproject:fedora:37" } After: systemd-coredump[235218]: [🡕] Process 235216 (bash) of user 1000 dumped core. Module libtinfo.so.6 from rpm ncurses-6.3-3.20220501.fc37.x86_64, build-id=71a04d23fd572525eb6efc47026c379725e06d96 Module bash from rpm bash-5.1.16-3.fc37.x86_64, build-id=6c936aff95a2ccda04a3fb685a81a84a0a8d10da Stack trace of thread 235216: #0 0x00007fa409ec8d8b kill (libc.so.6 + 0x38d8b) #1 0x0000560d35e366b1 kill_builtin (bash + 0xad6b1) #2 0x0000560d35dd7227 execute_builtin.lto_priv.0 (bash + 0x4e227) #3 0x0000560d35dd0459 execute_simple_command (bash + 0x47459) #4 0x0000560d35dd1de0 execute_command_internal (bash + 0x48de0) #5 0x0000560d35e307aa parse_and_execute (bash + 0xa77aa) #6 0x0000560d35e91b08 run_one_command.isra.0 (bash + 0x108b08) #7 0x0000560d35dba07c main (bash + 0x3107c) #8 0x00007fa409eb3510 __libc_start_call_main (libc.so.6 + 0x23510) #9 0x00007fa409eb35c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x235c9) #10 0x0000560d35dbad85 _start (bash + 0x31d85)
* coredump: when parsing json, optionally copy the string firstZbigniew Jędrzejewski-Szmek2022-09-281-0/+13
|
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-6/+3
|
* shared: Add more dlopen() testsDaan De Meyer2022-03-011-2/+2
| | | | | | Add dlopen_dw(), dlopen_elf() and dlopen_pcre2() to the dlopen test. To enable adding dlopen_pcre2(), we move pcre2-dlopen.h/c from src/journal to src/shared.
* elf-util: add missing assertionYu Watanabe2022-01-041-0/+2
|
* elf-util: reduce variable scopeYu Watanabe2022-01-041-3/+3
|
* elf-util: executable argument for parse_elf() may be NULLYu Watanabe2022-01-041-3/+5
| | | | Fixes assertion triggered by parse_package_metadata() and json_build().
* elf-util: reduce variable scope and indentationYu Watanabe2022-01-041-40/+42
|
* elf-util: reduce variable scope and indentationYu Watanabe2022-01-041-20/+22
|
* Merge pull request #21454 from bluca/inspect_elfZbigniew Jędrzejewski-Szmek2021-12-061-5/+136
|\ | | | | analyze: add inspect-elf verb to parse package metadata
| * elf-util: add function to parse metadata out of ELF objectsLuca Boccassi2021-11-301-5/+136
| | | | | | | | | | | | Parse the packaging metadata from an ELF object, if any, and print a pretty table following the spec defined at: https://systemd.io/COREDUMP_PACKAGE_METADATA/
* | elf-util: do not ignore prctl() errorsLuca Boccassi2021-12-011-2/+5
|/ | | | | | | We want to avoid loops, so fail and return if we can't disable core dumping CID#1467004
* elf-util: switch libelf/libdw to dlopen()Luca Boccassi2021-11-301-54/+176
| | | | | | In order to avoid inflating the dependency list for the core library, use dlopen when inspecting elfs, since it's only used in two non-core executables.
* elf-util: split out helper to parse build-idLuca Boccassi2021-11-301-27/+47
|
* coredump: move elf parsing utilities to src/shared/elf-utilLuca Boccassi2021-11-301-0/+535