Closed Bug 1511073 Opened 6 years ago Closed 4 years ago

Enable stack protector on mingw-clang builds

Categories

(Core :: Security, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox-esr68 --- fixed
firefox65 --- wontfix
firefox73 --- fixed

People

(Reporter: gcp, Assigned: tjr)

References

(Blocks 4 open bugs)

Details

Attachments

(2 files)

mingw-clang has an exclusion due to this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1503589#c18

We should remove the exclusion when the toolchain is fixed.
Blocks: 1330608
Depends on: 1503589
Blocks: 1359928

Quoting from bug 1503589:

Here is how llvm-mingw toolchain builds it:
https://github.com/mstorsjo/llvm-mingw/blob/master/build-libssp.sh
We could do the same in our toolchain build script (we don't need .dll version, just static library, so it's a bit simpler than tat) or even use llvm-mingw script for that.

So, I tried a bunch of things (including building the libssp libs as llvm-mingw does it). But in all cases it turns out that a) we need the .dll version as all the binaries seem to get linked against it. And b) the resulting bundles crash both on 64bit and 32bit Windows systems.

On the Firefox side I only removed the mingw-w64-clang exclusion for stack protection support.

I won't have time to look at it closer before we switch to ESR 68 at the end of October.

So, I tried a bunch of things (including building the libssp libs as llvm-mingw does it). But in all cases it turns out that a) we need the .dll version as all the binaries seem to get linked against it.

If you keep both libssp.dll.a and libssp.a from the build, you'll probably get it linked dynamically. But just get rid of libssp.dll.a and it should end up linking it statically instead. (Or just don't build it - this commit shows what I changed when I made it available as a DLL: https://github.com/mstorsjo/llvm-mingw/commit/d3ec443f9248a83cfbdd4bef311a7191d6acc311#diff-61ff93e7b0a019a6b2791677ea7c6770)

And b) the resulting bundles crash both on 64bit and 32bit Windows systems.

Now that's surprising though. (VLC builds with stack protector enabled via -fstack-protector-strong, with these libs, and runs fine in my tests.)

(In reply to Martin Storsjö from comment #2)

So, I tried a bunch of things (including building the libssp libs as llvm-mingw does it). But in all cases it turns out that a) we need the .dll version as all the binaries seem to get linked against it.

If you keep both libssp.dll.a and libssp.a from the build, you'll probably get it linked dynamically. But just get rid of libssp.dll.a and it should end up linking it statically instead. (Or just don't build it - this commit shows what I changed when I made it available as a DLL: https://github.com/mstorsjo/llvm-mingw/commit/d3ec443f9248a83cfbdd4bef311a7191d6acc311#diff-61ff93e7b0a019a6b2791677ea7c6770)

And b) the resulting bundles crash both on 64bit and 32bit Windows systems.

Now that's surprising though. (VLC builds with stack protector enabled via -fstack-protector-strong, with these libs, and runs fine in my tests.)

Both a) and b) go away by just copying libssp.a and libssp_nonshared.a, leaving the .dll.a out, thanks! So, we are good for now to test this in our next Tor Browser alpha release I think. (I just copied the libs over from mingw-w64/gcc which we need to build anyway for other parts for Tor Browser).

Assignee: nobody → tom
Pushed by tritter@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8483ffceb35b
Enable stack protector for MinGW build r=dmajor
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73

[Approval Request Comment]
If this is not a sec:{high,crit} bug, please state case for ESR consideration:
Build improvements to the mingw-clang build to reach parity with Tor Browser's current build

User impact if declined: The mingw-clang build on esr68 won't match Tor's. (They use stack protector)

Fix Landed on Version: Nightly 12/10

Risk to taking this patch (and alternatives if risky): The mingw-clang build might break.

Note: Land Bug 1601701 in esr68 before this one.

Attachment #9115224 - Flags: approval-mozilla-esr68?
Comment on attachment 9115224 [details] [diff] [review]
Bug 1511073 - Enable Stack protector on mingw-clang builds (esr68)

mingw build change for Tor browser parity. NPOTB for mainline Firefox ESR. Approved for 68.4esr.
Attachment #9115224 - Flags: approval-mozilla-esr68? → approval-mozilla-esr68+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: