stack-protector flag for Windows-builds #1074

issue Diapolo opened this issue on April 10, 2012
  1. Diapolo commented at 10:53 AM on April 10, 2012: none

    I tried enabling the -fstack-protector flag and compiled Bitcoin-Qt on Windows. The resulting executable works, even the use of "-fstack-protector-all" caused no problems, so I'm asking to re-evaluate enabling of that flag in the Windows-builds.

    A brief description of the feature can be found here: http://www.research.ibm.com/trl/projects/security/ssp/

  2. laanwj commented at 10:59 AM on April 10, 2012: member

    Yes, I think it's a good idea to enable it for all operating systems unless there is a critical reason not to.

  3. gavinandresen commented at 12:55 PM on April 10, 2012: contributor

    My memory is fuzzy, but was there some issue with enabling it for mingw and/or cross-compiles?

  4. Diapolo commented at 1:14 PM on April 10, 2012: none

    I compile under Windows with Qt Creator and mingw 4.4, which works. Perhaps one should test it with Gitian ;)?

  5. laanwj commented at 5:58 PM on April 11, 2012: member

    I somehow don't think we added this warning just for fun:

    QMAKE_LFLAGS += -fstack-protector
    # do not enable this on windows, as it will result in a non-working executable!
    

    I now remember that @thebluematt added this after the gitian-produced executable frustratingly didn't work. Might be that the underlying issue is solved but we should be really careful.

  6. TheBlueMatt commented at 6:02 PM on April 11, 2012: member

    IIRC it was an issue with building using Ubuntu's i586-mingw32msvc-* compiling, though it may have worked on some other distro mingw packages, and possibly also on windows mingw builds. Though this causes issues for gitian, maybe it has been fixed in post-lucid Ubuntus?

  7. Diapolo commented at 9:19 PM on April 11, 2012: none

    Why not give it a try? If the resulting Windows executable is messed up disable the flag again and perhaps add when we last tried it and if it works it would be a nice security benefit for Windows users :).

  8. Diapolo commented at 2:36 PM on June 1, 2012: none

    Anyone willing to build an executable with this enabled? I'm glad to try it out on Windows ;).

  9. Diapolo commented at 12:06 PM on July 10, 2012: none

    Is there any way to enable ASLR with MinGW for the bitcoin-qt.exe? Even if we are unable to ship the official client with DEP / ASLR enabled, I would like to know how I can do this ^^.

  10. laanwj commented at 12:11 PM on July 10, 2012: member

    Pass QMAKE_CXXFLAGS=-fstack-protector QMAKE_LFLAGS=-fstack-protector on the qmake command line

  11. Diapolo commented at 12:27 PM on July 10, 2012: none

    @laanwj Even passing -fstack-protector-all does not set the ASLR enabled flag in the resulting executable (checked via ProcessExplorer - Sysinternals tool).

  12. Diapolo commented at 1:18 PM on July 10, 2012: none

    Nice find, I'll test this out with my build, perhaps a patch can be added later to enabled this for the official client.

  13. Diapolo commented at 6:44 AM on July 11, 2012: none

    I made positive progress on the mitigation techniques on Windows, but as long as the core devs don't care to (re-)test the -fstack-protector or even better -fstack-protector-all flag and take this issue more serious I don't mind creating a new patch ;).

    Everytime Gavin is talking about security and I have a strong belief such compiler/linker hardening is one very important aspect of making the Bitcoin client more secure!

    <pre> -fstack-protector Emit extra code to check for buffer overflows, such as stack smashing attacks. This is done by adding a guard variable to functions with vulnerable objects. This includes functions that call alloca, and functions with buffers larger than 8 bytes. The guards are initialized when a function is entered and then checked when the function exits. If a guard check fails, an error message is printed and the program exits. -fstack-protector-all Like -fstack-protector except that all functions are protected. </pre>

  14. Diapolo commented at 12:17 PM on July 16, 2012: none

    @luke-jr I know you have that test-next project, which uses the official build-process ... could you try to enable the stack-protection on Windows with -fstack-protector-all!? I will be glad to test it. This needs to be looked at! We can be happy there are currently no known attacks on the client that use a buffer-overflow, but this will for sure help mitigate, if that happens in the future.

    Do you need a pull?

  15. luke-jr commented at 4:33 PM on July 16, 2012: member

    I seem to recall the linker failed with stack protector, but maybe I was doing something wrong...

  16. Diapolo commented at 5:16 PM on July 16, 2012: none
  17. Diapolo commented at 5:22 PM on July 18, 2012: none

    @TheBlueMatt Could you give Jenkins a try on this? I would like to test a Gitian or static-compiled bitcoin-qt.exe to verify if it's usable now :).

  18. Diapolo commented at 9:49 AM on August 14, 2012: none

    #1674 is now the pull for this wish ;).

  19. laanwj commented at 8:46 AM on September 21, 2012: member

    Let's keep the discussion there, closing this

  20. laanwj closed this on Sep 21, 2012

  21. suprnurd referenced this in commit 8aaa8a22b0 on Dec 5, 2017
  22. sanch0panza referenced this in commit f2678b29cb on May 17, 2018
  23. lateminer referenced this in commit 54ff8bd3da on Nov 7, 2019
  24. MarcoFalke locked this on Sep 8, 2021
  25. DrahtBot added the label CI failed on Apr 5, 2023
  26. MarcoFalke removed the label CI failed on Apr 5, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 03:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me