summaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_metrics.c
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-03-08 16:39:45 +0100
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-03-10 23:41:18 +0100
commit5677a3d713ad795e3ce32d631941e982777b43db (patch)
tree3721f7325edb65ffe1d2484da43a39a3e9574b04 /net/ipv4/tcp_metrics.c
parentuser_events: Fix potential uninitialized pointer while parsing field (diff)
downloadlinux-5677a3d713ad795e3ce32d631941e982777b43db.tar.xz
linux-5677a3d713ad795e3ce32d631941e982777b43db.zip
tracing: Fix last_cmd_set() string management in histogram code
Using strnlen(dest, str, n) is confusing, as the size of dest must be strlen(dest) + n + 1. Even more confusing, using sizeof(string constant) gives you strlen(string constant) + 1 and not just strlen(). These two together made using strncat() with a constant string a bit off in the calculations as we have: len = sizeof(HIST_PREFIX) + strlen(str) + 1; kfree(last_cmd); last_cmd = kzalloc(len, GFP_KERNEL); strcpy(last_cmd, HIST_PREFIX); len -= sizeof(HIST_PREFIX) + 1; strncat(last_cmd, str, len); The above works if we s/sizeof/strlen/ with HIST_PREFIX (which is defined as "hist:", but because sizeof(HIST_PREFIX) is equal to strlen(HIST_PREFIX) + 1, we can drop the +1 in the code. But at least comment that we are doing so. Link: https://lore.kernel.org/all/202203082112.Iu7tvFl4-lkp@intel.com/ Fixes: 9f8e5aee93ed2 ("tracing: Fix allocation of last_cmd in last_cmd_set()") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'net/ipv4/tcp_metrics.c')
0 files changed, 0 insertions, 0 deletions