From nobody Thu Aug 01 14:47:18 2024 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 4WZWyZ5sfkz5SswJ; Thu, 01 Aug 2024 14:47:18 +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 4WZWyZ2Ww1z4H97; Thu, 1 Aug 2024 14:47:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722523638; 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=UFQVIKFlMHbF8M15SGh0gpf1x0CvWpod1SnqqUvWszM=; b=ikauYvceQvCoyQboehBgzq55R8RI5JagL+AD4Zb7siMtHMX1rbFcuHwaOnMkgfTOG3AQ/8 6bzkaUZzK3EbF3QAUNXh2UgT9CtsBP/Nv1IjrWoZMWgQmvNivN3RLr2V9HsTtqIEEk69Lg wcnIsAIHV8mI5scdkY5XmQIE4f6q+YfOEeRKri7mMndQB34PZLwpKc9XIR+BwRLlaCUi+u DmjfL1UaljFkEdy7a7Zip9v51hmNp83WUIqHLa1Hd4aelzeDOVBHoFJIWMLqDoV+1Wsfya icRwybayl4EO9OqLn/YcCYBLooJrb72HAE8mgSx1s5kOn/Rckb9gGkzFa3l1fw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722523638; a=rsa-sha256; cv=none; b=R0jVOXzp+pYASDKbF2i0ZSaAZQQazDYomDFmv7IyeL8Qy0cW15M7MmLSUymqlzdvaVU1Al y4DsU2DZxGVoEPKnRrq7mlDN1zEUne8JN+mCToSKVQW3XAM5hcECvqw5oEtjzY8gGMRYiC ZaGNG0ClVUAJIpZAnfU2cs0Mw/Ap5FWkZNmTlLVCTqZnIquusbukrr0boGb0Pn5ZwQh+JS OMJ2IQ/nlKAZS/PcuqGyrWXt59b3+mV9hNj3MSj3D+UOlswYtQb0qP24MNsUeM4qgTeopO EounMZqs+slbbQy7w3pgRRyEVsbT1uUoElKH7qq7H0CbtGYnf9Yssp+jOsgeZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722523638; 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=UFQVIKFlMHbF8M15SGh0gpf1x0CvWpod1SnqqUvWszM=; b=WS8yz4S7fltI1oAzvZgP88WekvJUi6kuhKmpBhdB4kHNgZt9kFt9mR7MnQjdNJT5bU0GjV qN74C6uuzItMHeydiwybYgxqcBj+8MoPO9A2kWw+xPZMHPlw+c2Nl6gFqyHE1K8FmQTrzl Zho7MVcXOXx3UC0frzMRHnypCn+HkT9RaXYXYI5iGXcBdn2bsYyos30+tB34sFYR5z39pH Z+LCWOwW+L6aOmYZurUlHJc+2OlPbwYE5nwgdglINl8cK8C0ZBD4LkO/uK4d7vYTJJ3CSl shmNq03p+m6sRPrUzIdkWuhbqnhlbway6+8286nTrALapfe9AjbTko56ZlAckQ== 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 4WZWyZ1wspzppN; Thu, 1 Aug 2024 14:47:18 +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 471ElI8D040031; Thu, 1 Aug 2024 14:47:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471ElIKB040026; Thu, 1 Aug 2024 14:47:18 GMT (envelope-from git) Date: Thu, 1 Aug 2024 14:47:18 GMT Message-Id: <202408011447.471ElIKB040026@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 8b5df7e36afb - stable/14 - mitigations.7: move SSP documentation from security.7 to here 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 8b5df7e36afb64617a0ff9e3692207537472a262 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=8b5df7e36afb64617a0ff9e3692207537472a262 commit 8b5df7e36afb64617a0ff9e3692207537472a262 Author: Ed Maste AuthorDate: 2024-06-01 12:07:38 +0000 Commit: Ed Maste CommitDate: 2024-08-01 14:46:46 +0000 mitigations.7: move SSP documentation from security.7 to here Stack Smashing Protection (SSP) is a software vulnerability mitigation, and fits with this page. Add a note to the beginning of security.7 providing a more explicit cross reference to mitigations.7. Reviewed by: kevans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45435 (cherry picked from commit 297bb39b6f0fcfc5d571dc77008eb7acf138d279) --- share/man/man7/mitigations.7 | 82 +++++++++++++++++++++++++++++++++++++++++--- share/man/man7/security.7 | 10 +++++- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/share/man/man7/mitigations.7 b/share/man/man7/mitigations.7 index db1b3244862b..4beaa4c9f46c 100644 --- a/share/man/man7/mitigations.7 +++ b/share/man/man7/mitigations.7 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 31, 2024 +.Dd June 1, 2024 .Dt MITIGATIONS 7 .Os .Sh NAME @@ -54,8 +54,8 @@ Write XOR Execute page protection policy Relocation Read-Only (RELRO) .It Bind Now -.\".It -.\"Stack Smashing Protection (SSP) +.It +Stack Overflow Protection .It Supervisor Mode Memory Protection .It @@ -232,7 +232,81 @@ preventing attacks on the relocation table. Note that this results in a nonstandard Application Binary Interface (ABI), and it is possible that some applications may not function correctly. .\" -.\".Ss Stack Smashing Protection (SSP) +.Ss Stack Overflow Protection +.Fx +supports stack overflow protection using the Stack Smashing Protector +.Pq SSP +compiler feature. +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. +In the kernel, a single randomized canary is used globally except on aarch64, +which has a +.Dv PERTHREAD_SSP +.Xr config 8 +option to enable per-thread randomized canaries. +If stack corruption is detected, then the process aborts to avoid potentially +malicious execution as a result of the corruption. +SSP may be enabled or disabled when building +.Fx +base with the +.Xr src.conf 5 +SSP knob. +.Pp +When +.Va WITH_SSP +is enabled, which is the default, world is built with the +.Fl fstack-protector-strong +compiler option. +The kernel is built with the +.Fl fstack-protector +option. +.Pp +In addition to SSP, a +.Dq FORTIFY_SOURCE +implementation is supported up to level 2 by defining +.Va _FORTIFY_SOURCE +to +.Dv 1 +or +.Dv 2 +before including any +.Fx +headers. +.Fx +world builds can set +.Va FORTIFY_SOURCE +to provide a default value for +.Va _FORTIFY_SOURCE . +When enabled, +.Dq FORTIFY_SOURCE +enables extra bounds checking in various functions that accept buffers to be +written into. +These functions currently have extra bounds checking support: +.Bl -column -offset indent "snprintf" "memmove" "strncpy" "vsnprintf" "readlink" +.It bcopy Ta bzero Ta fgets Ta getcwd Ta gets +.It memcpy Ta memmove Ta memset Ta read Ta readlink +.It snprintf Ta sprintf Ta stpcpy Ta stpncpy Ta strcat +.It strcpy Ta strncat Ta strncpy Ta vsnprintf Ta vsprintf +.El +.Pp +.Dq FORTIFY_SOURCE +requires compiler support from +.Xr clang 1 +or +.Xr gcc 1 , +which provide the +.Xr __builtin_object_size 3 +function that is used to determine the bounds of an object. +This feature works best at optimization levels +.Fl O1 +and above, as some object sizes may be less obvious without some data that the +compiler would collect in an optimization pass. +.Pp +Similar to SSP, violating the bounds of an object will cause the program to +abort in an effort to avoid malicious execution. +This effectively provides finer-grained protection than SSP for some class of +function and system calls, along with some protection for buffers allocated as +part of the program data. .\" .Ss Supervisor mode memory protection Certain processors include features that prevent unintended access to memory diff --git a/share/man/man7/security.7 b/share/man/man7/security.7 index 71107b29ba11..697d860a9836 100644 --- a/share/man/man7/security.7 +++ b/share/man/man7/security.7 @@ -26,13 +26,21 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 5, 2023 +.Dd June 1, 2024 .Dt SECURITY 7 .Os .Sh NAME .Nm security .Nd introduction to security under FreeBSD .Sh DESCRIPTION +See +.Xr mitigations 7 +for a description of vulnerability mitigations in +.Fx . +This man page documents other +.Fx +security related topics. +.Pp Security is a function that begins and ends with the system administrator. While all .Bx