lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 28 Nov 2013 10:18:50 +0100
From:	"azurIt" <azurit@...ox.sk>
To:	Johannes Weiner <hannes@...xchg.org>,
	Ma, Xindong <xindong.ma@...el.com>
Cc:	akpm@...ux-foundation.org 
	<akpm@...ux-foundation.org>,
	mhocko@...e.cz <mhocko@...e.cz>,
	rientjes@...gle.com <rientjes@...gle.com>,
	rusty@...tcorp.com.au <rusty@...tcorp.com.au>,
	linux-mm@...ck.org <linux-mm@...ck.org>,
	linux-kernel@...r.kernel.org 
	<linux-kernel@...r.kernel.org>,
	'Peter Zijlstra' <peterz@...radead.org>,
	'gregkh@...uxfoundation.org' 
	<gregkh@...uxfoundation.org>,
	Tu, Xiaobing <xiaobing.tu@...el.com>,
	William Dauchy <wdauchy@...il.com>
Subject: Re: [PATCH] Fix race between oom kill and task exit

> Od: Johannes Weiner <hannes@...xchg.org>
> Komu: "Ma, Xindong" <xindong.ma@...el.com>
> Dátum: 28.11.2013 07:54
> Predmet: Re: [PATCH] Fix race between oom kill and task exit
>
> CC: "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>, "mhocko@...e.cz" <mhocko@...e.cz>, "rientjes@...gle.com" <rientjes@...gle.com>, "rusty@...tcorp.com.au" <rusty@...tcorp.com.au>, "linux-mm@...ck.org" <linux-mm@...ck.org>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "'Peter Zijlstra'" <peterz@...radead.org>, "'gregkh@...uxfoundation.org'" <gregkh@...uxfoundation.org>, "Tu, Xiaobing" <xiaobing.tu@...el.com>, "William Dauchy" <wdauchy@...il.com>
>Cc William and azur who might have encountered this problem.
>
>On Thu, Nov 28, 2013 at 05:09:16AM +0000, Ma, Xindong wrote:
>> From: Leon Ma <xindong.ma@...el.com>
>> Date: Thu, 28 Nov 2013 12:46:09 +0800
>> Subject: [PATCH] Fix race between oom kill and task exit
>> 
>> There is a race between oom kill and task exit. Scenario is:
>>    TASK  A                      TASK  B
>> TASK B is selected to oom kill
>> in oom_kill_process()
>> check PF_EXITING of TASK B
>>                             task call do_exit()
>>                             task set PF_EXITING flag
>>                             write_lock_irq(&tasklist_lock);
>>                             remove TASK B from thread group in __unhash_process()
>>                             write_unlock_irq(&tasklist_lock);
>> read_lock(&tasklist_lock);
>> traverse threads of TASK B
>> read_unlock(&tasklist_lock);
>> 
>> After that, the following traversal of threads in TASK B will not end because TASK B is not in the thread group:
>> do {
>> ....
>> } while_each_thread(p, t);
>> 
>> Signed-off-by: Leon Ma <xindong.ma@...el.com>
>> Signed-off-by: xiaobing tu <xiaobing.tu@...el.com>
>> ---
>>  mm/oom_kill.c |   20 ++++++++++----------
>>  1 files changed, 10 insertions(+), 10 deletions(-)
>> 
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index 1e4a600..32ec88d 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -412,16 +412,6 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
>>  	static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
>>  					      DEFAULT_RATELIMIT_BURST);
>>  
>> -	/*
>> -	 * If the task is already exiting, don't alarm the sysadmin or kill
>> -	 * its children or threads, just set TIF_MEMDIE so it can die quickly
>> -	 */
>> -	if (p->flags & PF_EXITING) {
>> -		set_tsk_thread_flag(p, TIF_MEMDIE);
>> -		put_task_struct(p);
>> -		return;
>> -	}
>> -
>>  	if (__ratelimit(&oom_rs))
>>  		dump_header(p, gfp_mask, order, memcg, nodemask);
>>  
>> @@ -437,6 +427,16 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
>>  	 * still freeing memory.
>>  	 */
>>  	read_lock(&tasklist_lock);
>> +	/*
>> +	 * If the task is already exiting, don't alarm the sysadmin or kill
>> +	 * its children or threads, just set TIF_MEMDIE so it can die quickly
>> +	 */
>> +	if (p->flags & PF_EXITING) {
>> +		set_tsk_thread_flag(p, TIF_MEMDIE);
>> +		put_task_struct(p);
>> +		read_unlock(&tasklist_lock);
>> +		return;
>> +	}
>>  	do {
>>  		list_for_each_entry(child, &t->children, sibling) {
>>  			unsigned int child_points;
>> -- 
>> 1.7.4.1
>> 
>




Hi Johannes,

thank you very much! Fortunately, i didn't notice anything like this yet.

azur
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ