depends: harden Linux and Windows packages #36649

pull fametrano wants to merge 1 commits into bitcoin:master from fametrano:depends-hardening-flags changing 2 files +2 −2
  1. fametrano commented at 12:51 PM on October 24, 2026: none

    The depends packages are built without _FORTIFY_SOURCE and -fstack-clash-protection unless the compiler turns them on by default. CMakeLists.txt adds both to core_interface only. The release flags in depends/hosts/linux.mk and mingw32.mk are only -O2. Debian's GCC turns on neither, so sqlite, libzmq and capnp are built without them. #27118 built libevent with -D_FORTIFY_SOURCE=3, but libevent is no longer in depends.

    I add -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection to linux_release_CFLAGS, and the two _FORTIFY_SOURCE flags to mingw32_release_CFLAGS. Through toolchain.cmake the flags also reach the main build. There secp256k1, which does not link core_interface, gets them too. #36534 does that for every build. Qt 6.8 already adds both flags to its own targets on Linux. I leave macOS alone, because its SDK already fortifies. Apple clang 21 ignores -fstack-clash-protection on arm64. I did not add -fcf-protection (see #30685).

    In a debian:trixie container (GCC 14.2, aarch64) I built depends with NO_QT=1 and then Core, on master and on this branch. On master no library in depends calls a _chk function. On this branch libsqlite3.a, libzmq.a, libkj.a, libkj-async.a and libcapnpc.a do. secp256k1 is compiled with the new flags. All 380 ctest tests pass, and so do interface_zmq.py, wallet_basic.py and wallet_backup.py. With HOST=x86_64-w64-mingw32ucrt (mingw-w64 12), libsqlite3.a calls __memcpy_chk and bitcoind.exe links. I have not run a Guix build or built Qt.

    This is one of several PRs from a large audit of Bitcoin Core that I did with the help of LLM tools. The audit produced its evidence all at once, which is why the PRs arrive together. I understand each change fully and will answer review questions myself.

  2. depends: harden Linux and Windows packages
    The release flags for Linux and Windows packages are only -O2. So
    sqlite, libzmq, capnp and the others are built without
    _FORTIFY_SOURCE, and on Linux without -fstack-clash-protection,
    unless the compiler turns them on by default. Debian's GCC turns on
    neither.
    
    Add -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 to linux_release_CFLAGS and
    mingw32_release_CFLAGS, and -fstack-clash-protection to
    linux_release_CFLAGS. CMakeLists.txt adds the same flags to
    core_interface. toolchain.cmake passes them to the main build as well,
    so secp256k1 also gets them in depends builds.
    
    Leave macOS alone: its SDK already fortifies, and Apple clang ignores
    -fstack-clash-protection on arm64.
    4d9443b461
  3. DrahtBot added the label Build system on Oct 24, 2026
  4. DrahtBot commented at 12:51 PM on October 24, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. sipa commented at 12:58 PM on October 24, 2026: member
  6. maflcko commented at 10:22 AM on October 26, 2026: member

    I have not run a Guix build

    In theory this could make sense, but the pull misses the important part.

    Also, the pull description is written by an LLM and thus violates https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md

  7. fanquake commented at 10:25 AM on October 26, 2026: member

    I did not add -fcf-protection (see #30685).

    if you've seen #30685, then you'd know the same rationale for not adding the flags in that PR, applies here? Concept NACK.


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-10-26 15:51 UTC

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