tracing: Fix align of static buffer
Subsystems (2)
PATCH 1/1 tracing: Fix align of static buffer
With 5.9 kernel on ARM64, I found ftrace_dump output was broken but it had no problem with normal output "cat /sys/kernel/debug/tracing/trace".
With investigation, it seems coping the data into temporal buffer seems to break the align binary printf expects if the static buffer is not aligned with 4-byte. IIUC, get_arg in bstr_printf expects that args has already right align to be decoded and seq_buf_bprintf says ``the arguments are saved in a 32bit word array that is defined by the format string constraints``. So if we don't keep the align under copy to temporal buffer, the output will be broken by shifting some bytes.
This patch fixes it.
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -3534,7 +3534,7 @@ __find_next_entry(struct trace_iterator *iter, int *ent_cpu, }#define STATIC_TEMP_BUF_SIZE 128 -static char static_temp_buf[STATIC_TEMP_BUF_SIZE ]; +static char static_temp_buf[STATIC_TEMP_BUF_SIZE ]__aligned(4) ;/* Find the next real entry, without updating the iterator itself */ struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
Greg KH
maintainerQuoted 11 lines · Minchan Kim
With 5.9 kernel on ARM64, I found
ftrace_dumpoutput was broken but it had no problem with normal output "cat/sys/kernel/debug/tracing/trace".With investigation, it seems coping the data into temporal buffer seems to break the align binary printf expects if the static buffer is not aligned with 4-byte. IIUC,
get_arginbstr_printfexpects that args has already right align to be decoded andseq_buf_bprintfsays ``the arguments are saved in a 32bit word array that is defined by the format string constraints``. So if we don't keep the align under copy to temporal buffer, the output will be broken by shifting some bytes.
Quoted 1 line
This patch fixes it.
Does this resolve the issue reported at:
https://lore.kernel.org/r/[email protected]
?
thanks,
greg k-h
Hi Greg,
Quoted 13 lines · Greg KH
Quoted 11 lines · Minchan Kim
With 5.9 kernel on ARM64, I found
ftrace_dumpoutput was broken but it had no problem with normal output "cat/sys/kernel/debug/tracing/trace".With investigation, it seems coping the data into temporal buffer seems to break the align binary printf expects if the static buffer is not aligned with 4-byte. IIUC,
get_arginbstr_printfexpects that args has already right align to be decoded andseq_buf_bprintfsays ``the arguments are saved in a 32bit word array that is defined by the format string constraints``. So if we don't keep the align under copy to temporal buffer, the output will be broken by shifting some bytes.
Quoted 5 lines
Quoted 1 line
This patch fixes it.
Does this resolve the issue reported at:
https://lore.kernel.org/r/[email protected]?
No, it's a different issue.
Thanks,
Namhyung
Quoted 5 lines · Youngmin Nam
Hi Minchan,
Feel free to add my:
Tested-by Youngmin Nam <[email protected]>
Thanks for the testing, Youngmin!