* [PATCH] dmapools: protect page_list walk in show_pools()
@ 2009-06-23 14:41 Thomas Gleixner
2009-06-23 14:46 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Gleixner @ 2009-06-23 14:41 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: LKML
show_pools() walks the page_list of a pool w/o protection against the
list modifications in alloc/free. Take pool->lock to avoid stomping
into nirvana.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
diff --git a/mm/dmapool.c b/mm/dmapool.c
index b1f0885..3df0637 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -86,10 +86,12 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf)
unsigned pages = 0;
unsigned blocks = 0;
+ spin_lock_irq(&pool->lock);
list_for_each_entry(page, &pool->page_list, page_list) {
pages++;
blocks += page->in_use;
}
+ spin_unlock_irq(&pool->lock);
/* per-pool info, no real statistics yet */
temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n",
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmapools: protect page_list walk in show_pools()
2009-06-23 14:41 [PATCH] dmapools: protect page_list walk in show_pools() Thomas Gleixner
@ 2009-06-23 14:46 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2009-06-23 14:46 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: LKML, Andrew Morton
On Tue, Jun 23, 2009 at 04:41:14PM +0200, Thomas Gleixner wrote:
> show_pools() walks the page_list of a pool w/o protection against the
> list modifications in alloc/free. Take pool->lock to avoid stomping
> into nirvana.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Looks right to me. We're already holding pools_lock here, but pools_lock
doesn't protect against the page_list.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
I don't have a tree for dmapool work ... might as well go in through
Andrew, I suppose?
> ---
> diff --git a/mm/dmapool.c b/mm/dmapool.c
> index b1f0885..3df0637 100644
> --- a/mm/dmapool.c
> +++ b/mm/dmapool.c
> @@ -86,10 +86,12 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf)
> unsigned pages = 0;
> unsigned blocks = 0;
>
> + spin_lock_irq(&pool->lock);
> list_for_each_entry(page, &pool->page_list, page_list) {
> pages++;
> blocks += page->in_use;
> }
> + spin_unlock_irq(&pool->lock);
>
> /* per-pool info, no real statistics yet */
> temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n",
>
>
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-23 14:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-23 14:41 [PATCH] dmapools: protect page_list walk in show_pools() Thomas Gleixner
2009-06-23 14:46 ` Matthew Wilcox
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.