Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-09-29 Thread Alejandro Colomar
On Sun, Sep 29, 2024 at 09:58:30AM GMT, Alejandro Colomar wrote: > [CC += Andy, Gustavo] > > On Sat, Sep 28, 2024 at 02:17:30PM GMT, Kees Cook wrote: > > > > diff --git a/mm/util.c b/mm/util.c > > > > index 983baf2bd675..4542d8a800d9 100644 > > > > --- a/mm/util.c > > > > +++ b/mm/util.c > > > > @

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-09-29 Thread Alejandro Colomar
[CC += Andy, Gustavo] On Sat, Sep 28, 2024 at 02:17:30PM GMT, Kees Cook wrote: > > > diff --git a/mm/util.c b/mm/util.c > > > index 983baf2bd675..4542d8a800d9 100644 > > > --- a/mm/util.c > > > +++ b/mm/util.c > > > @@ -62,8 +62,14 @@ char *kstrdup(const char *s, gfp_t gfp) > > > > > > len = s

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-09-28 Thread Kees Cook
On Sat, Aug 17, 2024 at 10:48:15AM +0200, Alejandro Colomar wrote: > Hi Yafang, > > On Sat, Aug 17, 2024 at 10:56:21AM GMT, Yafang Shao wrote: > > In kstrdup(), it is critical to ensure that the dest string is always > > NUL-terminated. However, potential race condidtion can occur between a > > wr

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-09-28 Thread Kees Cook
On Sat, Aug 17, 2024 at 10:56:21AM +0800, Yafang Shao wrote: > In kstrdup(), it is critical to ensure that the dest string is always > NUL-terminated. However, potential race condidtion can occur between a > writer and a reader. > > Consider the following scenario involving task->comm: > > re

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-09-27 Thread Yafang Shao
On Fri, Sep 27, 2024 at 1:35 AM Andy Shevchenko wrote: > > On Thu, Sep 26, 2024 at 7:44 PM Yafang Shao wrote: > > > > In kstrdup(), it is critical to ensure that the dest string is always > > NUL-terminated. However, potential race condidtion can occur between a > > condition > > > writer and a r

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-09-26 Thread Andy Shevchenko
On Thu, Sep 26, 2024 at 7:44 PM Yafang Shao wrote: > > In kstrdup(), it is critical to ensure that the dest string is always > NUL-terminated. However, potential race condidtion can occur between a condition > writer and a reader. > > Consider the following scenario involving task->comm: > >

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-08-17 Thread Alejandro Colomar
Hi Linus, On Sat, Aug 17, 2024 at 09:26:21AM GMT, Linus Torvalds wrote: > On Sat, 17 Aug 2024 at 01:48, Alejandro Colomar wrote: > > > > I would compact the above to: > > > > len = strlen(s); > > buf = kmalloc_track_caller(len + 1, gfp); > > if (buf) > > st

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-08-17 Thread Linus Torvalds
On Sat, 17 Aug 2024 at 01:48, Alejandro Colomar wrote: > > I would compact the above to: > > len = strlen(s); > buf = kmalloc_track_caller(len + 1, gfp); > if (buf) > strcpy(mempcpy(buf, s, len), ""); No, we're not doing this kind of horror. If _FORTIFY_SO

Re: [PATCH v7 5/8] mm/util: Fix possible race condition in kstrdup()

2024-08-17 Thread Alejandro Colomar
Hi Yafang, On Sat, Aug 17, 2024 at 10:56:21AM GMT, Yafang Shao wrote: > In kstrdup(), it is critical to ensure that the dest string is always > NUL-terminated. However, potential race condidtion can occur between a > writer and a reader. > > Consider the following scenario involving task->comm: >