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

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.org



Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent f86b0aaa
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;