tracing: Make sure trace_printk() can output as soon as it can be used
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ e725c731e3bb1e892e7b564c945b121cb41d1087 · < 198c83963f6335ca6d690cff067679560f2a3a22| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
tracing: Make sure trace_printk() can output as soon as it can be used
Currently trace_printk() can be used as soon as early_trace_init() is called from start_kernel(). But if a crash happens, and "ftrace_dump_on_oops" is set on the kernel command line, all you get will be:
[ 0.456075] <idle>-0 0dN.2. 347519us : Unknown type 6 [ 0.456075] <idle>-0 0dN.2. 353141us : Unknown type 6 [ 0.456075] <idle>-0 0dN.2. 358684us : Unknown type 6
This is because the trace_printk() event (type 6) hasn't been registered yet. That gets done via an early_initcall(), which may be early, but not early enough.
Instead of registering the trace_printk() event (and other ftrace events, which are not trace events) via an early_initcall(), have them registered at the same time that trace_printk() can be used. This way, if there is a crash before early_initcall(), then the trace_printk()s will actually be useful.
From the CVE record · Linux
The Linux kernel can use trace_printk() before its event type is registered. If the kernel crashes during that interval with ftrace_dump_on_oops set, the trace dump shows “Unknown type 6” instead of useful trace_printk() output. The input does not describe an attacker scenario.
Engineers running Linux kernels that use trace_printk() and ftrace_dump_on_oops should check their kernel; affected versions are not specified.