Skip to content

Commit

Permalink
Add stack clash protection to the WITH_SSP flag
Browse files Browse the repository at this point in the history
  • Loading branch information
netchild committed Jan 25, 2025
1 parent 7bb9ba6 commit f934e62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions share/man/man7/mitigations.7
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd July 23, 2024
.Dd January 25, 2025
.Dt MITIGATIONS 7
.Os
.Sh NAME
Expand Down Expand Up @@ -244,9 +244,13 @@ and it is possible that some applications may not function correctly.
.Fx
supports stack overflow protection using the Stack Smashing Protector
.Pq SSP
compiler feature.
compiler feature,
and stack clash protection.
In userland, SSP adds a per-process randomized canary at the end of every stack
frame which is checked for corruption upon return from the function.
frame which is checked for corruption upon return from the function,
and stack probing in
.Dv PAGE_SIZE
chunks.
In the kernel, a single randomized canary is used globally except on aarch64,
which has a
.Dv PERTHREAD_SSP
Expand All @@ -264,7 +268,9 @@ When
.Va WITH_SSP
is enabled, which is the default, world is built with the
.Fl fstack-protector-strong
compiler option.
and
.Fl fstack-clash-protection
compiler options.
The kernel is built with the
.Fl fstack-protector
option.
Expand Down
2 changes: 1 addition & 1 deletion share/mk/bsd.sys.mk
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ CXXFLAGS.clang+= -Wno-c++11-extensions
FORTIFY_SOURCE?= 0
.if ${MK_SSP} != "no"
# Don't use -Wstack-protector as it breaks world with -Werror.
SSP_CFLAGS?= -fstack-protector-strong
SSP_CFLAGS?= -fstack-protector-strong -fstack-clash-protection
CFLAGS+= ${SSP_CFLAGS}
.endif # SSP
.if ${FORTIFY_SOURCE} > 0
Expand Down

0 comments on commit f934e62

Please sign in to comment.