Skip to content

Commit

Permalink
tracing: Use memset_startat() to zero struct trace_iterator
Browse files Browse the repository at this point in the history
In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memset(), avoid intentionally writing across
neighboring fields.

Use memset_startat() to avoid confusing memset() about writing beyond
the target struct member.

Link: https://lkml.kernel.org/r/[email protected]

Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
kees authored and rostedt committed Nov 19, 2021
1 parent f86b0aa commit c4c1dbc
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6706,9 +6706,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
cnt = PAGE_SIZE - 1;

/* reset all but tr, trace, and overruns */
memset(&iter->seq, 0,
sizeof(struct trace_iterator) -
offsetof(struct trace_iterator, seq));
memset_startat(iter, 0, seq);
cpumask_clear(iter->started);
trace_seq_init(&iter->seq);
iter->pos = -1;
Expand Down

0 comments on commit c4c1dbc

Please sign in to comment.