kernel: enable CONFIG_GCC_PLUGIN_STACKLEAK

Message ID 286f4067-f7e8-19a2-f45d-204e5e9a6fb1@ipfire.org
State New
Headers show
Series
  • kernel: enable CONFIG_GCC_PLUGIN_STACKLEAK
Related show

Commit Message

Peter Müller June 9, 2020, 5:53 p.m. UTC
Quoted from https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project/Recommended_Settings:

> # Wipe stack contents on syscall exit (reduces stale data lifetime in stack)
> CONFIG_GCC_PLUGIN_STACKLEAK=y

Not sure what performance penalities this introduces in real life...

Fixes: #12382

Cc: Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 config/kernel/kernel.config.aarch64-ipfire        | 1 +
 config/kernel/kernel.config.armv5tel-ipfire-multi | 1 +
 config/kernel/kernel.config.i586-ipfire           | 1 +
 config/kernel/kernel.config.x86_64-ipfire         | 1 +
 4 files changed, 4 insertions(+)

Comments

Michael Tremer June 10, 2020, 8:28 a.m. UTC | #1
Hi,

> On 9 Jun 2020, at 18:53, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> Quoted from https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project/Recommended_Settings:
> 
>> # Wipe stack contents on syscall exit (reduces stale data lifetime in stack)
>> CONFIG_GCC_PLUGIN_STACKLEAK=y
> 
> Not sure what performance penalities this introduces in real life...

Well, should we not find out before we make this generally available for all users?

-Michael

> 
> Fixes: #12382
> 
> Cc: Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
> config/kernel/kernel.config.aarch64-ipfire        | 1 +
> config/kernel/kernel.config.armv5tel-ipfire-multi | 1 +
> config/kernel/kernel.config.i586-ipfire           | 1 +
> config/kernel/kernel.config.x86_64-ipfire         | 1 +
> 4 files changed, 4 insertions(+)
> 
> diff --git a/config/kernel/kernel.config.aarch64-ipfire b/config/kernel/kernel.config.aarch64-ipfire
> index e0f2f6df8..f4240e0ae 100644
> --- a/config/kernel/kernel.config.aarch64-ipfire
> +++ b/config/kernel/kernel.config.aarch64-ipfire
> @@ -256,6 +256,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
> CONFIG_GCC_PLUGINS=y
> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
> +CONFIG_GCC_PLUGIN_STACKLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
> diff --git a/config/kernel/kernel.config.armv5tel-ipfire-multi b/config/kernel/kernel.config.armv5tel-ipfire-multi
> index 15183300f..2bcfbdbdd 100644
> --- a/config/kernel/kernel.config.armv5tel-ipfire-multi
> +++ b/config/kernel/kernel.config.armv5tel-ipfire-multi
> @@ -252,6 +252,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
> CONFIG_GCC_PLUGINS=y
> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
> +CONFIG_GCC_PLUGIN_STACKLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
> diff --git a/config/kernel/kernel.config.i586-ipfire b/config/kernel/kernel.config.i586-ipfire
> index 578931497..a72cde41a 100644
> --- a/config/kernel/kernel.config.i586-ipfire
> +++ b/config/kernel/kernel.config.i586-ipfire
> @@ -283,6 +283,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
> CONFIG_GCC_PLUGINS=y
> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
> +CONFIG_GCC_PLUGIN_STACKLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
> diff --git a/config/kernel/kernel.config.x86_64-ipfire b/config/kernel/kernel.config.x86_64-ipfire
> index 6a5fbbfe9..cd116d780 100644
> --- a/config/kernel/kernel.config.x86_64-ipfire
> +++ b/config/kernel/kernel.config.x86_64-ipfire
> @@ -293,6 +293,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
> CONFIG_GCC_PLUGINS=y
> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
> +CONFIG_GCC_PLUGIN_STACKLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
> -- 
> 2.26.2
Arne Fitzenreiter June 10, 2020, 2:48 p.m. UTC | #2
This option not exist in kernel 4.14!!! It was added with kernel 5.2

Arne


Am 2020-06-10 10:28, schrieb Michael Tremer:
> Hi,
> 
>> On 9 Jun 2020, at 18:53, Peter Müller <peter.mueller@ipfire.org> 
>> wrote:
>> 
>> Quoted from 
>> https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project/Recommended_Settings:
>> 
>>> # Wipe stack contents on syscall exit (reduces stale data lifetime in 
>>> stack)
>>> CONFIG_GCC_PLUGIN_STACKLEAK=y
>> 
>> Not sure what performance penalities this introduces in real life...
> 
> Well, should we not find out before we make this generally available
> for all users?
> 
> -Michael
> 
>> 
>> Fixes: #12382
>> 
>> Cc: Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
>> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
>> ---
>> config/kernel/kernel.config.aarch64-ipfire        | 1 +
>> config/kernel/kernel.config.armv5tel-ipfire-multi | 1 +
>> config/kernel/kernel.config.i586-ipfire           | 1 +
>> config/kernel/kernel.config.x86_64-ipfire         | 1 +
>> 4 files changed, 4 insertions(+)
>> 
>> diff --git a/config/kernel/kernel.config.aarch64-ipfire 
>> b/config/kernel/kernel.config.aarch64-ipfire
>> index e0f2f6df8..f4240e0ae 100644
>> --- a/config/kernel/kernel.config.aarch64-ipfire
>> +++ b/config/kernel/kernel.config.aarch64-ipfire
>> @@ -256,6 +256,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
>> CONFIG_GCC_PLUGINS=y
>> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
>> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
>> +CONFIG_GCC_PLUGIN_STACKLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
>> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
>> diff --git a/config/kernel/kernel.config.armv5tel-ipfire-multi 
>> b/config/kernel/kernel.config.armv5tel-ipfire-multi
>> index 15183300f..2bcfbdbdd 100644
>> --- a/config/kernel/kernel.config.armv5tel-ipfire-multi
>> +++ b/config/kernel/kernel.config.armv5tel-ipfire-multi
>> @@ -252,6 +252,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
>> CONFIG_GCC_PLUGINS=y
>> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
>> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
>> +CONFIG_GCC_PLUGIN_STACKLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
>> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
>> diff --git a/config/kernel/kernel.config.i586-ipfire 
>> b/config/kernel/kernel.config.i586-ipfire
>> index 578931497..a72cde41a 100644
>> --- a/config/kernel/kernel.config.i586-ipfire
>> +++ b/config/kernel/kernel.config.i586-ipfire
>> @@ -283,6 +283,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
>> CONFIG_GCC_PLUGINS=y
>> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
>> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
>> +CONFIG_GCC_PLUGIN_STACKLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
>> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
>> diff --git a/config/kernel/kernel.config.x86_64-ipfire 
>> b/config/kernel/kernel.config.x86_64-ipfire
>> index 6a5fbbfe9..cd116d780 100644
>> --- a/config/kernel/kernel.config.x86_64-ipfire
>> +++ b/config/kernel/kernel.config.x86_64-ipfire
>> @@ -293,6 +293,7 @@ CONFIG_HAVE_GCC_PLUGINS=y
>> CONFIG_GCC_PLUGINS=y
>> # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
>> CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
>> +CONFIG_GCC_PLUGIN_STACKLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK=y
>> CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
>> # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
>> --
>> 2.26.2

Patch

diff --git a/config/kernel/kernel.config.aarch64-ipfire b/config/kernel/kernel.config.aarch64-ipfire
index e0f2f6df8..f4240e0ae 100644
--- a/config/kernel/kernel.config.aarch64-ipfire
+++ b/config/kernel/kernel.config.aarch64-ipfire
@@ -256,6 +256,7 @@  CONFIG_HAVE_GCC_PLUGINS=y
 CONFIG_GCC_PLUGINS=y
 # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
+CONFIG_GCC_PLUGIN_STACKLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
 # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
diff --git a/config/kernel/kernel.config.armv5tel-ipfire-multi b/config/kernel/kernel.config.armv5tel-ipfire-multi
index 15183300f..2bcfbdbdd 100644
--- a/config/kernel/kernel.config.armv5tel-ipfire-multi
+++ b/config/kernel/kernel.config.armv5tel-ipfire-multi
@@ -252,6 +252,7 @@  CONFIG_HAVE_GCC_PLUGINS=y
 CONFIG_GCC_PLUGINS=y
 # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
+CONFIG_GCC_PLUGIN_STACKLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
 # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
diff --git a/config/kernel/kernel.config.i586-ipfire b/config/kernel/kernel.config.i586-ipfire
index 578931497..a72cde41a 100644
--- a/config/kernel/kernel.config.i586-ipfire
+++ b/config/kernel/kernel.config.i586-ipfire
@@ -283,6 +283,7 @@  CONFIG_HAVE_GCC_PLUGINS=y
 CONFIG_GCC_PLUGINS=y
 # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
+CONFIG_GCC_PLUGIN_STACKLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
 # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set
diff --git a/config/kernel/kernel.config.x86_64-ipfire b/config/kernel/kernel.config.x86_64-ipfire
index 6a5fbbfe9..cd116d780 100644
--- a/config/kernel/kernel.config.x86_64-ipfire
+++ b/config/kernel/kernel.config.x86_64-ipfire
@@ -293,6 +293,7 @@  CONFIG_HAVE_GCC_PLUGINS=y
 CONFIG_GCC_PLUGINS=y
 # CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
 CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
+CONFIG_GCC_PLUGIN_STACKLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK=y
 CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
 # CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE is not set