Message ID | 20200401161538.000681014@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show
Return-Path: <SRS0=zuZT=5R=vger.kernel.org=stable-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 260F1C2D0F2 for <stable@archiver.kernel.org>; Wed, 1 Apr 2020 16:52:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD7F520714 for <stable@archiver.kernel.org>; Wed, 1 Apr 2020 16:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759958; bh=Nb0r+HQTy4g3tmCtBYbsXP+gteUn0DVvrhjMF+wHtw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yLBD/0hlScG4x8tvpokjErteOmcU/FPahW51SB+bOqvhIutOGKXiXRVvtBiei79iH U6zNb1+w0/Lpm8YkdpNpP/xOsknW5q3QWHPcXceSYFm0lal/JfAO7/UWfI58tIQY4F qKyWUPllSHT9iqaubGL3d/US/yZCgsd9js2XMh8A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388661AbgDAQfk (ORCPT <rfc822;stable@archiver.kernel.org>); Wed, 1 Apr 2020 12:35:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:34418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388757AbgDAQfj (ORCPT <rfc822;stable@vger.kernel.org>); Wed, 1 Apr 2020 12:35:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AF7420BED; Wed, 1 Apr 2020 16:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758938; bh=Nb0r+HQTy4g3tmCtBYbsXP+gteUn0DVvrhjMF+wHtw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mt/p+B+q8f3YrrqJDCKhbZiGTeCshTbnDOpaVdd3c1Uq0djz4RHxxXvS9VV/dqoaB zHtDoHpZZ2n2GiNXnowgi32dvHEqhmdnFk1ehkRv8liKLJ1B56JnmNIQoCM092vVvN HyW9S7pmXY4DB+QowJvtD2vKeK9mIDEt0n6Cw3b4= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Sachin Sant <sachinp@linux.vnet.ibm.com>, PUVICHAKRAVARTHY RAMACHANDRAN <puvichakravarthy@in.ibm.com>, Vlastimil Babka <vbabka@suse.cz>, Andrew Morton <akpm@linux-foundation.org>, Bharata B Rao <bharata@linux.ibm.com>, Srikar Dronamraju <srikar@linux.vnet.ibm.com>, Mel Gorman <mgorman@techsingularity.net>, Michael Ellerman <mpe@ellerman.id.au>, Michal Hocko <mhocko@kernel.org>, Christopher Lameter <cl@linux.com>, linuxppc-dev@lists.ozlabs.org, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Kirill Tkhai <ktkhai@virtuozzo.com>, Nathan Lynch <nathanl@linux.ibm.com>, Linus Torvalds <torvalds@linux-foundation.org> Subject: [PATCH 4.9 026/102] mm, slub: prevent kmalloc_node crashes and memory leaks Date: Wed, 1 Apr 2020 18:17:29 +0200 Message-Id: <20200401161538.000681014@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161530.451355388@linuxfoundation.org> References: <20200401161530.451355388@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
--- a/mm/slub.c +++ b/mm/slub.c @@ -1909,8 +1909,6 @@ static void *get_partial(struct kmem_cac if (node == NUMA_NO_NODE) searchnode = numa_mem_id(); - else if (!node_present_pages(node)) - searchnode = node_to_mem_node(node); object = get_partial_node(s, get_node(s, searchnode), c, flags); if (object || node != NUMA_NO_NODE) @@ -2506,17 +2504,27 @@ static void *___slab_alloc(struct kmem_c struct page *page; page = c->page; - if (!page) + if (!page) { + /* + * if the node is not online or has no normal memory, just + * ignore the node constraint + */ + if (unlikely(node != NUMA_NO_NODE && + !node_state(node, N_NORMAL_MEMORY))) + node = NUMA_NO_NODE; goto new_slab; + } redo: if (unlikely(!node_match(page, node))) { - int searchnode = node; - - if (node != NUMA_NO_NODE && !node_present_pages(node)) - searchnode = node_to_mem_node(node); - - if (unlikely(!node_match(page, searchnode))) { + /* + * same as above but node_match() being false already + * implies node != NUMA_NO_NODE + */ + if (!node_state(node, N_NORMAL_MEMORY)) { + node = NUMA_NO_NODE; + goto redo; + } else { stat(s, ALLOC_NODE_MISMATCH); deactivate_slab(s, page, c->freelist); c->page = NULL;