Page MenuHomeFreeBSD

libc: Avoid defining memcpy() as a macro under FORTIFY_SOURCE
Needs ReviewPublic

Authored by markj on Aug 10 2026, 7:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 11, 3:03 PM
Unknown Object (File)
Mon, Oct 5, 1:05 AM
Unknown Object (File)
Sun, Oct 4, 2:23 AM
Unknown Object (File)
Thu, Oct 1, 4:08 AM
Unknown Object (File)
Mon, Sep 28, 7:39 PM
Unknown Object (File)
Mon, Sep 28, 7:39 PM
Unknown Object (File)
Mon, Sep 28, 6:44 AM
Unknown Object (File)
Fri, Sep 18, 4:13 PM
Subscribers

Details

Reviewers
kevans
Summary

Otherwise it is impossible to make certain memcpy() usages work, e.g.,
memcpy(dst, &(struct foo){1, 2}, sizeof(*dst)) fails to compile
because a macro parameter can't contain a comma. This arises when
compiling graphics/mesa-libs with FORTIFY_SOURCE enabled.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75499
Build 72382: arc lint + arc unit

Event Timeline

markj requested review of this revision.Aug 10 2026, 7:14 PM

@kevans do you have any time to look at this?

It should probably be noted that this effectively orphans the corresponding __*_chk symbols in libc/secure. I don't think that's a bad thing or that we should stop exposing a default version for them, it just means that we won't emit references to them with our own implementation.

include/ssp/string.h
123–126

I think we probably want __ssp_redirect_raw_impl for these two like we do in <ssp/wchar.h>; the easy __ssp_redirect* loses runtime overlap checks for src/dst that are currently done by the __*_chk symbols