Skip to contentSkip to conversation

tracing: Do not set trace clock if tracefs lockdown is in effect

PATCH In review Masami Ichikawa 2 participants 4 messages Jan 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Do not set trace clock if tracefs lockdown is in effect

When trace_clock option is not set and unstable clcok detected, tracing_set_default_clock() sets trace_clock(ThinkPad A285 is one of case). In that case, if lockdown is in effect, null pointer dereference error happens in ring_buffer_set_clock().

---
 kernel/trace/trace.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/trace/trace.c +5 -0
index ddb7e7f5fe8d..5b6ee4aadc26 100644
@@ -9420,6 +9420,11 @@ __init static int tracing_set_default_clock(void)
 {
 	/* sched_clock_stable() is determined in late_initcall */
 	if (!trace_boot_clock && !sched_clock_stable()) {
+		if (security_locked_down(LOCKDOWN_TRACEFS)) {
+			pr_warn("Can not set tracing clock due to lockdown\n");
+			return -EPERM;
+		}
+
 		printk(KERN_WARNING
 		       "Unstable clock detected, switching default tracing clock to \"global\"\n"
 		       "If you want to keep using the local clock, then add:\n"
Signature · 1 line
2.24.1
maintainer
#1 lore raw
Quoted 10 lines · Masami Ichikawa

When trace_clock option is not set and unstable clcok detected, tracing_set_default_clock() sets trace_clock(ThinkPad A285 is one of case). In that case, if lockdown is in effect, null pointer dereference error happens in ring_buffer_set_clock().

---
 kernel/trace/trace.c | 5 +++++
 1 file changed, 5 insertions(+)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

#2 lore raw
Quoted 14 lines · Greg KH
Quoted 10 lines · Masami Ichikawa

When trace_clock option is not set and unstable clcok detected, tracing_set_default_clock() sets trace_clock(ThinkPad A285 is one of case). In that case, if lockdown is in effect, null pointer dereference error happens in ring_buffer_set_clock().

---
 kernel/trace/trace.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 8 lines

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

Sorry, I'll resend patch without stable mailing list.

Signature · 1 line
Masami Ichikawa
#3 lore raw

PATCH 1/1 tracing: Do not set trace clock if tracefs lockdown is in effect

In reply to Masami Ichikawa

When trace_clock option is not set and unstable clcok detected, tracing_set_default_clock() sets trace_clock(ThinkPad A285 is one of case). In that case, if lockdown is in effect, null pointer dereference error happens in ring_buffer_set_clock().

---
 kernel/trace/trace.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/trace/trace.c +5 -0
index ddb7e7f5fe8d..5b6ee4aadc26 100644
@@ -9420,6 +9420,11 @@ __init static int tracing_set_default_clock(void)
 {
 	/* sched_clock_stable() is determined in late_initcall */
 	if (!trace_boot_clock && !sched_clock_stable()) {
+		if (security_locked_down(LOCKDOWN_TRACEFS)) {
+			pr_warn("Can not set tracing clock due to lockdown\n");
+			return -EPERM;
+		}
+
 		printk(KERN_WARNING
 		       "Unstable clock detected, switching default tracing clock to \"global\"\n"
 		       "If you want to keep using the local clock, then add:\n"
Signature · 1 line
2.24.1