From nobody Sat Jan 25 13:08:26 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YgFNp4qr3z5lKFJ; Sat, 25 Jan 2025 13:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YgFNp49lrz3vGT; Sat, 25 Jan 2025 13:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737810506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BwAoiZW+R18xuKuhwnEDcTt+QDCD/93WMBa7ewAMc2w=; b=HWTcy4GRDucufR6Ml2SY26dho1imRMCR9wvL+WvY/u2zT0zr/hFt2fzj2r+7tBENkm52fP YM84vjoUjFUryHfh5OVelddNelB1sPDUUbWrdBQhgfgAoLnhR17PCoHL+SKN25OYom4mCC HvI1+OZazVCS0qABN4IXMOe2JD//62OUYO2x9CEh9h4A5h0guKMBi4tg/p4pqC7ZTebdmU q0gNIukIZ434RcqtkOx8yicSCNSyAqfcAuXi1E7adH15Vlg14tQpbdwR/R9wP6uQP5eRjs UflS4LZFPD1gwo7NJhAzVXau7DaTXafMKzH1QOup7gpWIcNKbF+vUm+ou5LJ5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737810506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BwAoiZW+R18xuKuhwnEDcTt+QDCD/93WMBa7ewAMc2w=; b=Qg3YVO+zDcAAZObr++QuxfLDzgTK5YpvWZjZjCxan8wsVGkXAfKOV4FgTDh0LZcKJZi4lv 5LoguLIbV2fx9do6cY9k6OPmL7B5mrBYWWnWcLbHJ5XYFqDVkb8wECy+kQ2V/gO7YmK/kO jJHsGVKAC2pGS7bWU3JbI+yM1If9vqsfuzSkke/O5bWu7O+y1ZwG2Nc4sKu0yL+X120Xpl bPzgytJ2kQKhuc5xItDmGuk5VQJuyq8F+3vD3MLqpKhGg6WNbo/ejyELNpwHl0BEBWCSTU /wpPB/OpxQxv8wRbmpLzvcjN6xZkdNxarPgjUAe9mnULiSQxDTGa+1fDVqpBJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737810506; a=rsa-sha256; cv=none; b=k5ieFdaka88Ubw4nH+in3PGkwowF6pHsBN93FphnzjUcOMo4Fipv+XN8nWQ7yFJDR+kkDN 8DRNIEFaywLXtUbOCtk8D08PPVOMj0SlVhjQxoyRfBd9PC0YHsps0y8lhcHSqPgoGd6ujd PNnDDVq4ugLCFEx+cHbeNAKpzhuQtlkls1R4oCsMImXx1Xs/NozjEiDMf2yl0GdzgSDYAs lwHhqhPtd6lGGAJuwlMXftwaL1wujj7v+tlkRYy6m+0s/zxPkISUYKxqT/lFHvakRXJ9FE BOd9VYUuzEgR412DbDolepgAmFtB9g4vHO2jiRYEtzgoz2Fy4lUkUn0659UIVw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YgFNp3G4Qz1CPQ; Sat, 25 Jan 2025 13:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50PD8QjO042263; Sat, 25 Jan 2025 13:08:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50PD8Qsg042260; Sat, 25 Jan 2025 13:08:26 GMT (envelope-from git) Date: Sat, 25 Jan 2025 13:08:26 GMT Message-Id: <202501251308.50PD8Qsg042260@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Leidinger Subject: git: f934e629dc22 - main - Add stack clash protection to the WITH_SSP flag List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: netchild X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f934e629dc22b859efabd3cdebc23b63b04fa2bb Auto-Submitted: auto-generated The branch main has been updated by netchild: URL: https://cgit.FreeBSD.org/src/commit/?id=f934e629dc22b859efabd3cdebc23b63b04fa2bb commit f934e629dc22b859efabd3cdebc23b63b04fa2bb Author: Alexander Leidinger AuthorDate: 2025-01-25 12:43:39 +0000 Commit: Alexander Leidinger CommitDate: 2025-01-25 12:45:53 +0000 Add stack clash protection to the WITH_SSP flag Some background info availabe in: https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html https://developers.redhat.com/blog/2020/05/22/stack-clash-mitigation-in-gcc-part-3 https://blog.llvm.org/posts/2021-01-05-stack-clash-protection/ Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D48651 --- share/man/man7/mitigations.7 | 14 ++++++++++---- share/mk/bsd.sys.mk | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/share/man/man7/mitigations.7 b/share/man/man7/mitigations.7 index c487e4e1000b..4db6589cdcf1 100644 --- a/share/man/man7/mitigations.7 +++ b/share/man/man7/mitigations.7 @@ -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 @@ -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 @@ -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. diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 63774e857167..06f8e6e9fe78 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -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