From nobody Sun Nov 17 18:28:50 2024 X-Original-To: freebsd-current@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 4XrzmV36wpz5dFLr for ; Sun, 17 Nov 2024 18:28:58 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XrzmV2ZN3z4pX9; Sun, 17 Nov 2024 18:28:58 +0000 (UTC) (envelope-from dim@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731868138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6FbOtT7iES6zDO3HU+j0ukmviCfZJbxCW5AEbkYKspg=; b=WAVvQt1Rat2jV0Fk4Rwz8l0xMEpr1Cliu28upsJifZoDuZBbqSYeKiCryDKAT0VthqzKQc exSEveSzcc9avbOHOYyRBAGfDZHzY+/FZ/rlHT3N/au8dlK2cz9STLakowuG+Dhu9kH6X9 6ZGQMi8AC9DuMRRgslMf38s3ox8Xiqohc5Q+TndlI1KBVxXmszxJLK04Zr87wVe8pSoUTM Hg5e5TJnTqbxuWjg+S3K+YtMFo8xsIdGBdt/IlGq2RNwlxT3SVvntIci738oBcVZB/rAVF YJkRXnR8nAKRRBq8K89IPs/0pmRy9gNXHkRAqk4ezlIb+ksLA+N4xS7cukZ1rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731868138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6FbOtT7iES6zDO3HU+j0ukmviCfZJbxCW5AEbkYKspg=; b=b1VIifUQoDEUtBgFQO6yhAmGzHY74XDWtxfSOKWgLG1m+GAGg95DoUH166LxcCp5qHTxpI Aivz50B9eHk2+pm6gZ/0NwwIh2GS0sMl3mvWpl3vKYmGRJ1aET7CuCbEKDnOteI9lOzHiy xwhnlSCE+NWXEvfPJn1H01smubB4gN+M3yIwxYWW2MIHDfodFkWO2NNB1xcNaplZweFQuI z/oyZKGbVNKjvOFac20j9aqwB+f2w07dijLykCl+D8KrorpWHQDQbiyB892ieZ79RjLJdX rp/xfaOd3n58Pg4/gEmMW8cwKYV0cI0JqYZACuPap2UX0qL07/fGZoVCw+ADpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731868138; a=rsa-sha256; cv=none; b=Z7EThZtAvE/rhR39JUh3r3Y3PRXCm7avBTkAZ6iTyjhq8z0C6djIDEKIKPHO4IlMsJijw8 MKdxTJUNOpQlgculnpBCB81RrfdVG9bDdw1S1hYfcztl7s+veRsLmOyET9gBTgIzLSpTm3 BhwntjW5vzVjP5Zow4MY8ii5infASI+Uc5fTM82Gy8M9xazl+3J0TjS8bQ3n91FH74X1ly eiE2wqI9NqCvMWfKLiC50NFJk9xr/GpCyc5BVJFrqseJBuQYWO23GQ+GcHtpZ3CVct8JLp QlB3Qo0T8DsffirOcxnveT7aT27VAP4DM7LSMp6yZKAllnvfYuVSxIzLP1IZ2Q== Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (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 (2048 bits) client-digest SHA256) (Client CN "tensor.andric.com", Issuer "R10" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id 4XrzmV1F65zMhT; Sun, 17 Nov 2024 18:28:58 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (longrow.home.andric.com [192.168.0.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 12F272254C; Sun, 17 Nov 2024 19:28:57 +0100 (CET) Content-Type: multipart/signed; boundary="Apple-Mail=_48F44590-745D-4D44-A0DD-3C10301B2E8B"; protocol="application/pgp-signature"; micalg=pgp-sha1 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.9\)) Subject: Re: Playing around with security hardening compiler flags From: Dimitry Andric In-Reply-To: <01a4b49d43860c30e480ec7cf5bd08f9@Leidinger.net> Date: Sun, 17 Nov 2024 19:28:50 +0100 Cc: Current FreeBSD Message-Id: <812A3C4D-35FA-4F98-B279-F550D3296C12@FreeBSD.org> References: <01a4b49d43860c30e480ec7cf5bd08f9@Leidinger.net> To: Alexander Leidinger X-Mailer: Apple Mail (2.3731.700.6.1.9) --Apple-Mail=_48F44590-745D-4D44-A0DD-3C10301B2E8B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 17 Nov 2024, at 16:30, Alexander Leidinger = wrote: >=20 > Hi, >=20 > after reading > = https://security.googleblog.com/2024/11/retrofitting-spatial-safety-to-hun= dreds.html > https://libcxx.llvm.org/Hardening.html > = https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Harden= ing-Guide-for-C-and-C++.html > I played around a bit with some of the flags there (in CFLAGS). >=20 > What doesn't work: > - -fstrict-flex-arrays=3D3 (variable array issue in IIRC a tool for = ath) > - -fstrict-flex-arrays=3D2 (issue in another area, haven't checked = further) >=20 > What works and results in a world+kernel which is able to boot: > - -D_GLIBCXX_ASSERTIONS > - -fstrict-flex-arrays=3D1 > - -fstack-clash-protection > - -D_LIBCPP_HARDENING_MODE=3D_LIBCPP_HARDENING_MODE_EXTENSIVE FWIW the default hardening mode for libc++ is already extensive. There = is also a debug mode, but that is not suitable for general use. I have = not yet considered any WITH/WITHOUT options to fiddle with this, since = it is an option with 4 possible values: none, fast, extensive, and = debug. _GLIBCXX_ASSERTIONS is a similar directive for libstdc++, so it won't = make much difference for the base system, but it could be good for some = ports. (Not sure about the overhead though.) I am unsure about the usefulness of -fstrict-flex-arrays, I have not = really played with this option. I would expect more warnings to come = out? Last but not least, -fstack-clash-protection might be useful, but I = think it might need some additional runtime support? E.g. in libc? -Dimitry --Apple-Mail=_48F44590-745D-4D44-A0DD-3C10301B2E8B Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCZzo14gAKCRCwXqMKLiCW ows9AJ0daLhHhB0A5u1J5MyChziaFEWz/gCguyzVOpjfONIG2aP/kj5NO3eZPtA= =X4nm -----END PGP SIGNATURE----- --Apple-Mail=_48F44590-745D-4D44-A0DD-3C10301B2E8B--