From patchwork Wed Aug 1 20:04:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 10552937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBCC1139A for ; Wed, 1 Aug 2018 20:05:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4B332ABD8 for ; Wed, 1 Aug 2018 20:05:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6CF42BA0D; Wed, 1 Aug 2018 20:05:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2EE742ABD8 for ; Wed, 1 Aug 2018 20:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=OA5JJC00IC2urNlvgynMRykXMaXGHGZyzPr9Eo4ac+U=; b=Bdp zo8D7voyGxEK9xPrRm4CrZD9Ux5HP+DuLEx9LlwxOU7apHdmZlvWpGD4caG7jpX2L5/D2eaimNfMN 7G/Ahx+CaPB+8OLgEgUVJlydF/YgWLDwJXeCm1LHqNC2itYm/fMbXCFCr3Sd64oEq8Uw8mNkGgjP5 gqbOcq9fEW05SW4brG0syRjyB31c+dMojF0ybmhZhrKPM34CYQSIKNJyY+KVublkSFhzZHvOw44Yj GRmPEItOwG+OwGaJjwFm5/2oshy0P1uyrC14fImHjO3DQKxThOsoTbifKxOSe5u7tPSl6wMwjxrmJ 7bwJke4MZrkq7YuVkZRQ2oGek30Bq9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkxMd-0004a9-5m; Wed, 01 Aug 2018 20:04:55 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkxME-00042m-Vz for linux-arm-kernel@lists.infradead.org; Wed, 01 Aug 2018 20:04:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DBBC7A9; Wed, 1 Aug 2018 13:04:20 -0700 (PDT) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CC2093F5BA; Wed, 1 Aug 2018 13:04:19 -0700 (PDT) From: Jeremy Linton To: linux-mm@kvack.org Subject: [RFC 0/2] harden alloc_pages against bogus nid Date: Wed, 1 Aug 2018 15:04:16 -0500 Message-Id: <20180801200418.1325826-1-jeremy.linton@arm.com> X-Mailer: git-send-email 2.14.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180801_130431_040251_7F9FD9FB X-CRM114-Status: GOOD ( 11.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mhocko@suse.com, akpm@linux-foundation.org, Punit.Agrawal@arm.com, linux-kernel@vger.kernel.org, Jeremy Linton , penberg@kernel.org, Lorenzo.Pieralisi@arm.com, linux-arm-kernel@lists.infradead.org, rientjes@google.com, bhelgaas@google.com, cl@linux.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The thread "avoid alloc memory on offline node" https://lkml.org/lkml/2018/6/7/251 Asked at one point why the kzalloc_node was crashing rather than returning memory from a valid node. The thread ended up fixing the immediate causes of the crash but left open the case of bad proximity values being in DSDT tables without corrisponding SRAT/SLIT entries as is happening on another machine. Its also easy to fix that, but we should also harden the allocator sufficiently that it doesn't crash when passed an invalid node id. There are a couple possible ways to do this, and i've attached two separate patches which individually fix that problem. The first detects the offline node before calling the new_slab code path when it becomes apparent that the allocation isn't going to succeed. The second actually hardens node_zonelist() and prepare_alloc_pages() in the face of NODE_DATA(nid) returning a NULL zonelist. This latter case happens if the node has never been initialized or is possibly out of range. There are other places (NODE_DATA & online_node) which should be checking if the node id's are > MAX_NUMNODES. Jeremy Linton (2): slub: Avoid trying to allocate memory on offline nodes mm: harden alloc_pages code paths against bogus nodes include/linux/gfp.h | 2 ++ mm/page_alloc.c | 2 ++ mm/slub.c | 2 ++ 3 files changed, 6 insertions(+)