Re: [PATCH v2 05/10] mm/util: Fix possible race condition in kstrdup()

2024-06-14 Thread Yafang Shao
On Fri, Jun 14, 2024 at 6:18 AM Linus Torvalds wrote: > > On Thu, 13 Jun 2024 at 14:14, Andrew Morton wrote: > > > > The concept sounds a little strange. If some code takes a copy of a > > string while some other code is altering it, yes, the result will be a > > mess. This is why get_task_comm

Re: [PATCH v2 05/10] mm/util: Fix possible race condition in kstrdup()

2024-06-14 Thread Yafang Shao
On Fri, Jun 14, 2024 at 5:14 AM Andrew Morton wrote: > > On Thu, 13 Jun 2024 10:30:39 +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. > > > > Co

Re: [PATCH v2 05/10] mm/util: Fix possible race condition in kstrdup()

2024-06-13 Thread Linus Torvalds
On Thu, 13 Jun 2024 at 14:14, Andrew Morton wrote: > > The concept sounds a little strange. If some code takes a copy of a > string while some other code is altering it, yes, the result will be a > mess. This is why get_task_comm() exists, and why it uses locking. The thing is, get_task_comm()

Re: [PATCH v2 05/10] mm/util: Fix possible race condition in kstrdup()

2024-06-13 Thread Andrew Morton
On Thu, 13 Jun 2024 10:30:39 +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: > > reader

[PATCH v2 05/10] mm/util: Fix possible race condition in kstrdup()

2024-06-13 Thread Yafang Shao
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: readerwriter len = strlen(s) + 1;