Page MenuHomeFreeBSD

Add AUTO_VAR_INIT to ensure the stack it initialised
Needs ReviewPublic

Authored by andrew on Feb 4 2020, 1:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 4:57 PM
Unknown Object (File)
Dec 20 2023, 2:24 AM
Unknown Object (File)
Nov 6 2023, 2:07 AM
Unknown Object (File)
Nov 3 2023, 3:58 AM
Unknown Object (File)
Oct 24 2023, 9:34 AM
Unknown Object (File)
Oct 12 2023, 12:53 AM
Unknown Object (File)
Oct 5 2023, 12:59 AM
Unknown Object (File)
Oct 1 2023, 3:59 AM

Details

Reviewers
emaste
manu
Summary

AUTO_VAR_INIT adds a flag to clang to ensure the stack is initialised.
It will write a known value to the stack before it is used to ensure
no previous stack memory is leaked across functions.

This is currently disabled by default on amd64 as it seems to call memset
before ifunc resolution has occurred.

On a 4 core arm64 CPU no significant difference in kernel build sys and
real timd and only a 0.06% increase in user time was observed when this
was enabled.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 29158
Build 27092: arc lint + arc unit

Event Timeline

emaste added inline comments.
sys/conf/kern.pre.mk
149

At some point we need a better way to handle this for all such options

I would prefer that we do not triggered this option at all, this is no longer a C language.

I am not even sure is this a useful debugging technique or not.

It's not intended to be a debugging tool, it's to stop leaking from kernel stack, e.g. CVE-2019-15875 https://lists.freebsd.org/pipermail/freebsd-announce/2020-January/001926.html

The llvm review that added the option has more details on how it works: https://reviews.llvm.org/D54604