summaryrefslogtreecommitdiff
path: root/debuginfod
Commit message (Collapse)AuthorAgeFilesLines
* configure: Add --enable-sanitize-memoryIlya Leoshkevich2023-02-141-1/+2
| | | | | | | | | | | | | | | | | | | | Add support for clang Memory Sanitizer [1], which detects the usage of uninitialized values. While elfutils itself is already checked with valgrind, checking code that depends on elfutils requires elfutils to be built with MSan. MSan is not linked into shared libraries, and is linked into executables statically. Therefore, unlike the other sanitizers, MSan needs to be configured fairly early, since we need to drop -D_FORTIFY_SOURCE [2], -Wl,-z,defs and --no-undefined. Disable a few tests that run for more than 5 minutes due to test files being statically linked with MSan. [1] https://clang.llvm.org/docs/MemorySanitizer.html [2] https://github.com/google/sanitizers/issues/247 Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
* printversion: Fix unused variableIlya Leoshkevich2023-02-141-2/+1
| | | | | | | | | | | | | | | | | | clang complains: debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable] ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; ^ ../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF' const char *const apba__ __asm ("argp_program_bug_address") ^ The default linkage for consts in C++ is internal, so declare them extern. While at it, remove the debuginfod workaround for argp_program_version_hook. Co-developed-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
* debuginfod-client.c: Download section even if cached executable didn't ↵Aaron Merey2023-02-072-10/+21
| | | | | | | | | | | | | | | | | | | | | contain it. Before attempting to download a section, cache_find_section tries to extract the section from existing files in the cache. If it's determined that the section must not exist, cache_find_section returns -ENOENT to indicate that the download should be skipped. This patch fixes a bug where cache_find_section returns -ENOENT even though the section exists. If the cache contains the executable but not the debuginfo with the given build-id and the section only exists in the debuginfo (such as any of the .debug_* sections), then debuginfod_find_section returns -ENOENT even if the section could be downloaded. Fix this by having cache_find_section not return -ENOENT unless cached debuginfo was able to be read. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod: Make sure there is only one typedef for debuginfod_clientMark Wielaard2023-02-062-0/+8
| | | | | | | | | | | | Both debuginfod.h and libdwfl.h have a simple typedef for struct debuginfod_client. Some compilers pedantically warn when including both headers that such typedefs are only officially supported in C11. So guard them with _ELFUTILS_DEBUGINFOD_CLIENT_TYPEDEF to make them happy. https://sourceware.org/bugzilla/show_bug.cgi?id=30077 Signed-off-by: Mark Wielaard <mark@klomp.org>
* Fix typos from codespellSam James2023-01-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debuginfod/ChangeLog: * debuginfod-client.c: Typo simultaniously. doc/ChangeLog: * debuginfod.8: Typo succesfully. lib/ChangeLog: * dynamicsizehash_concurrent.c: Typo modul. * system.h: Typo dependend. libdwfl/ChangeLog: * open.c: Typo non-existant. src/ChangeLog: * nm.c: Typo Covert. * strings.c: Likewise. tests/ChangeLog: * elfstrmerge.c: Typo outselves. * run-debuginfod-extraction.sh: Typo accidentially. * run-debuginfod-fd-prefetch-caches.sh: Likewise. Signed-off-by: Sam James <sam@gentoo.org>
* debuginfod PR29975 & PR29976: decrease default concurrencyFrank Ch. Eigler2023-01-112-2/+63
| | | | | | | ... based on rlimit (rlimig -n NUM) ... based on cpu-affinity (taskset -c A,B,C,D ...) Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod-client: Use CURLOPT_PROTOCOLS_STR for libcurl >= 7.85.0Mark Wielaard2023-01-112-0/+10
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=29926 Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Define CURL_AT_LEAST_VERSION if necessaryMark Wielaard2022-12-212-0/+11
| | | | | | | | Older curl.h don't define CURL_AT_LEAST_VERSION, so define it ourselves because it is nicer than doing hex encoded version comparisons. Signed-off-by: Mark Wielaard <mark@klomp.org>
* PR29926: debuginfod: Fix usage of deprecated CURLINFO_*Andrew Paprocki2022-12-212-2/+6
| | | | | | | | | | | | | | | | | The `CURLINFO_SIZE_DOWNLOAD_T` and `CURLINFO_CONTENT_LENGTH_DOWNLOAD_T` identifiers are `enum`s, not pre-processor definitions, so the current `#ifdef` logic is not selecting the newer API. This results in the older identifiers being used and they now generate errors when compiled against Curl 7.87, which has silently deprecated them, causing GCC to emit `-Werror=deprecated-declarations`. Instead, the newer identifiers were added in Curl 7.55, so explicitly check for `CURL_AT_LEAST_VERSION(7, 55, 0)` instead of the current logic. This eliminates the error when compiling against Curl 7.87. Ref: https://github.com/curl/curl/pull/1511 Signed-off-by: Andrew Paprocki <andrew@ishiboo.com>
* debuginfod: Initialize response_data early in debuginfod-client queryMark Wielaard2022-11-212-2/+7
| | | | | | | | On error going to out2, the response_data is freed. So initialize the response_data to NULL immediately after allocation or when going back to query_in_parallel. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod-client.c: Don't treat 0 as an error code.Aaron Merey2022-11-072-2/+7
| | | | | | | Replace 'fd > 0' with 'fd >= 0' to avoid treating a possible file descriptor as an error code. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod_find_section: Always update rc with most recent error codeAaron Merey2022-11-042-1/+10
| | | | | | | | | debuginfod_find_section may attempt to download both the debuginfo and executable matching the given build-id. If neither of these files can be found, update rc to ensure that we always return an accurate error code in this case. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod.cxx: fix coverity-found use-after-release errorFrank Ch. Eigler2022-11-032-73/+75
| | | | | | | The debuginfod_client object lifetime needs more careful handling, made easier with the defer_dtor<> gadget. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod: Mark extract_section function staticMark Wielaard2022-11-022-1/+5
| | | | | | | The extract_section function in debuginfod-client.c is an internal function and should not be exported. Mark it as static. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Changelog: Update entries from previous commits.Aaron Merey2022-11-011-0/+4
| | | | | | Update Changelogs with details from commits 04b1a3aa and 054b3bde9. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod-client: Fix out-of-bounds writeAaron Merey2022-11-011-2/+1
| | | | | | | Return early from path_escape when '\0' is seen in order to prevent an out-of-bounds write to the dest buffer. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod: Support queries for ELF/DWARF sectionsAaron Merey2022-11-017-96/+696
| | | | | | | | | | | | | | | | | | | | | | Add new function debuginfod_find_section which queries debuginfod servers for the raw binary contents of the specified ELF/DWARF section in a file matching the given build-id. Extend the server webapi to support section queries. Section query URLS have the following format: /buildid/BUILDID/section/SECTION The server will attempt to extract the section from a debuginfo file matching the given build-id. If the debuginfo file cannot be found or the section has type SHT_NOBITS, the server will attempt to extract the section from the executable file matching the build-id. If the server is built without section query support, the client will attempt to download the debuginfo matching the build-id and extract the section. If the debuginfo file cannot be found or the section has type SHT_NOBITS, the server will attempt to download the executable file matching the build-id and extract the section. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod-client: Add DEBUGINFOD_HEADERS_FILE.Daniel Thornburgh2022-10-283-0/+51
| | | | | | | | This DEBUGINFOD_HEADERS_FILE environment variable names a file to supply HTTP headers to outgoing requests. Notably, this allows for Authorization headers to be added from a file under OS access control. Signed-off-by: Daniel Thornburgh <dthorn@google.com>
* debuginfod: report libmicrohttpd version on startupFrank Ch. Eigler2022-10-172-0/+6
| | | | | | To assist troubleshooting with intermittent bugs. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* Move the #include <libintl.h> into eu-config.hYonggang Luo2022-10-161-1/+0
| | | | | | | | | | So we do not need include in each file. And indeed the macro #define _(Str) dgettext ("elfutils", Str) access libintl function dgettext, so it's make more sense #include <libintl.h> in file eu-config.h Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* debuginfod-client: Ensure only negative error codes returned.Aaron Merey2022-09-282-2/+7
| | | | | Switch a couple error codes from positive to negative so they aren't interpreted as file descriptors by the caller.
* Retrive 64bit timestamp from curl_easy_getinfo on _TIME_BITS=64 environment河辺 岳人2022-09-271-0/+4
| | | | | | | | | | | | | | | | | | | | | On 32bit system compiled with -D_TIME_BITS=64, following tests failed: FAIL: run-debuginfod-archive-test.sh FAIL: run-debuginfod-archive-groom.sh FAIL: run-debuginfod-archive-rename.sh FAIL: run-debuginfod-federation-sqlite.sh FAIL: run-debuginfod-federation-metrics.sh FAIL: run-debuginfod-federation-link.sh due to tests/debuginfod-subr.sh:archive_test failing on "test $fileame -ot `pwd`", with LHS file having a bogus timestamp. LHS is generated by debuginfo-find as a cache file. I'm not sure the fix is the correct way, but since -D_TIME_BITS=64 mandates -D_FILE_OFFSET_BITS=64 in glibc, this does work on glibc environment. Signed-off-by: Taketo Kabe <kabe@sra-tohoku.co.jp>
* PR28284 cont'd, ->winning_headers reset at start of new queryFrank Ch. Eigler2022-09-082-1/+8
| | | | | | | Mark noted we need to ditch the last client ->winning_headers along with the last ->url. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* add debuginfod_get_headers if DUMMY_LIBDEBUGINFOD is usedMartin Liska2022-09-082-0/+6
| | | | Signed-off-by: Martin Liska <mliska@suse.cz>
* PR28284: add tweaks on previous debuginfod x-debuginfod* header forwarding workFrank Ch. Eigler2022-09-076-30/+47
| | | | | | | | Embrace case-independent headers, more fully document, handle HTTP \r. In addition to test case, hand-tested against fedora debuginfod instances, running federated servers under valgrind. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* PR28284 - Debuginfod header functionality implementedNoah Sanci2022-09-066-2/+54
| | | | | | | | Debuginfod and debuginfod clients are now equipped to send and receive http headers prefixed with X-DEBUGINFOD and print them in verbose mode for more context Signed-off-by: Noah Sanci <nsanci@redhat.com>
* debuginfod: Use auto-sized connection pool when -C is not given with argAaron Merey2022-09-052-12/+17
| | | | | | | | | | | | | | | | | | Since commit 4b42d9ad, libmicrohttpd's epoll event loop is used when available in which case we must disable its setting for spawning a thread per request. This contradicts the debuginfod doc's description of '-C', which indicates that if this command line option is not given then the thread pool size is unbounded. Fix this by using an auto-sized thread pool when '-C' is not given, just as we do when it's given with no argument. Update the doc's description of '-C'. Also use a fixed-size pool even if epoll is not supported. The unbounded pool config cannot be considered entirely reliable as it appears to cause random fails in the run-debuginfod-webapi-concurrency test. Signed-off-by: Aaron Merey <amerey@redhat.com>
* Add missing changelog entries.Martin Liska2022-08-171-0/+9
|
* debuginfod: fix http_requests_total{type="debuginfo"} when dwz is usedMartin Liska2022-08-171-2/+4
| | | | | | | | When dwarf_extract_source_paths is called, it can call handle_buildid when a rpm file used dwz. Ignore such internal request in http_requests_total statistics. Signed-off-by: Martin Liska <mliska@suse.cz>
* debuginfod: print filename for "cannot open archive" errorMartin Liska2022-08-171-2/+8
| | | | | | Report the file that has such a problem so that one can inspect it. Signed-off-by: Martin Liska <mliska@suse.cz>
* PR29474: debuginfodFrank Ch. Eigler2022-08-152-1/+8
| | | | | | | | | | | | | | | | | | | | | | | Previous code sometimes confused debuginfod with concurrent queries targeting the same RPM. One thread fetching & prefetching, the other thread misinterpreted the sudden presence of its target file in the fdcache as a mere unnecessary prefetch duplicate. But if it was the other thread's target file, previous code would -skip- it completely, resulting in a 404 error. New code allows the other thread to also decompress the target file and return it, and still continue to its own prefetching process for other files. There's a performance trade-off here. Another option would be for the other thread to check the fdcache regularly and abort its own prefetch/fetch/prefetch loop early in case of a sudden target file hit. That'd save CPU probably but it'd stop prefetching of later segments of the input archive, which could save future time. Automated testing is too time/load sensitive to attempt. Confirmed working with Martin's stress tester. Reported-By: Martin Liška <mliska@suse.cz> Signed-Off-By: Frank Ch. Eigler <fche@redhat.com>
* debuginfod: optimize regular expressions in groom()Josef Cejka2022-08-032-3/+13
| | | | | | | Check if applying of -I and -X during grooming is enabled before the regular expressions are matched. Signed-off-by: Josef Cejka <jcejka@suse.de>
* debuginfod: create indexes to speed up groomingJosef Cejka2022-07-292-0/+8
| | | | | | | | | | | | | | | Create indexes on _r_de and _f_de tables to speed up delete operations called by groom() function. Primary keys of those tables are optimalized to search rows by buildids so delete by file and mtime attributes has to scan the whole table. On large database can single delete query take minutes and grooming will be aborted before completion by time limit. New indexes are compatible with current sqlite schema. Signed-off-by: Josef Cejka <jcejka@suse.de>
* NEWS & ChangeLog: add debuginfod blurbsFrank Ch. Eigler2022-06-031-0/+5
| | | | Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod: add --disable-source-scan optionMichael Trapp2022-06-031-1/+8
| | | | | | | | --disable-source-scan disables scanning of the dwarf source info of debuginfo sections. The source info is not required in setups without source code access. Signed-off-by: Michael Trapp <michael.trapp@sap.com>
* debuginfod: update mtime of interval_path as early as possibleMark Wielaard2022-05-152-2/+10
| | | | | | | | | | Call utime on interval_path file as soon as the thread is committed to cleanup the cache files. This will prevent other threads trying to also commit to cleaning the cache files. Having multiple threads try to clean the cache simultaniously doesn't improve cleanup speed because the threads will try to delete the files in the same order. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Remove debuginfod_init_cacheMark Wielaard2022-05-152-52/+15
| | | | | | | | | | | debuginfod_init_cache would create all config files if they didn't exist yet. It always made two stat calls. Then debuginfod_clean_cache would call debuginfod_config_cache which did the same checks and created any missing config files. Just make sure the cache_path directory exists and remove debuginfod_init_cache before calling debuginfod_clean_cache. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Make sure debuginfod_config_cache always returns valid statMark Wielaard2022-05-152-7/+20
| | | | | | | | | | | If the condig file which value was requested from debuginfod_config_cache didn't exist yet, stat would fail and no valid struct stat would be returned even when the file was correctly created. Fix this by always using O_CREAT to open the file, and reuse that file descriptor to call fstat and for either writing the default value or reading the config file value. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Always request servname from getnameinfo for conninfo.Mark Wielaard2022-05-152-5/+14
| | | | | | | | | | | When getting the connection info getnameinfo is called getting the hostname and servname except when the sockaddr is a pure ipv6 address. In that last case only hostname is requested. Since servname is stack allocated and not initialized it might contain garbage which is then put in the log. Just always request both hostname and servname with NI_NUMERICHOST | NI_NUMERICSERV. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Check all curl_easy_setopt callsMark Wielaard2022-05-142-22/+44
| | | | | | | | curl_easy_setup can fail for various reasons. Add a curl_easy_setopt_ck macro to check all curl_easy_setopt calls and provides a human readable error message in verbose mode. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Check result of curl_easy_getinfo in debuginfod_write_callbackMark Wielaard2022-05-142-2/+8
| | | | | | | This was the only place in debuginfod-client.c where we didn't check the result of curl_easy_getinfo. Just check it to make things consistent. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Use MHD_USE_EPOLL for libmicrohttpd version 0.9.51 or higherMark Wielaard2022-05-122-5/+16
| | | | | | | | Also disable MHD_USE_THREAD_PER_CONNECTION when using MHD_USE_EPOLL. https://sourceware.org/bugzilla/show_bug.cgi?id=29123 Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Try without MHD_USE_DUAL_STACK if MHD_start_daemon failsMark Wielaard2022-05-122-23/+58
| | | | | | | | | | | On a systems that have ipv6 disabled debuginfod doesn't start up anymore because libhttpd MHD_USE_DUAL_STACK only works if it can open an ipv6 socket. If MHD_start_daemon with MHD_USE_DUAL_STACK fails try again without that flag set. https://sourceware.org/bugzilla/show_bug.cgi?id=29122 Signed-off-by: Mark Wielaard <mark@klomp.org>
* PR29098: debuginfod - set default prefetch cache size to >0Noah Sanci2022-05-092-0/+11
| | | | | | | | | Added default value to fdcache_prefetch_mds and fdcache_prefetch_fds. Defaults to one half of corresponging fdcache's values. Signed-off-by: Noah Sanci <nsanci@redhat.com> foo
* PR29117: fix fd leak in debuginfod client for cache-miss filesFrank Ch. Eigler2022-05-043-8/+35
| | | | | | | | | Correct a nasty fd leak and a few less nasty leaks in the debuginfod client code. The nasty one impacts long-lived apps such as debuginfod servers. Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod: ensure X-DEBUGINFOD-SIZE contains file sizeAaron Merey2022-04-251-1/+1
| | | | | | | | | | For archived files X-DEBUGINFOD-SIZE currently contains the size of the archive instead of the size of the uncompressed file. Fix this. Also add testcases to verify X-DEBUGINFOD-SIZE contains uncompressed file sizes. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod: Use the debuginfod-size response headerAaron Merey2022-04-251-40/+43
| | | | | | | | | | | | | In some cases the content-length header may not be available in order to pass to a progressfn. If content-length isn't available then attempt to get the size of the download from the debuginfod-size header instead. It should be mentioned that if a compressed file (ex. gzip) is being transferred, the actual transfer length will be less than debuginfod-size. In this case debuginfod-size is a best-guess upper bound on the size of the transfer. Signed-off-by: Aaron Merey <amerey@redhat.com>
* debuginfod, libdwfl: Initialize libcurl and dlopen debuginfod-client lazilyMark Wielaard2022-04-253-17/+26
| | | | | | | | | | | | | We used to go out of our way to initialize libcurl early before any other thread/code was running. But this meant that we might pay startup cost, which under FIPS is significant, even for code that never uses libdebuginfod or TLS libcurl connections. Although curl_global_init itself isn't thread-safe we can use pthread_once to make sure we don't race against ourselves. This still means we might race against any application code that might use libcurl. But we can assume they will have called curl_global_init before calling dwfl_begin or debuginfod_begin. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Use MHD_USE_ITC in MHD_start_daemon flagsMark Wielaard2022-04-242-0/+7
| | | | | | | | | | | | | | | | | | | This prevents the "Server reached connection limit. Closing inbound connection." issue we have been seeing in the run-debuginfod-webapi-concurrency.sh testcase. From the manual: If the connection limit is reached, MHD’s behavior depends a bit on other options. If MHD_USE_ITC was given, MHD will stop accepting connections on the listen socket. This will cause the operating system to queue connections (up to the listen() limit) above the connection limit. Those connections will be held until MHD is done processing at least one of the active connections. If MHD_USE_ITC is not set, then MHD will continue to accept() and immediately close() these connections. https://sourceware.org/bugzilla/show_bug.cgi?id=28708 Signed-off-by: Mark Wielaard <mark@klomp.org>
* PR29022: 000-permissions files cause problems for backupsAaron Merey2022-04-132-35/+67
| | | | | | | | | | | | | | 000-permission files currently used for negative caching can cause permission problems for some backup software and disk usage checkers. Fix this by using empty files for negative caching instead. Also use each empty file's mtime to determine the time since last download attempt instead of the cache_miss_s file's mtime. https://sourceware.org/bugzilla/show_bug.cgi?id=29022 Tested-by: Milian Wolff <mail@milianw.de> Signed-off-by: Aaron Merey <amerey@redhat.com>