Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ updates:
default-days: 7
commit-message:
prefix: build
# pybind11 stays at 2.x, and pybind11-stubgen at the version that bin/lint_bindings.py is made for. cmake is only the lowest version that
# the build asks for in pyproject.toml, and a bump of it would make the module build with nothing older
ignore:
- dependency-name: pybind11
update-types: ["version-update:semver-major"]
- dependency-name: pybind11-stubgen
update-types: ["version-update:semver-major"]
- dependency-name: cmake
groups:
build:
patterns:
Expand Down
8 changes: 5 additions & 3 deletions bin/check_elf_hardening.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# noble amd64 : 27284 calls to __stack_chk_fail, 82737 endbr64, 15 _chk functions imported, no full RELRO, an executable stack (GNU_STACK RWE)
# with the flags of bin/hardening_flags.sh and CMakeLists.txt (run 43531387312, bookworm amd64): 6472 calls to __stack_chk_fail, 66916 endbr64,
# 12 _chk functions imported, 890 exports. There are fewer calls than before because --gc-sections now drops the code that nothing reaches.
# The minimums are about half of the build with the flags. The one of aarch64 was not measured.
# aarch64 (run 43552349699, trixie and bookworm): 7594 and 6446 calls to __stack_chk_fail, 12 _chk functions imported, 890 and 889 exports
# The minimums are about half of the build with the flags.
#
# The exports are PyInit_monero, the names that the linker adds, the C++ symbols of Boost and the standard library, and the typeinfo: the
# headers of Boost mark many of their classes visible (BOOST_SYMBOL_VISIBLE), namespace std is visible, and pybind11 makes the typeinfo of the
Expand All @@ -27,7 +28,7 @@ library="${1:?usage: check_elf_hardening.sh monero.cpython-312-x86_64-linux-gnu.

MIN_FORTIFY_IMPORTS=8
MIN_CANARY_CALLS_X86_64=3000
MIN_CANARY_CALLS_AARCH64=1000
MIN_CANARY_CALLS_AARCH64=3000
MIN_LANDING_PADS_X86_64=20000

failed=0
Expand Down Expand Up @@ -64,7 +65,8 @@ echo "FORTIFY functions imported: $fortify_imports (minimum $MIN_FORTIFY_IMPORTS
[ "$fortify_imports" -ge "$MIN_FORTIFY_IMPORTS" ] || fail "only $fortify_imports _chk functions are imported, FORTIFY_SOURCE is not on in most of the code"

# a python module exports PyInit_monero and nothing else. The linker adds a few names of its own to some shared objects
exports=$(awk 'NF >= 8 && $1 ~ /^[0-9]+:$/ && $7 != "UND" { sub(/@.*/, "", $8); print $8 }' <<< "$dynamic_symbols" | sort -u)
# the local symbols are not exports: on aarch64 the dynamic table also has the sections, named .data and .init
exports=$(awk 'NF >= 8 && $1 ~ /^[0-9]+:$/ && $7 != "UND" && $5 != "LOCAL" { sub(/@.*/, "", $8); print $8 }' <<< "$dynamic_symbols" | sort -u)
# the mangled names of Boost and of the standard library: the symbol itself, its guard variable, vtable, typeinfo and thunks, and the local statics of a function
visible_cpp='^_ZT[IS]|^_Z(GV|TV|TI|TS|TT|GR)?Z?(Th[0-9n]+_|Tv[0-9n]+_[0-9n]+_)?(N[KVr]*)?(5boost|St|9__gnu_cxx)'
unexpected=$(grep -Evx 'PyInit_monero|_init|_fini|_edata|_end|__bss_start' <<< "$exports" | grep -Ev "$visible_cpp" || true)
Expand Down
6 changes: 3 additions & 3 deletions bin/check_macho_hardening.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#
# Apple clang turns the stack protector on (-fstack-protector-strong), so what is checked is that the module imports the guard and the handler of
# the canary, and that many functions call the handler. The count is the number of calls to ___stack_chk_fail in the code, a call for each function
# that has a canary. The minimum was not measured on this module: monero-c, which links the same libraries of monero-project, has about 3400, and
# a module built with no stack protector, or whose libraries were, has a handful. It is a guess, the first run of the check prints the real number.
# that has a canary. The module of the build of CI has 3018 of them on arm64 (macos-15) and 2864 on x86_64 (macos-15-intel), and the minimum is
# about half of that: a module built with no stack protector, or whose libraries were, has a handful.
#
# The exports are _PyInit_monero and nothing else, which the linker is asked for with -exported_symbol in CMakeLists.txt.
set -euo pipefail
export LC_ALL=C

library="${1:?usage: check_macho_hardening.sh monero.cpython-314-darwin.so}"
MIN_CANARY_CALLS=500
MIN_CANARY_CALLS=1400

failed=0
fail() {
Expand Down
Loading