* [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks
[not found] <20091210001308.247025548@linutronix.de>
@ 2009-12-10 0:53 ` Thomas Gleixner
2009-12-10 1:57 ` KOSAKI Motohiro
2009-12-11 13:49 ` David Howells
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2009-12-10 0:53 UTC (permalink / raw)
To: LKML
Cc: Paul E. McKenney, Dipankar Sarma, Ingo Molnar, Peter Zijlstra,
Oleg Nesterov, Al Viro, James Morris, David Howells,
Andrew Morton, Linus Torvalds, linux-mm
[-- Attachment #1: oom-fix-missing-rcu-protection-of-__task_cred.patch --]
[-- Type: text/plain, Size: 1220 bytes --]
dump_tasks accesses __task_cred() without being in a RCU read side
critical section. tasklist_lock is not protecting that when
CONFIG_TREE_PREEMPT_RCU=y.
Add a rcu_read_lock/unlock() section around the code which accesses
__task_cred().
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
---
mm/oom_kill.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-2.6-tip/mm/oom_kill.c
===================================================================
--- linux-2.6-tip.orig/mm/oom_kill.c
+++ linux-2.6-tip/mm/oom_kill.c
@@ -329,10 +329,13 @@ static void dump_tasks(const struct mem_
task_unlock(p);
continue;
}
+ /* Protect __task_cred() access */
+ rcu_read_lock();
printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n",
p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
get_mm_rss(mm), (int)task_cpu(p), p->signal->oom_adj,
p->comm);
+ rcu_read_unlock();
task_unlock(p);
} while_each_thread(g, p);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks
2009-12-10 0:53 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks Thomas Gleixner
@ 2009-12-10 1:57 ` KOSAKI Motohiro
0 siblings, 0 replies; 4+ messages in thread
From: KOSAKI Motohiro @ 2009-12-10 1:57 UTC (permalink / raw)
To: Thomas Gleixner
Cc: kosaki.motohiro, LKML, Paul E. McKenney, Dipankar Sarma,
Ingo Molnar, Peter Zijlstra, Oleg Nesterov, Al Viro,
James Morris, David Howells, Andrew Morton, Linus Torvalds,
linux-mm
> dump_tasks accesses __task_cred() without being in a RCU read side
> critical section. tasklist_lock is not protecting that when
> CONFIG_TREE_PREEMPT_RCU=y.
>
> Add a rcu_read_lock/unlock() section around the code which accesses
> __task_cred().
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-mm@kvack.org
> ---
> mm/oom_kill.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> Index: linux-2.6-tip/mm/oom_kill.c
> ===================================================================
> --- linux-2.6-tip.orig/mm/oom_kill.c
> +++ linux-2.6-tip/mm/oom_kill.c
> @@ -329,10 +329,13 @@ static void dump_tasks(const struct mem_
> task_unlock(p);
> continue;
> }
> + /* Protect __task_cred() access */
> + rcu_read_lock();
> printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n",
> p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
> get_mm_rss(mm), (int)task_cpu(p), p->signal->oom_adj,
> p->comm);
> + rcu_read_unlock();
> task_unlock(p);
> } while_each_thread(g, p);
> }
Looks straight forward and correct to me.
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks
[not found] <20091210001308.247025548@linutronix.de>
2009-12-10 0:53 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks Thomas Gleixner
@ 2009-12-11 13:49 ` David Howells
2009-12-11 13:52 ` Thomas Gleixner
1 sibling, 1 reply; 4+ messages in thread
From: David Howells @ 2009-12-11 13:49 UTC (permalink / raw)
To: Thomas Gleixner
Cc: dhowells, LKML, Paul E. McKenney, Dipankar Sarma, Ingo Molnar,
Peter Zijlstra, Oleg Nesterov, Al Viro, James Morris,
Andrew Morton, Linus Torvalds, linux-mm
Thomas Gleixner <tglx@linutronix.de> wrote:
> + /* Protect __task_cred() access */
> + rcu_read_lock();
> printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n",
> p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
> get_mm_rss(mm), (int)task_cpu(p), p->signal->oom_adj,
> p->comm);
> + rcu_read_unlock();
No. If there's only one access to __task_cred() like this, use
task_cred_xxx() or one of its wrappers instead:
- p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
+ p->pid, task_uid(p), p->tgid, mm->total_vm,
that limits the size of the critical section.
David
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks
2009-12-11 13:49 ` David Howells
@ 2009-12-11 13:52 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2009-12-11 13:52 UTC (permalink / raw)
To: David Howells
Cc: LKML, Paul E. McKenney, Dipankar Sarma, Ingo Molnar,
Peter Zijlstra, Oleg Nesterov, Al Viro, James Morris,
Andrew Morton, Linus Torvalds, linux-mm
On Fri, 11 Dec 2009, David Howells wrote:
> Thomas Gleixner <tglx@linutronix.de> wrote:
>
> > + /* Protect __task_cred() access */
> > + rcu_read_lock();
> > printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n",
> > p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
> > get_mm_rss(mm), (int)task_cpu(p), p->signal->oom_adj,
> > p->comm);
> > + rcu_read_unlock();
>
> No. If there's only one access to __task_cred() like this, use
> task_cred_xxx() or one of its wrappers instead:
>
> - p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
> + p->pid, task_uid(p), p->tgid, mm->total_vm,
>
> that limits the size of the critical section.
Fair enough.
tglx
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-11 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20091210001308.247025548@linutronix.de>
2009-12-10 0:53 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks Thomas Gleixner
2009-12-10 1:57 ` KOSAKI Motohiro
2009-12-11 13:49 ` David Howells
2009-12-11 13:52 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox