tracing: Apply upper limit of pid to prevent buffer overflow 51/287651/2 accepted/tizen_7.0_unified tizen_7.0 accepted/tizen/7.0/unified/20230203.164135 accepted/tizen/unified/20230206.093830 accepted/tizen/unified/20230206.093947
authorSung-hun Kim <sfoon.kim@samsung.com>
Thu, 2 Feb 2023 03:05:37 +0000 (12:05 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Thu, 2 Feb 2023 05:00:09 +0000 (14:00 +0900)
commit5f8b7fabcfbf3d7554c934f36af4a7ca3bb13e0b
tree3e29a708cf1aab9cf4ac9289f8d6a08aed4546b4
parent9c5d931a9e4710a5cd2dd4ae737bec807b4da371
tracing: Apply upper limit of pid to prevent buffer overflow

A member array `map_pid_to_cmdline` is allocated as much as
PID_MAX_DEFAULT. There is no consideration when a given pid
exceeds PID_MAX_DEFAULT which can make buffer overflow.

This patch handles such cases by just returning -1 for a case
that the given pid exceeds PID_MAX_DEFAULT. For such cases,
the user of trace loses tgid information for a given pid.

Change-Id: I589eda187490eddbd26fa5300a288097842d9af0
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
kernel/trace/trace.c