Page MenuHomeFreeBSD

OpenSSL: Link with -znoexecstack when using ld.bfd.
AbandonedPublic

Authored by jhb on Jul 19 2023, 6:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 23, 6:36 AM
Unknown Object (File)
Apr 25 2024, 3:50 PM
Unknown Object (File)
Jan 17 2024, 8:20 PM
Unknown Object (File)
Dec 20 2023, 6:28 AM
Unknown Object (File)
Dec 12 2023, 4:18 AM
Unknown Object (File)
Oct 31 2023, 1:29 AM
Unknown Object (File)
Sep 24 2023, 4:12 PM
Unknown Object (File)
Sep 24 2023, 4:10 PM

Details

Reviewers
emaste
Summary

ld.bfd >= 2.39 emits warnings if input object files do not have
note.GNU-stack annotations requesting a non-executable stack. It is
not feasible to patch all of the assembly files from OpenSSL to add
this annotation as a local patch, so tell the linker to assume the
stack is non-executable instead.

Diff Detail

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

Event Timeline

jhb requested review of this revision.Jul 19 2023, 6:31 PM

This fixes linking libcrypto.so with GCC 12.

Is this actually an openssl bug, generating these files without the annotation? (E.g., upstream build infra thinks they are required only on Linux?)

I think I'd rather we just set it in LDFLAGS (also for lld)

(But no objection to this as an immediate-term fix)

This revision is now accepted and ready to land.Jul 19 2023, 6:56 PM

Yes, OpenSSL will care once Linux distributions upgrade to ld.bfd 2.39 and presumably they will fix it at some point.

However, I think LLD just doesn't care and always assumes -znoexectsack on FreeBSD. Arguably we should just globally add -Wl,-znoexecstack to LDFLAGS for bfd instead of patching it piecemeal.

From lld's docs, "Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security."

Arguably we should just globally add -Wl,-znoexecstack to LDFLAGS for bfd instead of patching it piecemeal.

Yeah, I'd be happy to have that change go in.

From lld's docs, "Some default settings have been tuned for the 21st century. For example, the stack is marked as non-executable by default to tighten security."

Arguably we should just globally add -Wl,-znoexecstack to LDFLAGS for bfd instead of patching it piecemeal.

Yeah, I'd be happy to have that change go in.

I've tested this as an alternative and posted it as D41120