Re: [PATCH 1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case

2024-11-06 Thread Christian Brauner
On Wed, Oct 30, 2024 at 02:37:31PM -0600, Tycho Andersen wrote:
> From: Tycho Andersen 
> 
> Zbigniew mentioned at Linux Plumber's that systemd is interested in
> switching to execveat() for service execution, but can't, because the
> contents of /proc/pid/comm are the file descriptor which was used,
> instead of the path to the binary. This makes the output of tools like
> top and ps useless, especially in a world where most fds are opened
> CLOEXEC so the number is truly meaningless.
> 
> Change exec path to fix up /proc/pid/comm in the case where we have
> allocated one of these synthetic paths in bprm_init(). This way the actual
> exec machinery is unchanged, but cosmetically the comm looks reasonable to
> admins investigating things.
> 
> Signed-off-by: Tycho Andersen 
> Suggested-by: Zbigniew Jędrzejewski-Szmek 
> CC: Aleksa Sarai 
> Link: https://github.com/uapi-group/kernel-features#set-comm-field-before-exec
> ---

We finally went full circle back to what was originally proposed :)

Reviewed-by: Christian Brauner 



Re: [PATCH 1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case

2024-11-02 Thread Kees Cook
On Sat, Nov 02, 2024 at 11:29:55AM +, Zbigniew Jędrzejewski-Szmek wrote:
> On Thu, Oct 31, 2024 at 03:10:37PM -0700, Kees Cook wrote:
> > On Wed, 30 Oct 2024 14:37:31 -0600, Tycho Andersen wrote:
> > > Zbigniew mentioned at Linux Plumber's that systemd is interested in
> > > switching to execveat() for service execution, but can't, because the
> > > contents of /proc/pid/comm are the file descriptor which was used,
> > > instead of the path to the binary. This makes the output of tools like
> > > top and ps useless, especially in a world where most fds are opened
> > > CLOEXEC so the number is truly meaningless.
> > > 
> > > [...]
> > 
> > Applied to for-next/execve, thanks!
> > 
> > [1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case
> >   https://git.kernel.org/kees/c/7bdc6fc85c9a
> > [2/2] selftests/exec: add a test for execveat()'s comm
> >   https://git.kernel.org/kees/c/bd104872311a
> 
> I tested this with systemd compiled with -Dfexece=true and it all
> seems to work fine. Thanks!

Great; thank you!

-- 
Kees Cook



Re: [PATCH 1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case

2024-11-02 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Oct 31, 2024 at 03:10:37PM -0700, Kees Cook wrote:
> On Wed, 30 Oct 2024 14:37:31 -0600, Tycho Andersen wrote:
> > Zbigniew mentioned at Linux Plumber's that systemd is interested in
> > switching to execveat() for service execution, but can't, because the
> > contents of /proc/pid/comm are the file descriptor which was used,
> > instead of the path to the binary. This makes the output of tools like
> > top and ps useless, especially in a world where most fds are opened
> > CLOEXEC so the number is truly meaningless.
> > 
> > [...]
> 
> Applied to for-next/execve, thanks!
> 
> [1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case
>   https://git.kernel.org/kees/c/7bdc6fc85c9a
> [2/2] selftests/exec: add a test for execveat()'s comm
>   https://git.kernel.org/kees/c/bd104872311a

I tested this with systemd compiled with -Dfexece=true and it all
seems to work fine. Thanks!

Zbyszek



Re: [PATCH 1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case

2024-10-31 Thread Kees Cook
On Wed, 30 Oct 2024 14:37:31 -0600, Tycho Andersen wrote:
> Zbigniew mentioned at Linux Plumber's that systemd is interested in
> switching to execveat() for service execution, but can't, because the
> contents of /proc/pid/comm are the file descriptor which was used,
> instead of the path to the binary. This makes the output of tools like
> top and ps useless, especially in a world where most fds are opened
> CLOEXEC so the number is truly meaningless.
> 
> [...]

Applied to for-next/execve, thanks!

[1/2] exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case
  https://git.kernel.org/kees/c/7bdc6fc85c9a
[2/2] selftests/exec: add a test for execveat()'s comm
  https://git.kernel.org/kees/c/bd104872311a

Take care,

-- 
Kees Cook