Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
03e06eb
chore: revamp and add additional build hardening
RKNF404 Jun 22, 2025
8d77d1b
fix: assert
RKNF404 Jun 22, 2025
ccd32e4
chore: enable IBT and SHSTK via glibc tunables as well
RKNF404 Jun 22, 2025
81ebea4
fix
RKNF404 Jun 23, 2025
2130361
fix
RKNF404 Jun 23, 2025
3dc02ba
Update build-hardening.patch
RKNF404 Jun 23, 2025
4721c49
chore: only enable tunables on x86
RKNF404 Jun 23, 2025
53f43a1
fix: codacy
RKNF404 Jun 23, 2025
e3bdb84
fix
RKNF404 Jun 23, 2025
3bb3304
chore
RKNF404 Jun 24, 2025
3f0b16a
fix
RKNF404 Jun 24, 2025
ed98fa9
fix: force-ibt does not work
RKNF404 Jun 24, 2025
02d662b
chore: adjust CFI conditions
RKNF404 Jun 24, 2025
8bb87bd
fix: use permissive shadow stacks otherwise tabs crash
RKNF404 Jun 24, 2025
bc6add6
chore
RKNF404 Jun 24, 2025
d3c931b
chore: rebuild rust's std with CFI
RKNF404 Jun 24, 2025
91456b4
chore: merge CET protections
RKNF404 Jun 24, 2025
0bad179
fix: copy artifact
RKNF404 Jun 24, 2025
438c63e
fix: wtf
RKNF404 Jun 24, 2025
284b478
fix: don't build std
RKNF404 Jun 24, 2025
03219c3
feat: enable V8 CET
RKNF404 Jun 24, 2025
02cae22
Merge branch 'secureblue:live' into revamp-build-hardening
RKNF404 Jun 24, 2025
ebaff2a
fix: allow building with CET
RKNF404 Jun 24, 2025
9012d39
fix: proper patch path
RKNF404 Jun 24, 2025
1b7b3e9
test: disable rust hardening
RKNF404 Jun 24, 2025
0fe47ad
chore: re-enable CFI
RKNF404 Jun 25, 2025
2772e75
chore: re-enable SLS hardening for rust
RKNF404 Jun 25, 2025
2c449a5
fix: rust does not support SLS hardening
RKNF404 Jun 25, 2025
aa50f8b
fix: patch formation
RKNF404 Jun 25, 2025
00dc6af
fix
RKNF404 Jun 25, 2025
2408e45
chore: remove v8 CET
RKNF404 Jun 25, 2025
7a9b789
chore: update to a more stable state
RKNF404 Jun 26, 2025
dab98c1
Merge branch 'live' into revamp-build-hardening
RKNF404 Jun 26, 2025
bac59fa
docs: link to hardware CFI tunables
RKNF404 Jun 27, 2025
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
6 changes: 6 additions & 0 deletions build/trivalent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ declare -rx XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR"
declare -rx XAUTHORITY="$XAUTHORITY"
declare -rx DISPLAY="$DISPLAY"

# enable hardware CFI feature
# https://www.gnu.org/software/libc/manual/html_node/Hardware-Capability-Tunables.html
if [[ "$(arch)" == "x86_64" ]]; then
declare -rx GLIBC_TUNABLES="glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=permissive"
fi

# unify branding
declare -r CHROMIUM_NAME="@@CHROMIUM_NAME@@"

Expand Down
67 changes: 64 additions & 3 deletions patches/build-hardening.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 5898b8c54bef2..d924cec372c1a 100644
index 59942a3cf6..c80eadf2c0 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -371,6 +371,10 @@ config("compiler") {
@@ -373,12 +373,18 @@ config("compiler") {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
- assert(is_android)
+ assert(is_android || is_linux)

scs_parameters = [
"-fsanitize=shadow-call-stack",
- "-fno-stack-protector",
+ "-fstack-protector-strong",
]
+
+ # fixed-x18 may be required for ShadowCallStack
+ if (is_linux) {
+ scs_paramaters += [ "-ffixed-x18" ]
+ }
+
cflags += scs_parameters
ldflags += scs_parameters
} else {
@@ -400,6 +406,11 @@ config("compiler") {
}
}

+ if (is_linux) {
+ cflags += [ "-fstack-clash-protection" ]
+ cflags += [ "-mharden-sls=all" ]
+ }
+
if (use_lld) {
ldflags += [ "-fuse-ld=lld" ]
if (lld_path != "") {
@@ -2059,7 +2063,7 @@ config("chromium_code") {
@@ -2282,7 +2293,7 @@ config("chromium_code") {
# Non-chromium code is not guaranteed to compile cleanly with
# _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
# disabled, so only do that for Release build.
Expand All @@ -22,3 +44,42 @@ index 5898b8c54bef2..d924cec372c1a 100644

# ChromeOS's toolchain supports a high-quality _FORTIFY_SOURCE=3
# implementation with a few custom glibc patches. Use that if it's
@@ -3363,8 +3374,14 @@ buildflag_header("compiler_buildflags") {
}

config("cet_shadow_stack") {
- if (enable_cet_shadow_stack && is_win) {
+ if (enable_cet_shadow_stack) {
assert(target_cpu == "x64")
- ldflags = [ "/CETCOMPAT" ]
+ if (is_win) {
+ ldflags = [ "/CETCOMPAT" ]
+ } else if (is_linux) {
+ cflags = [ "-fcf-protection=full" ]
+ ldflags = [ "-fcf-protection=full", "-Wl,-z,shstk" ]
+ rustflags = [ "-Zcf-protection=full" ]
+ }
}
}
diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn
index 131bb71d1d..b584e8d547 100644
--- a/build/config/linux/BUILD.gn
+++ b/build/config/linux/BUILD.gn
@@ -20,11 +20,13 @@ config("compiler") {
cflags = []
asmflags = []
if (arm_control_flow_integrity == "standard") {
- cflags += [ "-mbranch-protection=standard" ]
- asmflags += [ "-mbranch-protection=standard" ]
+ cflags += [ "-mbranch-protection=pac-ret+leaf+bti" ]
+ asmflags += [ "-mbranch-protection=pac-ret+leaf+bti" ]
+ rustflags += [ "-Zbranch-protection=bti,pac-ret,leaf" ]
} else if (arm_control_flow_integrity == "pac") {
- cflags += [ "-mbranch-protection=pac-ret" ]
- asmflags += [ "-mbranch-protection=pac-ret" ]
+ cflags += [ "-mbranch-protection=pac-ret+leaf" ]
+ asmflags += [ "-mbranch-protection=pac-ret+leaf" ]
+ rustflags += [ "-Zbranch-protection=pac-ret,leaf" ]
}
}
}