CET is Intelβs Control-flow Enforcement Technology.
The current GCC implementation of the -fcf-protection
option is based on CET for x86_64-linux-gnu
.
However, on the master branch @ d79ea809d28197b1b4e3748aa1715272b53601d0, the release binaries are not marked as CET-enabled:
0$ env HOSTS=x86_64-linux-gnu ./contrib/guix/guix-build
1$ tar -xf guix-build-d79ea809d281/output/x86_64-linux-gnu/bitcoin-d79ea809d281-x86_64-linux-gnu.tar.gz
2$ readelf -n bitcoin-d79ea809d281/bin/bitcoind | grep -A 5 "\.note\.gnu\.property"
3Displaying notes found in: .note.gnu.property
4 Owner Data size Description
5 GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
6 Properties: x86 feature used: x86, x87, XMM, YMM, XSAVE
7 x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3
This occurs because not all object files, including those from the depends and the secp256k1
subtree, have the required properties.
This PR resolves the issue by explicitly enabling -fcf-protection=full
for all object files, which will be beneficial for all targets, not just x86_64-linux-gnu
.
With this PR:
0$ env HOSTS=x86_64-linux-gnu ./contrib/guix/guix-build
1$ tar -xf guix-build-c5bed747e6e9/output/x86_64-linux-gnu/bitcoin-c5bed747e6e9-x86_64-linux-gnu.tar.gz
2$ readelf -n bitcoin-c5bed747e6e9/bin/bitcoind | grep -A 6 "\.note\.gnu\.property"
3Displaying notes found in: .note.gnu.property
4 Owner Data size Description
5 GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0
6 Properties: x86 feature: IBT, SHSTK
7 x86 feature used: x86, x87, XMM, YMM, XSAVE
8 x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3
Please note Properties: x86 feature: IBT, SHSTK
.
A runtime check on Ubuntu 24.04 (GLIBC 2.39):
0$ export GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK
1$ bitcoin-c5bed747e6e9/bin/bitcoind -printtoconsole=0 &
2$ cat /proc/$(cat .bitcoin/bitcoind.pid)/status | grep x86
3x86_Thread_features: shstk
4x86_Thread_features_locked: shstk wrss
As a follow-up, a check for the IBT
and SHSTK
can be added to the contrib/devtools/security-check.py
script.
Fixes #30677.