Re: [GIT PULL] execve updates for v6.13-rc1

From: Linus Torvalds
Date: Thu Nov 21 2024 - 12:47:32 EST


On Thu, 21 Nov 2024 at 09:28, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> See? There is no single solution, but at least the dentry name is a
> *reliable* thing, not a random garbage thing passed in by user space.

Note that the reason I want 'comm[]' to be something actually
*reliable* is that that is what the kernel actually uses for various
error messages etc.

User space tools like 'ps' already do the "dig around in user space to
look for argv[]" thing, and tools like "ps" do *not* actually use
comm[] at all from normal user space programs.

For example, why do you think "ps 3545" says

3545 ? Ssl 0:00 /usr/libexec/gnome-shell-calendar-server

but when I do "cat /proc/3545/stat" I see

3545 (gnome-shell-cal) S 3129 ...

in the output?

That's exactly because comm[] has that "gnome-shell-cal" (limited to
16 characters with the NUL due to TASK_COMM_LEN), but 'ps' will go
digging into user space argv[0] by looking at /proc/*/cmdline which
gets you much more than just the name of the executable.

And I do *not* want anybody to think that "comm[]" should act IN ANY
WAY identically to /proc/*/cmdline. It never has, and it never will.
Exactly because the two are completely different things, for different
uses.

And yes, people have historically actively messed with the argv[0]
thing, and actively tried to hide what the actual executable was.

I am not AT ALL interested in letting people play those kinds of games
with "comm[]".

There's a very real reason I rejected that original execve() change.
It was stupid and wrong.

Linus