From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [PATCH] linux: Randomize layout of sensitive kernel structures Date: Wed, 03 Aug 2022 09:30:12 +0100 Message-ID: <70EE8330-1796-4A8B-83A6-AF900F934BEC@ipfire.org> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7193834012329709614==" List-Id: --===============7193834012329709614== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, I assume that is without any ccache whatsoever? Why is this so slow? >>From cache, the kernel should build in about 5-ish minutes. -Michael > On 2 Aug 2022, at 16:13, Peter M=C3=BCller wro= te: >=20 > Hello Michael, >=20 > on my local workstation (featuring an Intel i5-6500), the kernel takes ~ 48 > minutes to compile with randstruct enabled, which is around the same time I= have > experienced before. >=20 > Thanks, and best regards, > Peter M=C3=BCller >=20 >=20 >> Do we finally know how much the impact is at compile time? >>=20 >> -Michael >>=20 >>> On 1 Aug 2022, at 18:18, Peter M=C3=BCller w= rote: >>>=20 >>> To quote from the kernel documentation: >>>=20 >>>> If you say Y here, the layouts of structures that are entirely >>>> function pointers (and have not been manually annotated with >>>> __no_randomize_layout), or structures that have been explicitly >>>> marked with __randomize_layout, will be randomized at compile-time. >>>> This can introduce the requirement of an additional information >>>> exposure vulnerability for exploits targeting these structure >>>> types. >>>>=20 >>>> Enabling this feature will introduce some performance impact, >>>> slightly increase memory usage, and prevent the use of forensic >>>> tools like Volatility against the system (unless the kernel >>>> source tree isn't cleaned after kernel installation). >>>>=20 >>>> The seed used for compilation is located at >>>> scripts/gcc-plgins/randomize_layout_seed.h. It remains after >>>> a make clean to allow for external modules to be compiled with >>>> the existing seed and will be removed by a make mrproper or >>>> make distclean. >>>>=20 >>>> Note that the implementation requires gcc 4.7 or newer. >>>=20 >>> Signed-off-by: Peter M=C3=BCller >>> --- >>> config/kernel/kernel.config.x86_64-ipfire | 3 ++- >>> config/rootfiles/common/aarch64/linux | 5 +++++ >>> config/rootfiles/common/armv6l/linux | 5 +++++ >>> config/rootfiles/common/x86_64/linux | 5 +++++ >>> 4 files changed, 17 insertions(+), 1 deletion(-) >>>=20 >>> diff --git a/config/kernel/kernel.config.x86_64-ipfire b/config/kernel/ke= rnel.config.x86_64-ipfire >>> index 40975b5fc..c8e7ada01 100644 >>> --- a/config/kernel/kernel.config.x86_64-ipfire >>> +++ b/config/kernel/kernel.config.x86_64-ipfire >>> @@ -793,7 +793,8 @@ CONFIG_HAVE_GCC_PLUGINS=3Dy >>> CONFIG_GCC_PLUGINS=3Dy >>> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set >>> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=3Dy >>> -# CONFIG_GCC_PLUGIN_RANDSTRUCT is not set >>> +CONFIG_GCC_PLUGIN_RANDSTRUCT=3Dy >>> +CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE=3Dy >>> # end of General architecture-dependent options >>>=20 >>> CONFIG_RT_MUTEXES=3Dy >>> diff --git a/config/rootfiles/common/aarch64/linux b/config/rootfiles/com= mon/aarch64/linux >>> index dbd6e8f2f..b3a642e56 100644 >>> --- a/config/rootfiles/common/aarch64/linux >>> +++ b/config/rootfiles/common/aarch64/linux >>> @@ -7646,6 +7646,8 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/include/config/GARP >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGINS >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_LATENT_ENTROPY >>> +#lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_RANDSTRUCT >>> +#lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_RANDSTRUCT_PERF= ORMANCE >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_STRUCTLEAK >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_STRUCTLEAK_BYREF= _ALL >>> #lib/modules/KVER-ipfire/build/include/config/GCC_VERSION >>> @@ -11684,6 +11686,7 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/include/generated/autoconf.h >>> #lib/modules/KVER-ipfire/build/include/generated/bounds.h >>> #lib/modules/KVER-ipfire/build/include/generated/compile.h >>> +#lib/modules/KVER-ipfire/build/include/generated/randomize_layout_hash.h >>> #lib/modules/KVER-ipfire/build/include/generated/timeconst.h >>> #lib/modules/KVER-ipfire/build/include/generated/uapi >>> #lib/modules/KVER-ipfire/build/include/generated/uapi/linux >>> @@ -17129,6 +17132,8 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/latent_entropy_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/latent_entropy_plugin.= so >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_plugi= n.c >>> +#lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_plug= in.so >>> +#lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_seed= .h >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/sancov_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/stackleak_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/structleak_plugin.c >>> diff --git a/config/rootfiles/common/armv6l/linux b/config/rootfiles/comm= on/armv6l/linux >>> index 79e4facfe..c3411fe8d 100644 >>> --- a/config/rootfiles/common/armv6l/linux >>> +++ b/config/rootfiles/common/armv6l/linux >>> @@ -8071,6 +8071,8 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGINS >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_ARM_SSP_PER_TASK >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_LATENT_ENTROPY >>> +#lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_RANDSTRUCT >>> +#lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_RANDSTRUCT_PERF= ORMANCE >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_STRUCTLEAK >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_STRUCTLEAK_BYREF= _ALL >>> #lib/modules/KVER-ipfire/build/include/config/GCC_VERSION >>> @@ -12134,6 +12136,7 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/include/generated/autoconf.h >>> #lib/modules/KVER-ipfire/build/include/generated/bounds.h >>> #lib/modules/KVER-ipfire/build/include/generated/compile.h >>> +#lib/modules/KVER-ipfire/build/include/generated/randomize_layout_hash.h >>> #lib/modules/KVER-ipfire/build/include/generated/timeconst.h >>> #lib/modules/KVER-ipfire/build/include/generated/uapi >>> #lib/modules/KVER-ipfire/build/include/generated/uapi/linux >>> @@ -17579,6 +17582,8 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/latent_entropy_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/latent_entropy_plugin.= so >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_plugi= n.c >>> +#lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_plug= in.so >>> +#lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_seed= .h >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/sancov_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/stackleak_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/structleak_plugin.c >>> diff --git a/config/rootfiles/common/x86_64/linux b/config/rootfiles/comm= on/x86_64/linux >>> index b25f85a3a..1b78fe8c5 100644 >>> --- a/config/rootfiles/common/x86_64/linux >>> +++ b/config/rootfiles/common/x86_64/linux >>> @@ -7624,6 +7624,8 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/include/config/GARP >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGINS >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_LATENT_ENTROPY >>> +#lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_RANDSTRUCT >>> +#lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_RANDSTRUCT_PERF= ORMANCE >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_STRUCTLEAK >>> #lib/modules/KVER-ipfire/build/include/config/GCC_PLUGIN_STRUCTLEAK_BYREF= _ALL >>> #lib/modules/KVER-ipfire/build/include/config/GCC_VERSION >>> @@ -12128,6 +12130,7 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/include/generated/autoconf.h >>> #lib/modules/KVER-ipfire/build/include/generated/bounds.h >>> #lib/modules/KVER-ipfire/build/include/generated/compile.h >>> +#lib/modules/KVER-ipfire/build/include/generated/randomize_layout_hash.h >>> #lib/modules/KVER-ipfire/build/include/generated/timeconst.h >>> #lib/modules/KVER-ipfire/build/include/generated/uapi >>> #lib/modules/KVER-ipfire/build/include/generated/uapi/linux >>> @@ -17567,6 +17570,8 @@ etc/modprobe.d/ipv6.conf >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/latent_entropy_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/latent_entropy_plugin.= so >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_plugi= n.c >>> +#lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_plug= in.so >>> +#lib/modules/KVER-ipfire/build/scripts/gcc-plugins/randomize_layout_seed= .h >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/sancov_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/stackleak_plugin.c >>> #lib/modules/KVER-ipfire/build/scripts/gcc-plugins/structleak_plugin.c >>> --=20 >>> 2.35.3 >>=20 --===============7193834012329709614==--