提交 cbdcf7f7 编写于 作者: M Michal Hocko 提交者: Linus Torvalds

mm, oom_reaper: do not use siglock in try_oom_reaper()

Oleg has noted that siglock usage in try_oom_reaper is both pointless
and dangerous.  signal_group_exit can be checked lockless.  The problem
is that sighand becomes NULL in __exit_signal so we can crash.

Fixes: 3ef22dff ("oom, oom_reaper: try to reap tasks which skip regular OOM killer path")
Link: http://lkml.kernel.org/r/1464679423-30218-1-git-send-email-mhocko@kernel.orgSigned-off-by: NMichal Hocko <mhocko@suse.com>
Suggested-by: NOleg Nesterov <oleg@redhat.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 83b9355b
...@@ -625,8 +625,6 @@ void try_oom_reaper(struct task_struct *tsk) ...@@ -625,8 +625,6 @@ void try_oom_reaper(struct task_struct *tsk)
if (atomic_read(&mm->mm_users) > 1) { if (atomic_read(&mm->mm_users) > 1) {
rcu_read_lock(); rcu_read_lock();
for_each_process(p) { for_each_process(p) {
bool exiting;
if (!process_shares_mm(p, mm)) if (!process_shares_mm(p, mm))
continue; continue;
if (fatal_signal_pending(p)) if (fatal_signal_pending(p))
...@@ -636,10 +634,7 @@ void try_oom_reaper(struct task_struct *tsk) ...@@ -636,10 +634,7 @@ void try_oom_reaper(struct task_struct *tsk)
* If the task is exiting make sure the whole thread group * If the task is exiting make sure the whole thread group
* is exiting and cannot acces mm anymore. * is exiting and cannot acces mm anymore.
*/ */
spin_lock_irq(&p->sighand->siglock); if (signal_group_exit(p->signal))
exiting = signal_group_exit(p->signal);
spin_unlock_irq(&p->sighand->siglock);
if (exiting)
continue; continue;
/* Give up */ /* Give up */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册