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)
Sat, Sep 21, 12:01 PM
Unknown Object (File)
Sat, Sep 21, 6:08 AM
Unknown Object (File)
Fri, Sep 20, 7:43 PM
Unknown Object (File)
Wed, Sep 18, 12:09 AM
Unknown Object (File)
Sun, Sep 8, 12:30 PM
Unknown Object (File)
Sat, Sep 7, 5:39 PM
Unknown Object (File)
Aug 21 2024, 11:19 AM
Unknown Object (File)
Aug 12 2024, 2:35 AM

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