lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <B9C50D0B-DCD9-41A2-895D-4899728AF605@kernel.org>
Date: Sat, 26 Jul 2025 16:19:18 -0700
From: Kees Cook <kees@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
CC: Bhupesh <bhupesh@...lia.com>, akpm@...ux-foundation.org,
 kernel-dev@...lia.com, linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
 linux-perf-users@...r.kernel.org, linux-fsdevel@...r.kernel.org,
 linux-mm@...ck.org, oliver.sang@...el.com, lkp@...el.com,
 laoar.shao@...il.com, pmladek@...e.com, rostedt@...dmis.org,
 mathieu.desnoyers@...icios.com, arnaldo.melo@...il.com,
 alexei.starovoitov@...il.com, andrii.nakryiko@...il.com,
 mirq-linux@...e.qmqm.pl, peterz@...radead.org, willy@...radead.org,
 david@...hat.com, viro@...iv.linux.org.uk, ebiederm@...ssion.com,
 brauner@...nel.org, jack@...e.cz, mingo@...hat.com, juri.lelli@...hat.com,
 bsegall@...gle.com, mgorman@...e.de, vschneid@...hat.com,
 linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v6 2/3] treewide: Switch memcpy() users of 'task->comm' to a more safer implementation



On July 26, 2025 10:50:55 AM PDT, Linus Torvalds <torvalds@...ux-foundation.org> wrote:
>, but
>
>On Thu, 24 Jul 2025 at 16:49, Kees Cook <kees@...nel.org> 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ