Bug 289845 - aarch64 libc timingsafe_memcmp has an ELF symbol size of 0
Summary: aarch64 libc timingsafe_memcmp has an ELF symbol size of 0
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Robert Clausecker
URL: lib/libc/aarch64/string
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-25 19:28 UTC by Paul Floyd
Modified: 2025-09-27 08:55 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2025-09-25 19:28:47 UTC
I'm seeing errors with Valgrind on 15.3-ALPHA2

These are due to Valgrind not redirecting timingsafe_memcmp. Here is an extract of the output of valgrind --trace-symtab=yes for libc.so timingsafe_bcmp included for comparison.

raw symbol [ 122]: GLO FUN : svma 0x0000166c08, sz  348  timingsafe_bcmp
    rec(t) [ 122]:            val 0x0004a47c08, sz  348  timingsafe_bcmp

raw symbol [1355]: GLO FUN : svma 0x0000166d64, sz    0  timingsafe_memcmp
    ignore -- size=0: timingsafe_memcmp

You can see the same thing with readelf:

readelf -s /lib/libc.so.7 | grep timingsafe_m

  1355: 0000000000166d64     0 FUNC    GLOBAL DEFAULT    14 timingsafe_memcmp

Valgrind does not accept functions with a zero size for redirection, and this is causing errors. Probably not too serious or frequent.

I see the cause of the error

https://github.com/freebsd/freebsd-src/blob/main/lib/libc/aarch64/string/timingsafe_memcmp.S

There is a copy and paste error at the end, using END(timingsafe_bcmp) instead of END(timingsafe_memcmp)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2025-09-25 20:43:58 UTC
(In reply to Paul Floyd from comment #0)
15.3-ALPHA2 doesn't exist yet.  Which version are you running?
Comment 2 Paul Floyd 2025-09-26 04:45:11 UTC
I meant 15.0-ALPHA2. 

I haven’t looked at the git history to see when timingsafe_mempcmp.S was added. All versions since then will be affected. I guess that it is only on the 15 and16 branches as I’ve not seen it on 14.3-RELEASE.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-09-26 09:06:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7feac79331bc8c77e2f8a3e71d6ea087fa17b61d

commit 7feac79331bc8c77e2f8a3e71d6ea087fa17b61d
Author:     Paul Floyd <pjfloyd@wanadoo.fr>
AuthorDate: 2025-09-25 19:49:08 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2025-09-26 09:04:54 +0000

    libc/aarch64: fix ELF size of timingsafe_memcmp

    Looks like a copy and paste error.
    The ELF size of 0 prevents Valgrind from redirecting this function.

    PR:             289845
    Reviewed by:    fuz
    Fixes:          3f224333af163d5fcd7547a20993dcf18f19076c
    See also:       https://bugs.kde.org/show_bug.cgi?id=509406
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1854
    MFC after:      1 day
    Event:          EuroBSDcon 2025

 lib/libc/aarch64/string/timingsafe_memcmp.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 4 Robert Clausecker freebsd_committer freebsd_triage 2025-09-26 09:06:41 UTC
Good catch!
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-09-27 08:52:10 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=510a9e3885e7852e420bea01dcb0247827ea932c

commit 510a9e3885e7852e420bea01dcb0247827ea932c
Author:     Paul Floyd <pjfloyd@wanadoo.fr>
AuthorDate: 2025-09-25 19:49:08 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2025-09-27 08:51:33 +0000

    libc/aarch64: fix ELF size of timingsafe_memcmp

    Looks like a copy and paste error.
    The ELF size of 0 prevents Valgrind from redirecting this function.

    PR:             289845
    Reviewed by:    fuz
    Fixes:          3f224333af163d5fcd7547a20993dcf18f19076c
    See also:       https://bugs.kde.org/show_bug.cgi?id=509406
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1854
    MFC after:      1 day
    Event:          EuroBSDcon 2025

    (cherry picked from commit 7feac79331bc8c77e2f8a3e71d6ea087fa17b61d)

 lib/libc/aarch64/string/timingsafe_memcmp.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 Robert Clausecker freebsd_committer freebsd_triage 2025-09-27 08:55:17 UTC
Fixed and MFC'ed!
Thank you for your contribution.