Thread (10 messages) 10 messages, 3 authors, 2025-08-13

Re: [PATCH v7 4/4] treewide: Switch memcpy() users of 'task->comm' to a more safer implementation

From: Andy Shevchenko <hidden>
Date: 2025-08-11 15:09:01
Also in: bpf, linux-fsdevel, linux-mm, linux-perf-users, lkml

On Mon, Aug 11, 2025 at 12:16:09PM +0530, Bhupesh wrote:
As Linus mentioned in [1], currently we have several memcpy() use-cases
which use 'current->comm' to copy the task name over to local copies.
For an example:

 ...
 char comm[TASK_COMM_LEN];
 memcpy(comm, current->comm, TASK_COMM_LEN);
 ...

These should be rather calling a wrappper like "get_task_array()",
which is implemented as:

   static __always_inline void
       __cstr_array_copy(char *dst,
            const char *src, __kernel_size_t size)
   {
        memcpy(dst, src, size);
        dst[size] = 0;
   }

   #define get_task_array(dst,src) \
      __cstr_array_copy(dst, src, __must_be_array(dst))

The relevant 'memcpy()' users were identified using the following search
pattern:
 $ git grep 'memcpy.*->comm\>'
[1]. https://lore.kernel.org/all/CAHk-=wi5c=_-FBGo_88CowJd_F-Gi6Ud9d=TALm65ReN7YjrMw@mail.gmail.com/ (local)

Signed-off-by: Bhupesh <redacted>
Same suggestion, make it a Link tag.

-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help