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

2024-11-30 Thread Christian Brauner
On Fri, Nov 29, 2024 at 08:54:38PM -0800, Kees Cook 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

Re: [PATCH v2] printf: Remove unused 'bprintf'

2024-11-30 Thread Steven Rostedt
On Sun, 1 Dec 2024 02:47:49 + "Dr. David Alan Gilbert" wrote: > > > suggested at > > > https://lore.kernel.org/r/20241002104807.42b4b...@gandalf.local.home > > > > Yeah, since I'm basically the only user of it, it's best it goes through my > > testing. > > Hmm, did you pick this one up

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

2024-11-30 Thread Linus Torvalds
On Sat, 30 Nov 2024 at 12:28, Mateusz Guzik wrote: > > > + /* The dentry name won't change while we hold the rcu read > > lock. */ > > + __set_task_comm(me, > > smp_load_acquire(&bprm->file->f_path.dentry->d_name.name), > > + true); > > This do

Re: [PATCH] exec: Make sure task->comm is always NUL-terminated

2024-11-30 Thread Linus Torvalds
On Sat, 30 Nov 2024 at 13:05, Kees Cook wrote: > > Yeah, this just means it has greater potential to be garbled. Garbled is fine. Id' just rather it be "consistently padded". > This is fine, but it doesn't solve either an unstable source nor > concurrent writers to dest. Yeah, I guess concurren

RE: [PATCH] exec: Make sure task->comm is always NUL-terminated

2024-11-30 Thread David Laight
From: Kees Cook > Sent: 30 November 2024 04:49 > > Instead of adding a new use of the ambiguous strncpy(), we'd want to > use memtostr_pad() which enforces being able to check at compile time > that sizes are sensible, but this requires being able to see string > buffer lengths. Instead of trying t

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

2024-11-30 Thread Mateusz Guzik
On Fri, Nov 29, 2024 at 08:54:38PM -0800, Kees Cook 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

Re: [PATCH v2] printf: Remove unused 'bprintf'

2024-11-30 Thread Dr. David Alan Gilbert
* Steven Rostedt (rost...@goodmis.org) wrote: > On Thu, 3 Oct 2024 10:13:34 +0200 > Petr Mladek wrote: > > > On Wed 2024-10-02 18:31:47, li...@treblig.org wrote: > > > From: "Dr. David Alan Gilbert" > > > > > > bprintf() is unused. Remove it. It was added in the commit 4370aa4aa753 > > > ("vspr

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

2024-11-30 Thread Linus Torvalds
On Sat, 30 Nov 2024 at 04:30, Christian Brauner wrote: > > What does the smp_load_acquire() pair with? I'm not sure we have them everywhere, but at least this one at dentry creation time. __d_alloc(): /* Make sure we always see the terminating NUL character */ smp_store_release(&

Re: [PATCH] exec: Make sure task->comm is always NUL-terminated

2024-11-30 Thread Kees Cook
On Fri, Nov 29, 2024 at 11:15:44PM -0800, Linus Torvalds wrote: > Edited down to just the end result: > > On Fri, 29 Nov 2024 at 20:49, Kees Cook wrote: > > > > void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) > > { > > size_t len = min(strlen(buf), sizeof(tsk->