lkml.org 
[lkml]   [2022]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] cgroup: align the comm length with TASK_COMM_LEN
On Mon, 26 Sep 2022 10:18:55 +0800
Kassey Li <quic_yingangl@quicinc.com> wrote:

> >> @@ -139,12 +139,12 @@ DECLARE_EVENT_CLASS(cgroup_migrate,
> >> __entry->dst_level = dst_cgrp->level;
> >> __assign_str(dst_path, path);
> >> __entry->pid = task->pid;
> >> - __assign_str(comm, task->comm);
> >> + memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
> I think the problem is here, __assign_str using strcpy
> the task->comm here tail is not '\0'
> that's why it out of bounds access.
>

If this is the case, then there's a lot more than just tracing that will
break. There are other places in the kernel has used strcpy() on task->comm,
and many more that do "%s" on task->comm, which would also crash on this.

> do you want to this version or just modify the memcpy or strncpy to do
> with a known length ? please give suggest so I can modify .

I'm guessing a problem exists elsewhere that makes it look like this is the
issue. I suggest finding where the '\0' is dropped (if that is indeed the
case).

-- Steve

\
 
 \ /
  Last update: 2022-09-26 04:42    [W:0.363 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site