Commit c4c1dbcc authored by Kees Cook's avatar Kees Cook Committed by Steven Rostedt (VMware)

tracing: Use memset_startat() to zero struct trace_iterator

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/20211118202217.1285588-1-keescook@chromium.orgSigned-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent f86b0aaa
...@@ -6706,9 +6706,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, ...@@ -6706,9 +6706,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
cnt = PAGE_SIZE - 1; cnt = PAGE_SIZE - 1;
/* reset all but tr, trace, and overruns */ /* reset all but tr, trace, and overruns */
memset(&iter->seq, 0, memset_startat(iter, 0, seq);
sizeof(struct trace_iterator) -
offsetof(struct trace_iterator, seq));
cpumask_clear(iter->started); cpumask_clear(iter->started);
trace_seq_init(&iter->seq); trace_seq_init(&iter->seq);
iter->pos = -1; iter->pos = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment