ANDROID: sched/events: Fix out of bound memory access
authorQuentin Perret <quentin.perret@arm.com>
Fri, 14 Dec 2018 09:05:20 +0000 (09:05 +0000)
committerQuentin Perret <quentin.perret@arm.com>
Mon, 17 Dec 2018 09:25:38 +0000 (09:25 +0000)
commitc6ced91f3c12de5906a1b9c898ceaf334424a9d1
treeb7dd89c7b440da9bc0260824db204b667f90eca0
parent310c9f0e31c82927bef8a4172df3dd36c6be980c
ANDROID: sched/events: Fix out of bound memory access

GCC 8 provides the following warning:

./include/trace/events/sched.h:736:3: warning: ‘memcpy’ forming offset
[8, 16] is out of the bounds [0, 7] [-Warray-bounds]
   memcpy(__entry->comm, p ? p->comm : "(null)", TASK_COMM_LEN);

Indeed, in the case where p==NULL, we copy TASK_COMM_LEN bytes from the
memory location where "(null)" is stored, which is incorrect.

Fix this by making sure to pass the right size parameter to memcpy in
all cases.

Bug: 120440300
Test: Compilation warning gone, no changes noticed in traces
Fixes: acfe25da3551 ("ANDROID: sched/events: Introduce sched_entity load
tracking trace event")
Change-Id: Id93c9c0265f10c09b731daca25401696785b4b1e
Suggested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
include/trace/events/sched.h