Re: [PATCH] coredump: Do not lock during 'comm' reporting

From: Andrew Morton
Date: Sat Sep 28 2024 - 17:46:44 EST


On Sat, 28 Sep 2024 14:39:45 -0700 Kees Cook <kees@xxxxxxxxxx> wrote:

> On Sat, Sep 28, 2024 at 02:35:32PM -0700, Andrew Morton wrote:
> > On Sat, 28 Sep 2024 14:08:31 -0700 Kees Cook <kees@xxxxxxxxxx> wrote:
> >
> > > The 'comm' member will always be NUL terminated,
> >
> > Why is this? I thought this is only true if the caller holds task_lock()?
>
> Because it's always written with strscpy_pad(). The final byte will
> always be NUL. (And this has been true for a very long time.)

So why does __get_task_comm() need to take task_lock()?