All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: use mm.arg_lock in get_cmdline()
@ 2019-04-18 12:58 Laurent Dufour
  2019-04-18 13:03 ` Michal Hocko
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Dufour @ 2019-04-18 12:58 UTC (permalink / raw)
  To: mhocko, akpm; +Cc: linux-mm, linux-kernel, Yang Shi

The commit 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end
and env_start|end in mm_struct") introduce the spinlock arg_lock to protect
the arg_* and env_* field of the mm_struct structure.

While reading the code, I found that this new spinlock was not used in
get_cmdline() to protect access to these fields.

Fixing this even if there is no issue reported yet for this.

Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct")
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
---
 mm/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/util.c b/mm/util.c
index 05a464929b3e..789760c3028b 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
 	if (!mm->arg_end)
 		goto out_mm;	/* Shh! No looking before we're done */
 
-	down_read(&mm->mmap_sem);
+	spin_lock(&mm->arg_lock);
 	arg_start = mm->arg_start;
 	arg_end = mm->arg_end;
 	env_start = mm->env_start;
 	env_end = mm->env_end;
-	up_read(&mm->mmap_sem);
+	spin_unlock(&mm->arg_lock);
 
 	len = arg_end - arg_start;
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: use mm.arg_lock in get_cmdline()
  2019-04-18 12:58 [PATCH] mm: use mm.arg_lock in get_cmdline() Laurent Dufour
@ 2019-04-18 13:03 ` Michal Hocko
  2019-04-18 13:05   ` Laurent Dufour
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2019-04-18 13:03 UTC (permalink / raw)
  To: Laurent Dufour; +Cc: akpm, linux-mm, linux-kernel, Yang Shi, Michal Koutny

Michal has posted the same patch few days ago http://lkml.kernel.org/r/20190417120347.15397-1-mkoutny@suse.com

On Thu 18-04-19 14:58:27, Laurent Dufour wrote:
> The commit 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end
> and env_start|end in mm_struct") introduce the spinlock arg_lock to protect
> the arg_* and env_* field of the mm_struct structure.
> 
> While reading the code, I found that this new spinlock was not used in
> get_cmdline() to protect access to these fields.
> 
> Fixing this even if there is no issue reported yet for this.
> 
> Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct")
> Cc: Yang Shi <yang.shi@linux.alibaba.com>
> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
> ---
>  mm/util.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/util.c b/mm/util.c
> index 05a464929b3e..789760c3028b 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
>  	if (!mm->arg_end)
>  		goto out_mm;	/* Shh! No looking before we're done */
>  
> -	down_read(&mm->mmap_sem);
> +	spin_lock(&mm->arg_lock);
>  	arg_start = mm->arg_start;
>  	arg_end = mm->arg_end;
>  	env_start = mm->env_start;
>  	env_end = mm->env_end;
> -	up_read(&mm->mmap_sem);
> +	spin_unlock(&mm->arg_lock);
>  
>  	len = arg_end - arg_start;
>  
> -- 
> 2.21.0

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: use mm.arg_lock in get_cmdline()
  2019-04-18 13:03 ` Michal Hocko
@ 2019-04-18 13:05   ` Laurent Dufour
  2019-04-18 16:48     ` Yang Shi
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Dufour @ 2019-04-18 13:05 UTC (permalink / raw)
  To: Michal Hocko; +Cc: akpm, linux-mm, linux-kernel, Yang Shi, Michal Koutny

Le 18/04/2019 à 15:03, Michal Hocko a écrit :
> Michal has posted the same patch few days ago http://lkml.kernel.org/r/20190417120347.15397-1-mkoutny@suse.com

Oups, sorry for the noise, I missed it.

> On Thu 18-04-19 14:58:27, Laurent Dufour wrote:
>> The commit 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end
>> and env_start|end in mm_struct") introduce the spinlock arg_lock to protect
>> the arg_* and env_* field of the mm_struct structure.
>>
>> While reading the code, I found that this new spinlock was not used in
>> get_cmdline() to protect access to these fields.
>>
>> Fixing this even if there is no issue reported yet for this.
>>
>> Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct")
>> Cc: Yang Shi <yang.shi@linux.alibaba.com>
>> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
>> ---
>>   mm/util.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/util.c b/mm/util.c
>> index 05a464929b3e..789760c3028b 100644
>> --- a/mm/util.c
>> +++ b/mm/util.c
>> @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
>>   	if (!mm->arg_end)
>>   		goto out_mm;	/* Shh! No looking before we're done */
>>   
>> -	down_read(&mm->mmap_sem);
>> +	spin_lock(&mm->arg_lock);
>>   	arg_start = mm->arg_start;
>>   	arg_end = mm->arg_end;
>>   	env_start = mm->env_start;
>>   	env_end = mm->env_end;
>> -	up_read(&mm->mmap_sem);
>> +	spin_unlock(&mm->arg_lock);
>>   
>>   	len = arg_end - arg_start;
>>   
>> -- 
>> 2.21.0
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: use mm.arg_lock in get_cmdline()
  2019-04-18 13:05   ` Laurent Dufour
@ 2019-04-18 16:48     ` Yang Shi
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Shi @ 2019-04-18 16:48 UTC (permalink / raw)
  To: Laurent Dufour, Michal Hocko; +Cc: akpm, linux-mm, linux-kernel, Michal Koutny



On 4/18/19 6:05 AM, Laurent Dufour wrote:
> Le 18/04/2019 à 15:03, Michal Hocko a écrit :
>> Michal has posted the same patch few days ago 
>> http://lkml.kernel.org/r/20190417120347.15397-1-mkoutny@suse.com
>
> Oups, sorry for the noise, I missed it.

Yes, Michal already posted a similar patch. Anyway, thanks for catching 
this.

>
>> On Thu 18-04-19 14:58:27, Laurent Dufour wrote:
>>> The commit 88aa7cc688d4 ("mm: introduce arg_lock to protect 
>>> arg_start|end
>>> and env_start|end in mm_struct") introduce the spinlock arg_lock to 
>>> protect
>>> the arg_* and env_* field of the mm_struct structure.
>>>
>>> While reading the code, I found that this new spinlock was not used in
>>> get_cmdline() to protect access to these fields.
>>>
>>> Fixing this even if there is no issue reported yet for this.
>>>
>>> Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect 
>>> arg_start|end and env_start|end in mm_struct")
>>> Cc: Yang Shi <yang.shi@linux.alibaba.com>
>>> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
>>> ---
>>>   mm/util.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/mm/util.c b/mm/util.c
>>> index 05a464929b3e..789760c3028b 100644
>>> --- a/mm/util.c
>>> +++ b/mm/util.c
>>> @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char 
>>> *buffer, int buflen)
>>>       if (!mm->arg_end)
>>>           goto out_mm;    /* Shh! No looking before we're done */
>>>   -    down_read(&mm->mmap_sem);
>>> +    spin_lock(&mm->arg_lock);
>>>       arg_start = mm->arg_start;
>>>       arg_end = mm->arg_end;
>>>       env_start = mm->env_start;
>>>       env_end = mm->env_end;
>>> -    up_read(&mm->mmap_sem);
>>> +    spin_unlock(&mm->arg_lock);
>>>         len = arg_end - arg_start;
>>>   --
>>> 2.21.0
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-18 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 12:58 [PATCH] mm: use mm.arg_lock in get_cmdline() Laurent Dufour
2019-04-18 13:03 ` Michal Hocko
2019-04-18 13:05   ` Laurent Dufour
2019-04-18 16:48     ` Yang Shi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.