From e914f8eb445e8f74b00303c19c2ffceaedd16a05 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Wed, 12 Oct 2016 01:30:33 -0300 Subject: Linux-libre 4.7.6-gnu --- mm/kasan/quarantine.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mm/kasan/quarantine.c') diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 65793f150..a04887c62 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -196,7 +196,7 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) void quarantine_reduce(void) { - size_t new_quarantine_size; + size_t new_quarantine_size, percpu_quarantines; unsigned long flags; struct qlist_head to_free = QLIST_INIT; size_t size_to_free = 0; @@ -214,7 +214,12 @@ void quarantine_reduce(void) */ new_quarantine_size = (READ_ONCE(totalram_pages) << PAGE_SHIFT) / QUARANTINE_FRACTION; - new_quarantine_size -= QUARANTINE_PERCPU_SIZE * num_online_cpus(); + percpu_quarantines = QUARANTINE_PERCPU_SIZE * num_online_cpus(); + if (WARN_ONCE(new_quarantine_size < percpu_quarantines, + "Too little memory, disabling global KASAN quarantine.\n")) + new_quarantine_size = 0; + else + new_quarantine_size -= percpu_quarantines; WRITE_ONCE(quarantine_size, new_quarantine_size); last = global_quarantine.head; -- cgit v1.2.3-54-g00ecf