Skip to contentSkip to conversation

ftrace: ipipe: Fix hardening of trace_recursive_lock

PATCH New Jan Kiszka 1 participant 1 message Mar 14, 2021

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 ftrace: ipipe: Fix hardening of trace_recursive_lock

From: Jan Kiszka <[email protected]>

cpu_buffer->current_context is supposed to be protected by irq disabling, just like in dovetail.

---

No-arch branches updated with this already.

 kernel/trace/ring_buffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +3 -1
index dfaeee5b54e3..90be9e613887 100644
@@ -2726,9 +2726,9 @@ rb_wakeups(struct ring_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer)
 static __always_inline int
 trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer)
 {
-	unsigned int val = cpu_buffer->current_context;
 	unsigned long pc = preempt_count();
 	unsigned long flags;
+	unsigned int val;
 	int bit;
 
 	if (!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
@@ -2739,6 +2739,8 @@ trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer)
 
 	flags = hard_local_irq_save();
 
+	val = cpu_buffer->current_context;
+
 	if (unlikely(val & (1 << (bit + cpu_buffer->nest)))) {
 		/*
 		 * It is possible that this was called by transitioning
Signature · 1 line
2.26.2