Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 913339 - Consider -ftrivial-auto-var-init=zero for future hardened profiles?
Summary: Consider -ftrivial-auto-var-init=zero for future hardened profiles?
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-30 09:19 UTC by Sam James
Modified: 2023-09-01 17:05 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
enable-ftrivial-auto-var-init-zero-by-default.patch (file_913339.txt,577 bytes, patch)
2023-09-01 12:10 UTC, Sam James
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-30 09:19:57 UTC
* Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gcc-12/+bug/1972043
* Debian: https://bugs.debian.org/1010685
* General: https://stackoverflow.com/questions/75061576/using-ftrivial-auto-var-init-to-guarantee-the-initialization-of-padding-bytes

* LLVM: https://discourse.llvm.org/t/making-ftrivial-auto-var-init-zero-a-first-class-option/55143/40
* LLVM: https://lists.llvm.org/pipermail/cfe-dev/2020-April/065221.html

I don't think this is likely to ever be a candidate for non-hardened, as it's more expensive - like -D_GLIBCXX_ASSERTIONS is. But what are the hardened profiles for if not bits like this? :)

Fortunately, the =0 init is cheaper than with a pattern.

Apparently ChromiumOS is using zero as well, but I haven't verified that.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-30 09:23:42 UTC
kees, maskray: I'd welcome your opinions on if it's worth exploring this for our Hardened profiles yet or not (note that I've done 0 test builds over the repositories yet).
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-30 09:31:24 UTC
(Note that I don't plan on the similarly-named-but-rather-different -fzero-call-used-regs=all given https://dustri.org/b/paper-notes-clean-the-scratch-registers-a-way-to-mitigate-return-oriented-programming-attacks.html).
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-01 12:10:22 UTC
Created attachment 869126 [details, diff]
enable-ftrivial-auto-var-init-zero-by-default.patch

Attached trivial hacky patch for anyone who wants to test.
Comment 4 emacsray 2023-09-01 17:05:16 UTC
Sounds great! https://reviews.freebsd.org/D27131 provides choices WITH_INIT_ALL_ZERO/WITH_INIT_ALL_PATTERN

Android platform defaulted to -ftrivial-auto-var-init=zero since 2020-05
https://r.android.com/c/platform/build/soong/+/1310902/2/cc/config/global.go

https://chromium.googlesource.com/chromium/src/+/refs/heads/main/build/config/compiler/BUILD.gn#139 defaults to pattern (non-official-build-of-Android non-ChromeOS) or zero (ChromeOS)