tracing: Don't make assumptions about length of string on task rename
Steven Rostedt
maintainerPATCH 1/1 tracing: Don't make assumptions about length of string on task rename
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: f0a515780393dffbb363e6d1567da46af6f3c5f3
Sasha Levin (1):
tracing: Don't make assumptions about length of string on task rename
----
include/trace/events/task.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --------------------------- commit f0a515780393dffbb363e6d1567da46af6f3c5f3 Author: Sasha Levin <[email protected]> Date: Fri Aug 28 07:06:58 2015 -0400
tracing: Don't make assumptions about length of string on task rename
While the dest comm string size is assured to be at least TASK_COMM_LEN long, doing a memcpy() also adds the assumption that the source is at least that long as well, which isn't assured, and isn't true in cases such as:
set_task_comm(worker->task, "kworker/dying");
This leads to accessing invalid memory.
Signed-off-by Sasha Levin <[email protected]>
Signed-off-by Steven Rostedt <[email protected]>
include/trace/events/task.h +1 -1
@@ -46,7 +46,7 @@ TRACE_EVENT(task_rename,TP_fast_assign ( __entry->pid = task->pid;memcpy (entry->oldcomm, task->comm,TASK_COMM_LEN ); -memcpy (entry->newcomm, comm,TASK_COMM_LEN ); +strlcpy (entry->newcomm, comm,TASK_COMM_LEN ); __entry->oom_score_adj = task->signal->oom_score_adj; ),