Files
kernel_xiaomi_sm8250/kernel
Steven Rostedt (Google) 9a9d6a7266 tracing: Add size check when printing trace_marker output
[ Upstream commit 60be76eeabb3d83858cc6577fc65c7d0f36ffd42 ]

If for some reason the trace_marker write does not have a nul byte for the
string, it will overflow the print:

  trace_seq_printf(s, ": %s", field->buf);

The field->buf could be missing the nul byte. To prevent overflow, add the
max size that the buf can be by using the event size and the field
location.

  int max = iter->ent_size - offsetof(struct print_entry, buf);

  trace_seq_printf(s, ": %*.s", max, field->buf);

Link: https://lore.kernel.org/linux-trace-kernel/20231212084444.4619b8ce@gandalf.local.home

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 14:33:30 -08:00
..
2023-01-18 11:30:39 +01:00
2019-12-13 08:51:11 +01:00
2023-12-20 15:38:01 +01:00
2021-02-10 09:21:06 +01:00
2020-03-25 08:06:13 +01:00
2021-02-07 14:48:38 +01:00
2020-01-09 10:18:59 +01:00