diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2016-10-20 12:49:10 +0200 |
---|---|---|
committer | Daniel Wagner <wagi@monom.org> | 2018-07-26 06:48:25 +0200 |
commit | eea30cc5534b1790fdfc113d697125de0ff9c443 (patch) | |
tree | 9f918f3e753535881a3cbddba574f9a5e095491e | |
parent | 86037da0160f633ea9145ee4e79cf0ec66cc0619 (diff) | |
download | linux-rt-eea30cc5534b1790fdfc113d697125de0ff9c443.tar.gz |
zsmalloc: turn that get_cpu_light() into a local_lock()
We might get preempted, grab the same ressource again and then corrupt
the memory.
Cc: stable-rt@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | mm/zsmalloc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b552fd607df8..529552c3716d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -64,6 +64,7 @@ #include <linux/debugfs.h> #include <linux/zsmalloc.h> #include <linux/zpool.h> +#include <linux/locallock.h> /* * This must be power of 2 and greater than of equal to sizeof(link_free). @@ -403,6 +404,7 @@ static unsigned int get_maxobj_per_zspage(int size, int pages_per_zspage) /* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ static DEFINE_PER_CPU(struct mapping_area, zs_map_area); +static DEFINE_LOCAL_IRQ_LOCK(zs_map_area_lock); static int is_first_page(struct page *page) { @@ -1289,7 +1291,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, class = pool->size_class[class_idx]; off = obj_idx_to_offset(page, obj_idx, class->size); - area = per_cpu_ptr(&zs_map_area, get_cpu_light()); + area = &get_locked_var(zs_map_area_lock, zs_map_area); area->vm_mm = mm; if (off + class->size <= PAGE_SIZE) { /* this object is contained entirely within a page */ @@ -1342,7 +1344,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) __zs_unmap_object(area, pages, off, class->size); } - put_cpu_light(); + put_locked_var(zs_map_area_lock, zs_map_area); unpin_tag(handle); } EXPORT_SYMBOL_GPL(zs_unmap_object); |