Skip to contentSkip to conversation

Documentation/tracing: Mention that RESET_ATTACK_MITIGATION can clear memory

PATCH Superseded Steven Rostedt 4 participants 10 messages Sep 26, 2024 – Oct 1, 2024

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 Documentation/tracing: Mention that RESET_ATTACK_MITIGATION can clear memory

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index bb48ae24ae69..f9b79294f84a 100644
@@ -6850,6 +6850,9 @@
 
 				reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff^traceprintk@trace,sched,irq
 
+			Note, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which
+			will clear any trace that was stored.
+
 			See also Documentation/trace/debugging.rst
 
 
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 12 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Quoted 7 lines

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 18 lines
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index bb48ae24ae69..f9b79294f84a 100644
@@ -6850,6 +6850,9 @@
 
 				reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff^traceprintk@trace,sched,irq
 
+			Note, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which
+			will clear any trace that was stored.
+
 			See also Documentation/trace/debugging.rst
 
 
author maintainer
#2 lore raw
Quoted 18 lines · On Thu, 26 Sep 2024 19:54:48 +0200 Hans de Goede <[email protected]> wrote:

Hi,

Quoted 15 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

Quoted 8 lines
Quoted 4 lines

Thanks, patch looks good to me:

Thanks,

And I forgot to send this to the Documentation maintainers :-p

Jon, could you take this? Do you need me to resend, or can you just pull it from lore?

https://lore.kernel.org/linux-trace-kernel/[email protected]/

-- Steve

Quoted 25 lines

Regards,

Hans

Quoted 18 lines
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index bb48ae24ae69..f9b79294f84a 100644
@@ -6850,6 +6850,9 @@
 
 				reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff^traceprintk@trace,sched,irq
 
+			Note, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which
+			will clear any trace that was stored.
+
 			See also Documentation/trace/debugging.rst
 
 
maintainer
#3 lore raw
Quoted 28 lines · Steven Rostedt
Quoted 25 lines · On Thu, 26 Sep 2024 19:54:48 +0200 Hans de Goede <[email protected]> wrote:

Hi,

Quoted 12 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Quoted 7 lines

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

Thanks, patch looks good to me:

Quoted 8 lines
Quoted 1 line

Thanks,

And I forgot to send this to the Documentation maintainers :-p

Jon, could you take this? Do you need me to resend, or can you just pull it from lore?

I'll grab it in a bit.

jon

author maintainer
#4 lore raw
Quoted 6 lines · On Mon, 30 Sep 2024 11:20:48 -0600 Jonathan Corbet <[email protected]> wrote:
Quoted 4 lines

And I forgot to send this to the Documentation maintainers :-p

Jon, could you take this? Do you need me to resend, or can you just pull it from lore?

I'll grab it in a bit.

No rush.

Thanks!

-- Steve

#5 lore raw
In reply to Steven Rostedt
Quoted 29 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index bb48ae24ae69..f9b79294f84a 100644

Documentation/admin-guide/kernel-parameters.txt line 6855

Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -6850,6 +6850,9 @@
 
                                reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff^traceprintk@trace,sched,irq
 
+                       Note, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which
+                       will clear any trace that was stored.
+

CONFIG_RESET_ATTACK_MITIGATION can force a wipe of system RAM at warm reboot on systems that have a TPM enabled, but disabling it does not prevent it. Also, there are many other reasons why the trace buffer region may be wiped and/or reused for other purposes, so singling out CONFIG_RESET_ATTACK_MITIGATION like this is not that useful imo.

As I indicated when this feature was under review, it should be made very clear that any kernel side changes that affect the system's behavior in this regard should not be considered regressions. So instead of mentioning CONFIG_RESET_ATTACK_MITIGATION here, perhaps it would be better to document that system firmware generally makes no guarantees about preserving memory contents, and so this feature may break without warning.

Note that on UEFI systems, there is a so-called 'capsule' interface which does allow the OS to preserve an arbitrary buffer across a warm reboot. However, whether it works on all systems is anybody's guess.

#6 lore raw

Hi,

Quoted 33 lines · Ard Biesheuvel
Quoted 32 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index bb48ae24ae69..f9b79294f84a 100644
@@ -6850,6 +6850,9 @@
 
                                reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff^traceprintk@trace,sched,irq
 
Quoted 9 lines

Documentation/admin-guide/kernel-parameters.txt line 6855

Quoted 3 lines
Documentation/admin-guide/kernel-parameters.txt +3 -0
+                       Note, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which
+                       will clear any trace that was stored.
+

CONFIG_RESET_ATTACK_MITIGATION can force a wipe of system RAM at warm reboot on systems that have a TPM enabled, but disabling it does not prevent it. Also, there are many other reasons why the trace buffer region may be wiped and/or reused for other purposes, so singling out CONFIG_RESET_ATTACK_MITIGATION like this is not that useful imo.

Since the userspace parts to clear the CONFIG_RESET_ATTACK_MITIGATION related EFI variable after cleaning cryptographic keys from RAM has never materialized CONFIG_RESET_ATTACK_MITIGATION is pretty much guaranteed to clear any traces on any modern machine (and at least in Fedora's kernel config it is disabled because of this).

I agree that there are more ways the RAM might get cleared, but since this will clear the RAM almost 100% of the time it is worth documenting this IMHO.

I get the feeling you (Ard) see documenting this as some sorta bug report against CONFIG_RESET_ATTACK_MITIGATION, that is not the intention. Quite the opposite the documentation is there to let the user know that CONFIG_RESET_ATTACK_MITIGATION works as advertised and that it will (almost) always clear the RAM on reboot and thus conflicts with keeping traces over reboot.

Regards,

Hans

#7 lore raw

Hi Hans,

Quoted 47 lines · Hans de Goede

Hi,

Quoted 33 lines · Ard Biesheuvel
Quoted 32 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

At the 2024 Linux Plumbers Conference, I was talking with Hans de Goede about the persistent buffer to display traces from previous boots. He mentioned that UEFI can clear memory. In my own tests I have not seen this. He later informed me that it requires the config option:

CONFIG_RESET_ATTACK_MITIGATION

It appears that setting this will allow the memory to be cleared on boot up, which will definitely clear out the trace of the previous boot.

Add this information under the trace_instance in kernel-parameters.txt to let people know that this can cause issues.

---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index bb48ae24ae69..f9b79294f84a 100644
@@ -6850,6 +6850,9 @@
 
                                reserve_mem=12M:4096:trace trace_instance=boot_map^traceoff^traceprintk@trace,sched,irq
 
Quoted 9 lines

Documentation/admin-guide/kernel-parameters.txt line 6855

Quoted 3 lines
Documentation/admin-guide/kernel-parameters.txt +3 -0
+                       Note, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which
+                       will clear any trace that was stored.
+

CONFIG_RESET_ATTACK_MITIGATION can force a wipe of system RAM at warm reboot on systems that have a TPM enabled, but disabling it does not prevent it. Also, there are many other reasons why the trace buffer region may be wiped and/or reused for other purposes, so singling out CONFIG_RESET_ATTACK_MITIGATION like this is not that useful imo.

Quoted 6 lines

Since the userspace parts to clear the CONFIG_RESET_ATTACK_MITIGATION related EFI variable after cleaning cryptographic keys from RAM has never materialized CONFIG_RESET_ATTACK_MITIGATION is pretty much guaranteed to clear any traces on any modern machine (and at least in Fedora's kernel config it is disabled because of this).

Any modern x86 PC, sure.

Quoted 4 lines

I agree that there are more ways the RAM might get cleared, but since this will clear the RAM almost 100% of the time it is worth documenting this IMHO.

Fair enough.

Quoted 7 lines

I get the feeling you (Ard) see documenting this as some sorta bug report against CONFIG_RESET_ATTACK_MITIGATION, that is not the intention. Quite the opposite the documentation is there to let the user know that CONFIG_RESET_ATTACK_MITIGATION works as advertised and that it will (almost) always clear the RAM on reboot and thus conflicts with keeping traces over reboot.

I am not against documenting this. CONFIG_RESET_ATTACK_MITIGATION is simply incompatible with this feature so it makes sense calling that out.

But there are so many other ways in which the trace buffer might get clobbered, and mentioning CONFIG_RESET_ATTACK_MITIGATION in particular might suggest to some that those other causes are due to kernel bugs.

All I am asking for is a line in the documentation that says that clobbered trace buffers could occur at any time, regardless of whether CONFIG_RESET_ATTACK_MITIGATION is enabled or not. That way, we have something to refer to when people start filing bugs against the EFI component when this breaks.

author maintainer
#8 lore raw
Quoted 5 lines · On Tue, 1 Oct 2024 11:35:53 +0200 Ard Biesheuvel <[email protected]> wrote:

All I am asking for is a line in the documentation that says that clobbered trace buffers could occur at any time, regardless of whether CONFIG_RESET_ATTACK_MITIGATION is enabled or not. That way, we have something to refer to when people start filing bugs against the EFI component when this breaks.

How about if I change the comment to this?

Note, saving the trace buffer across reboots does require that the system is set up to not wipe memory. For instance, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which will clear any trace that was stored. This is just one of many ways that can clear memory. Make sure your system keeps the content of memory across reboots before relying on this option.

Would that be better?

I want to stress that this doesn't work for every setup. It just so happens to work for mine and others. I do not want people thinking that it's a bug if it doesn't work for them.

-- Steve

#9 lore raw
Quoted 12 lines · Steven Rostedt
Quoted 5 lines · On Tue, 1 Oct 2024 11:35:53 +0200 Ard Biesheuvel <[email protected]> wrote:

All I am asking for is a line in the documentation that says that clobbered trace buffers could occur at any time, regardless of whether CONFIG_RESET_ATTACK_MITIGATION is enabled or not. That way, we have something to refer to when people start filing bugs against the EFI component when this breaks.

How about if I change the comment to this?

Quoted 8 lines

Note, saving the trace buffer across reboots does require that the system is set up to not wipe memory. For instance, CONFIG_RESET_ATTACK_MITIGATION can force a memory reset on boot which will clear any trace that was stored. This is just one of many ways that can clear memory. Make sure your system keeps the content of memory across reboots before relying on this option.

Would that be better?

Yes, that looks much better. Thanks.

Quoted 3 lines

I want to stress that this doesn't work for every setup. It just so happens to work for mine and others. I do not want people thinking that it's a bug if it doesn't work for them.

Exactly. I can see how this feature is very useful if it happens to work on your system firmware, but it should be documented as not being covered by the 'no user visible regressions' policy.