Summary: | glibc built with -march=x86-64-v3 does not work due to ld.so memcmp | ||
---|---|---|---|
Product: | [Developer tools] valgrind | Reporter: | Florian Weimer <fweimer> |
Component: | memcheck | Assignee: | Julian Seward <jseward> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | mark, pjfloyd |
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=485487 | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Proposed memcmp interceptor |
Description
Florian Weimer
2025-03-11 11:22:56 UTC
Replicated with a dlopen of a library using RPATH. # Invalid read of size 32 # at 0x40242D9: bcmp (memcmp-avx2-movbe.S:415) # by 0x40069BD: fillin_rpath.isra.0 (dl-load.c:510) # by 0x4006C6A: decompose_rpath (dl-load.c:654) # by 0x4009375: _dl_map_object (dl-load.c:2040) # by 0x4002934: openaux (dl-deps.c:64) # by 0x40014E0: _dl_catch_exception (dl-catch.c:237) # by 0x4002D97: _dl_map_object_deps (dl-deps.c:232) # by 0x400CB70: dl_open_worker_begin (dl-open.c:613) # by 0x40014E0: _dl_catch_exception (dl-catch.c:237) # by 0x400C256: dl_open_worker (dl-open.c:778) # by 0x40014E0: _dl_catch_exception (dl-catch.c:237) # by 0x400C6B0: _dl_open (dl-open.c:880) The string being compared is just 11 chars long. It is pretty hard to replicate though any change in environment seems to hide it again. But the patch does look correct and does resolve the issue by always using a simpler memcmp implementation. commit 9ffdeb4927b8505cc5a9ea54f608f4972166bb0e Author: Mark Wielaard <mark@klomp.org> Date: Wed Mar 12 13:57:19 2025 +0100 add_hardwired_spec for ld-linux-x86-64.so.2 memcmp With RPATH processing ld.so compiled for x86-64-v3 uses an optimized avx2 memcmp (bcmp) which causes (false postive) memcheck invalid reads of size 32 warnings. Fix this my adding a hardwire spec with a simpler memcmp for ld-linux-x86-64.so.2. https://bugs.kde.org/show_bug.cgi?id=501348 Authored-by: Florian Weimer <fweimer@redhat.com> And also on the VALGRIND_3_24_0_BRANCH as commit 2c17a8a3e865816ee48e7f78148bbc7240c2a38c Author: Mark Wielaard <mark@klomp.org> Date: Wed Mar 12 13:57:19 2025 +0100 add_hardwired_spec for ld-linux-x86-64.so.2 memcmp With RPATH processing ld.so compiled for x86-64-v3 uses an optimized avx2 memcmp (bcmp) which causes (false postive) memcheck invalid reads of size 32 warnings. Fix this my adding a hardwire spec with a simpler memcmp for ld-linux-x86-64.so.2. https://bugs.kde.org/show_bug.cgi?id=501348 Authored-by: Florian Weimer <fweimer@redhat.com> (cherry picked from commit 9ffdeb4927b8505cc5a9ea54f608f4972166bb0e) |