tracing: Have traceprobe_probes_write() not access userspace unnecessarily
commit1f9b3546cf4c273b6d809003244d05cf0460a5e9
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 9 Feb 2017 22:53:50 +0000 (9 17:53 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 15 Feb 2017 14:00:55 +0000 (15 09:00 -0500)
tree67b22717ba453ac9afbf9bd84ae261cd4ae05772
parent4c7384131c8d343c0bf79abac3b3e78596d85b10
tracing: Have traceprobe_probes_write() not access userspace unnecessarily

The code in traceprobe_probes_write() reads up to 4096 bytes from userpace
for each line. If userspace passes in several lines to execute, the code
will do a large read for each line, even though, it is highly likely that
the first read from userspace received all of the lines at once.

I changed the logic to do a single read from userspace, and to only read
from userspace again if not all of the read from userspace made it in.

I tested this by adding printk()s and writing files that would test -1, ==,
and +1 the buffer size, to make sure that there's no overflows and that if a
single line is written with +1 the buffer size, that it fails properly.

Link: http://lkml.kernel.org/r/20170209180458.5c829ab2@gandalf.local.home
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_probe.c