All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: Fix align of static buffer
@ 2020-11-25 22:56 Minchan Kim
  2020-11-26  5:52 ` Greg KH
       [not found] ` <CGME20201126124101epcas2p30b7039bc8e6a9c08e35487b39dd84767@epcas2p3.samsung.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Minchan Kim @ 2020-11-25 22:56 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Minchan Kim, stable, Namhyung Kim

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.

Cc: <stable@vger.kernel.org>
Fixes: 8e99cf91b99bb ("tracing: Do not allocate buffer in trace_find_next_entry() in atomic")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6a282bbc7e7f..01bfcc345d55 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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,
-- 
2.29.2.454.gaff20da3a2-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: Fix align of static buffer
  2020-11-25 22:56 [PATCH] tracing: Fix align of static buffer Minchan Kim
@ 2020-11-26  5:52 ` Greg KH
  2020-11-26  9:31   ` Namhyung Kim
       [not found] ` <CGME20201126124101epcas2p30b7039bc8e6a9c08e35487b39dd84767@epcas2p3.samsung.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-11-26  5:52 UTC (permalink / raw)
  To: Minchan Kim; +Cc: Steven Rostedt, LKML, stable, Namhyung Kim

On Wed, Nov 25, 2020 at 02:56:54PM -0800, Minchan Kim wrote:
> 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.

Does this resolve the issue reported at:
	https://lore.kernel.org/r/20201124223917.795844-1-elavila@google.com
?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: Fix align of static buffer
  2020-11-26  5:52 ` Greg KH
@ 2020-11-26  9:31   ` Namhyung Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2020-11-26  9:31 UTC (permalink / raw)
  To: Greg KH; +Cc: Minchan Kim, Steven Rostedt, LKML, stable # 4 . 5

Hi Greg,

On Thu, Nov 26, 2020 at 2:52 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Nov 25, 2020 at 02:56:54PM -0800, Minchan Kim wrote:
> > 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.
>
> Does this resolve the issue reported at:
>         https://lore.kernel.org/r/20201124223917.795844-1-elavila@google.com
> ?

No, it's a different issue.

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: Fix align of static buffer
       [not found] ` <CGME20201126124101epcas2p30b7039bc8e6a9c08e35487b39dd84767@epcas2p3.samsung.com>
@ 2020-11-26 13:04   ` Youngmin Nam
  2020-11-26 18:05     ` Minchan Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Youngmin Nam @ 2020-11-26 13:04 UTC (permalink / raw)
  To: minchan; +Cc: linux-kernel, stable, namhyung, youngmin.nam

Hi Minchan,

Feel free to add my:

Tested-by: Youngmin Nam <youngmin.nam@samsung.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: Fix align of static buffer
  2020-11-26 13:04   ` Youngmin Nam
@ 2020-11-26 18:05     ` Minchan Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Minchan Kim @ 2020-11-26 18:05 UTC (permalink / raw)
  To: Youngmin Nam; +Cc: linux-kernel, stable, namhyung

On Thu, Nov 26, 2020 at 10:04:28PM +0900, Youngmin Nam wrote:
> Hi Minchan,
> 
> Feel free to add my:
> 
> Tested-by: Youngmin Nam <youngmin.nam@samsung.com>

Thanks for the testing, Youngmin!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-26 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 22:56 [PATCH] tracing: Fix align of static buffer Minchan Kim
2020-11-26  5:52 ` Greg KH
2020-11-26  9:31   ` Namhyung Kim
     [not found] ` <CGME20201126124101epcas2p30b7039bc8e6a9c08e35487b39dd84767@epcas2p3.samsung.com>
2020-11-26 13:04   ` Youngmin Nam
2020-11-26 18:05     ` Minchan Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.