Re: [GIT PULL] execve updates for v6.13-rc1 (take 2)

From: Al Viro
Date: Wed Nov 27 2024 - 21:06:13 EST


On Wed, Nov 27, 2024 at 05:59:53PM -0800, Linus Torvalds wrote:
> On Wed, 27 Nov 2024 at 16:53, Kees Cook <kees@xxxxxxxxxx> wrote:
> >
> > On a related note, what do you think of using execveat's "pathname"
> > argument as "comm" if AT_EMPTY_PATH is set? That'll give process
> > launchers control over comm (which is what they want), and we can keep
> > the dentry name fallback as proposed too?
>
> That's not actually how AT_EMPTY_PATH works.
>
> Yes, it's how AT_EMPTY_PATH *should* work, but despite the name,
> AT_EMPTYH_PATH does not mean "path is empty".
>
> It means "path *may* be empty - but if path isn't empty, it's a regular path".
>
> IOW, what is going on is that POSIX required that an empty path be an
> error. And AT_EMPTY_PATH is basically a "don't error out on an empty
> path" flag, not a "path *is* empty" flag.
>
> So if pathname exists and isn't empty, AT_EMPTY_PATH does nothing.

... so let's tie that to pathname _being_ empty - it's not as if it
had been hard to check.

What's more, let's allow userland pointer to be NULL - use getname_maybe_null()
and treat NULL returned by it as "we have an empty pathname".