[PATCH] libdwfl: Don't try to convert too many bytes in dwfl_link_map_report

2021-12-08 Thread Mark Wielaard
When trying to read (corrupt) phdrs from a core file we only want to read and convert the bytes we could read. Also make sure we don't try to allocate too big buffers. https://sourceware.org/bugzilla/show_bug.cgi?id=28666 Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog | 6 ++ libdwfl/

[Bug libelf/28666] memmove() reads out-of-range in elf32_xlatetom

2021-12-08 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28666 --- Comment #3 from Mark Wielaard --- Proposed patch: https://patchwork.sourceware.org/project/elfutils/patch/20211208133606.7658-1-m...@klomp.org/ -- You are receiving this mail because: You are on the CC list for the bug.

Re: [PATCHv2] debuginfod: Check result of calling MHD_add_response_header.

2021-12-08 Thread Mark Wielaard
Hi Frank, On Wed, 2021-12-01 at 10:23 -0500, Frank Ch. Eigler wrote: > > Although unlikely the MHD_add_response_header can fail for > > various reasons. If it fails something odd is going on. > > So check we can actually add a response header and log an > > error if we cannot. > > TBH I wouldn't

[PATCHv3] debuginfod: Check result of calling MHD_add_response_header.

2021-12-08 Thread Mark Wielaard
Although unlikely the MHD_add_response_header can fail for various reasons. If it fails something odd is going on. So check we can actually add a response header and log an error if we cannot. Signed-off-by: Mark Wielaard --- debuginfod/ChangeLog | 12 debuginfod/debuginfod.cxx |

Re: [PATCH v3] build: allow turning off --no-undefined and -z,defs

2021-12-08 Thread Mark Wielaard
Hi Evgeny, On Sun, 2021-12-05 at 19:52 +0300, Evgeny Vereshchagin wrote: > > See how I used it to workaround isssues with the > > gcc address sanitizer. You can use it likewise to work around > > issues > > with clang. e.g. the configure check should detect the issue with > > --no-undefined and co

Re: [PATCH] debuginfod/debuginfod-client.c: correct string format on 32bit arches with 64bit time_t

2021-12-08 Thread Mark Wielaard
Hi Alexander, On Sun, 2021-12-05 at 21:45 +0100, Alexander Kanavin wrote: > I'm not sure; the point of this patch is simply to ensure debuginfod builds > everywhere without errors. Making the types consistent is perhaps better > done as a followup? I think the issue of the code not compiling in s

Re: [PATCHv3] debuginfod: Check result of calling MHD_add_response_header.

2021-12-08 Thread Frank Ch. Eigler via Elfutils-devel
Hi - > Although unlikely the MHD_add_response_header can fail for > various reasons. If it fails something odd is going on. > So check we can actually add a response header and log an > error if we cannot. Sure, if you insist. :-) except: > - *size = os.size(); > - MHD_add_response_header (r

Re: [PATCHv3] debuginfod: Check result of calling MHD_add_response_header.

2021-12-08 Thread Mark Wielaard
Hi Frank, On Wed, 2021-12-08 at 10:32 -0500, Frank Ch. Eigler wrote: > except: > > > - *size = os.size(); > > - MHD_add_response_header (r, "Content-Type", "text/plain"); > > + if (r != NULL) > > +{ > > + *size = os.size(); > > + add_mhd_response_header (r, "Content-Type", "text/

Re: [PATCHv3] debuginfod: Check result of calling MHD_add_response_header.

2021-12-08 Thread Frank Ch. Eigler via Elfutils-devel
Hi - > > Why move the *size assignment in there? > > Because both statements are unnecessary if r == NULL (aka the response > couldn't even be created). [...] > But it is also harmless to do, so if you want I can move it outside the > if statement. OK, whichever, doesn't much matter then. - FChE

obv patch: debuginfod concurrency fix

2021-12-08 Thread Frank Ch. Eigler via Elfutils-devel
Hi - Committing as obvious. Author: Frank Ch. Eigler Date: Wed Dec 8 10:20:58 2021 -0500 debuginfod: correct concurrency bug in fdcache metrics The intern() function called set_metrics() outside a necessary lock being held. helgrind identified this race condition. No QA imp

[COMMITTED] libdwfl: Don't read beyond end of file in dwfl_segment_report_module

2021-12-08 Thread Mark Wielaard
The ELF might not be fully mapped into memory (which probably means the phdrs are bogus). Don't try to read beyond what we have in memory already. Reported-by: Evgeny Vereshchagin Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog| 5 + libdwfl/dwfl_segment_report_module

[PATCH] libdwfl: Add overflow check while iterating in dwfl_segment_report_module

2021-12-08 Thread Mark Wielaard
While iterating the notes we could overflow the len variable if the note name or description was too big. Fix this by adding an (unsigned) overflow check. https://sourceware.org/bugzilla/show_bug.cgi?id=28654 Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog| 5 + libdw

[Bug libdw/28654] There seems to be an infinite loop somewhere in dwfl_segment_report_module

2021-12-08 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28654 Mark Wielaard changed: What|Removed |Added Last reconfirmed||2021-12-08 Status|UNCONFI

Buildbot failure in Wildebeest Builder on whole buildset

2021-12-08 Thread buildbot
The Buildbot has detected a new failure on builder elfutils-centos-x86_64 while building elfutils. Full details are available at: https://builder.wildebeest.org/buildbot/#builders/1/builds/868 Buildbot URL: https://builder.wildebeest.org/buildbot/ Worker for this Build: centos-x86_64 Build

[Bug libelf/28666] memmove() reads out-of-range in elf32_xlatetom

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28666 --- Comment #4 from Evgeny Vereshchagin --- With that patch applied I can confirm that the issue is gone.Just to make sure also run the unit tests on aarch64, i386, ppc64le and x86_64 and they all passed there. Thanks! -- You are receiving t

[Bug libdw/28654] There seems to be an infinite loop somewhere in dwfl_segment_report_module

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28654 --- Comment #2 from Evgeny Vereshchagin --- I applied the patch on top of the master branch with the other two patches related to libwfl applied and ran `src/stack` under Valgrind. I also ran the unit tests on four different architectures just

Re: [PATCH v3] build: allow turning off --no-undefined and -z,defs

2021-12-08 Thread Evgeny Vereshchagin
Hi Mark, > But that doesn't really work if you use clang. It kind of does because almost everybody who builds their projects with clang sanitizers turns off `z,defs` and `--no-undefined`. I agree it looks weird (and it's probably weird) but it's just how it has been done for I don't know how ma

[PATCH] libdwfl: Make sure we know the phdr entry size before searching phdrs.

2021-12-08 Thread Mark Wielaard
Without the program header entry size we cannot search through the phdrs. https://sourceware.org/bugzilla/show_bug.cgi?id=28657 Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog | 4 libdwfl/link_map.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLo

[Bug libdw/28657] UBSan seems to report a divison-by-zero in dwfl_link_map_report

2021-12-08 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28657 Mark Wielaard changed: What|Removed |Added CC||mark at klomp dot org Ever confir

[Bug libdw/28660] ASan seems to complain about a "heap-buffer-overflow"

2021-12-08 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28660 Mark Wielaard changed: What|Removed |Added CC||mark at klomp dot org --- Comment #1

[Bug libdw/28660] ASan seems to complain about a "heap-buffer-overflow"

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28660 --- Comment #2 from Evgeny Vereshchagin --- As far as I can see both issues are gone with that patch applied. Thanks! -- You are receiving this mail because: You are on the CC list for the bug.

[Bug libelf/28666] memmove() reads out-of-range in elf32_xlatetom

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28666 --- Comment #5 from Evgeny Vereshchagin --- I was able to trigger the same issue with a different file by running the fuzz target a bit longer. I'll double check and attach the file -- You are receiving this mail because: You are on the CC l

[Bug libelf/28666] memmove() reads out-of-range in elf32_xlatetom

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28666 --- Comment #6 from Evgeny Vereshchagin --- My bad. The backtrace is different there: ``` 2021-12-08T20:14:08.7167911Z ==21==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f4f1d328000 at pc 0x00524c9f bp 0x7fff9271bc40 sp 0x7f

[PATCH] libdwfl: Don't trust e_shentsize in dwfl_segment_report_module

2021-12-08 Thread Mark Wielaard
When calulating the possible section header table end us the actual size of the section headers (sizeof (Elf32_Shdr) or sizeof (Elf64_Shdr)), not the ELF header e_shentsize value, which can be corrupted. This prevents a posssible overflow, but we check the shdrs_end is sane later anyway. https://s

[Bug libdw/28659] UBSan seems to complain about an "integer overflow" in dwfl_segment_report_module

2021-12-08 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28659 Mark Wielaard changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Assignee|unassigne

Re: Buildbot failure in Wildebeest Builder on whole buildset

2021-12-08 Thread Mark Wielaard
On Wed, Dec 08, 2021 at 05:20:29PM +, build...@builder.wildebeest.org wrote: > The Buildbot has detected a new failure on builder elfutils-centos-x86_64 > while building elfutils. > Full details are available at: > https://builder.wildebeest.org/buildbot/#builders/1/builds/868 > > Buildbo

Re: [PATCHv3] debuginfod: Check result of calling MHD_add_response_header.

2021-12-08 Thread Mark Wielaard
On Wed, Dec 08, 2021 at 10:46:29AM -0500, Frank Ch. Eigler via Elfutils-devel wrote: > Hi - > > > > Why move the *size assignment in there? > > > > Because both statements are unnecessary if r == NULL (aka the response > > couldn't even be created). [...] > > But it is also harmless to do, so if

[Bug libdw/28659] UBSan seems to complain about an "integer overflow" in dwfl_segment_report_module

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28659 --- Comment #2 from Evgeny Vereshchagin --- > Note that the overflow is actually harmless It is but since the fuzz target ran into it almost as soon as it started it prevented the fuzz target from discovering new issues that can be less harml

[PATCH] libdwfl: Don't install an Elf handle in a Dwfl_Module twice

2021-12-08 Thread Mark Wielaard
dwfl_segment_report_module can be called with the same module name, start and end address twice (probably because of a corrupt core file). In that case don't override the main.elf handle if it already exists. https://sourceware.org/bugzilla/show_bug.cgi?id=28655 Signed-off-by: Mark Wielaard ---

[Bug libdw/28655] There seems to be a memory leak in file_read_elf

2021-12-08 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28655 Mark Wielaard changed: What|Removed |Added CC||mark at klomp dot org Sta

Re: [PATCH] readelf: Workaround stringop-truncation error

2021-12-08 Thread Mark Wielaard
On Sat, Dec 04, 2021 at 10:15:04PM +0100, Mark Wielaard wrote: > In function ‘strncpy’, > inlined from ‘print_ehdr’ at readelf.c:1175:4: > error: ‘__builtin_strncpy’ specified bound 512 equals destination size >[-Werror=stringop-truncation] > > strncpy doesn't terminate the copied stri

Re: [PATCH] tests: varlocs workaround format-overflow errors

2021-12-08 Thread Mark Wielaard
On Sat, Dec 04, 2021 at 10:27:29PM +0100, Mark Wielaard wrote: > In function ‘printf’, > inlined from ‘handle_attr’ at varlocs.c:932:3: > error: ‘%s’ directive argument is null [-Werror=format-overflow=] > > The warning is technically correct. A %s argument should not be > NULL. Although in pr

Re: [PATCH] debuginfod: Fix debuginfod_pool leak

2021-12-08 Thread Mark Wielaard
On Sat, Dec 04, 2021 at 10:33:35PM +0100, Mark Wielaard wrote: > gcc address sanitizer detected a dangling debuginfod_client handler > when debuginfod exits. Make sure to groom the debuginfod client pool > before exit after all threads are done. Pushed, Mark

Re: [PATCH] configure: Add --enable-sanitize-address

2021-12-08 Thread Mark Wielaard
Hi, On Sun, Dec 05, 2021 at 02:39:25AM +0100, Mark Wielaard wrote: > --enable-sanitize-address makes sure that all code is compiled with > -fsanitizer=address and all tests run against libasan. > > It can be combined with --enable-sanitize-undefined, but not with > --enable-valgrind. > > In main

[Bug libdw/28655] There seems to be a memory leak in file_read_elf

2021-12-08 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28655 --- Comment #2 from Evgeny Vereshchagin --- I can't seem to reproduce that memory leak anymore. Thanks! -- You are receiving this mail because: You are on the CC list for the bug.

Re: [PATCH] debuginfod/debuginfod-client.c: correct string format on 32bit arches with 64bit time_t

2021-12-08 Thread Frank Ch. Eigler via Elfutils-devel
Hi - > [...] > We seem to not expect these intervals to be much bigger than a week, > so an int should always be big enough (even when stretched up to a > whole year). Yes, ints are fine for these humane-number-of-seconds kinds of values in the cache configuration. There's no need for maximum le

patch rfc: PR28661: debuginfod thread-pool

2021-12-08 Thread Frank Ch. Eigler via Elfutils-devel
Hi - While I think this patch itself is fine, and works around the libmicrohttpd bug that motivated it, I don't know how to test it seriously in the testsuite. (We can certainly try few -C options for parsing & operability.) The error edge cases only appear to occur under very high load and task