On July 26, 2025 10:50:55 AM PDT, Linus Torvalds 
<[email protected]> wrote:
>, but
>
>On Thu, 24 Jul 2025 at 16:49, Kees Cook <[email protected]> wrote:
>>
>> Why not switch all of these to get_task_comm()? It will correctly handle
>> the size check and NUL termination.
>
>I'd rather aim to get rid of get_task_comm() entirely.

That works for me! I just get twitchy around seeing memcpy used for strings. :) 
if we're gonna NUL after the memcpy, just use strscpy_pad().

>And guess what? We *have* that function. It's called "strscpy()". It
>already does the right thing, including passing in the size of a fixed
>array and just dealing with it the RightWay(tm). Add '_pad()' if that
>is the behavior you want, and now you *document* the fact that the
>result is padded.

Exactly. Let's see how much we can just replace with strscpy_pad(). It we have 
other use cases, we can handle those separately.

-Kees

-- 
Kees Cook

Reply via email to