Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754060AbbBKUJb (ORCPT ); Wed, 11 Feb 2015 15:09:31 -0500 Received: from mail-we0-f179.google.com ([74.125.82.179]:54181 "EHLO mail-we0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752766AbbBKUJ3 (ORCPT ); Wed, 11 Feb 2015 15:09:29 -0500 Date: Wed, 11 Feb 2015 12:09:23 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Vladimir Davydov cc: Christoph Lameter , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Pekka Enberg , Joonsoo Kim Subject: Re: [PATCH -mm] slub: kmem_cache_shrink: init discard list after freeing slabs In-Reply-To: <20150211154128.GA26049@esperanza> Message-ID: References: <1423627463.5968.99.camel@intel.com> <1423642582-23553-1-git-send-email-vdavydov@parallels.com> <20150211154128.GA26049@esperanza> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2979 Lines: 59 On Wed, 11 Feb 2015, Vladimir Davydov wrote: > Currently, the discard list is only initialized at the beginning of the > function. As a result, if there are > 1 nodes, we can get use-after-free > while processing the second or higher node: > > WARNING: CPU: 60 PID: 1 at lib/list_debug.c:29 __list_add+0x3c/0xa9() > list_add corruption. next->prev should be prev (ffff881ff0a6bb98), but was ffffea007ff57020. (next=ffffea007fbf7320). > Modules linked in: > CPU: 60 PID: 1 Comm: swapper/0 Not tainted 3.19.0-rc7-next-20150203-gb50cadf #2178 > Hardware name: Intel Corporation BRICKLAND/BRICKLAND, BIOS BIVTSDP1.86B.0038.R02.1307231126 07/23/2013 > 0000000000000009 ffff881ff0a6ba88 ffffffff81c2e096 ffffffff810e2d03 > ffff881ff0a6bad8 ffff881ff0a6bac8 ffffffff8108b320 ffff881ff0a6bb18 > ffffffff8154bbc7 ffff881ff0a6bb98 ffffea007fbf7320 ffffea00ffc3c220 > Call Trace: > [] dump_stack+0x4c/0x65 > [] ? console_unlock+0x398/0x3c7 > [] warn_slowpath_common+0xa1/0xbb > [] ? __list_add+0x3c/0xa9 > [] warn_slowpath_fmt+0x46/0x48 > [] __list_add+0x3c/0xa9 > [] __kmem_cache_shrink+0x12b/0x24c > [] kmem_cache_shrink+0x26/0x38 > [] acpi_os_purge_cache+0xe/0x12 > [] acpi_purge_cached_objects+0x32/0x7a > [] acpi_initialize_objects+0x17e/0x1ae > [] ? acpi_sleep_proc_init+0x2a/0x2a > [] acpi_init+0x92/0x25e > [] ? do_one_initcall+0x90/0x17f > [] ? kfree+0x1fc/0x2d5 > [] ? acpi_sleep_proc_init+0x2a/0x2a > [] do_one_initcall+0xed/0x17f > [] kernel_init_freeable+0x1f0/0x278 > [] ? rest_init+0x13e/0x13e > [] kernel_init+0xe/0xda > [] ret_from_fork+0x7c/0xb0 > [] ? rest_init+0x13e/0x13e > > Fix this by initializing the discard list at each iteration of the > for_each_kmem_cache_node loop. Also, move promote lists initialization > to the beginning of the loop to conform. > > fixes: slub-never-fail-to-shrink-cache 8f44a586ac86 ("slub: never fail to shrink cache") > Signed-off-by: Vladimir Davydov > Reported-by: Huang Ying > Cc: Christoph Lameter > Cc: Pekka Enberg > Cc: David Rientjes > Cc: Joonsoo Kim Acked-by: David Rientjes -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/