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: 10552927 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 CF31713BB for ; Wed, 1 Aug 2018 20:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA6392B5C9 for ; Wed, 1 Aug 2018 20:04:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABDF72B7CA; Wed, 1 Aug 2018 20:04:24 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C682B5C9 for ; Wed, 1 Aug 2018 20:04:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEE396B0003; Wed, 1 Aug 2018 16:04:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E74866B0005; Wed, 1 Aug 2018 16:04:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D64D36B0006; Wed, 1 Aug 2018 16:04:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f72.google.com (mail-oi0-f72.google.com [209.85.218.72]) by kanga.kvack.org (Postfix) with ESMTP id A31F96B0003 for ; Wed, 1 Aug 2018 16:04:22 -0400 (EDT) Received: by mail-oi0-f72.google.com with SMTP id u74-v6so17800692oie.16 for ; Wed, 01 Aug 2018 13:04:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=H1yg/XW+LdTSY5aXgw+GGg0jaXxOBsXiTPpw+Y2V+Q4=; b=WwnvdKVzZKleQjT9zUQAD89BpyWTTdRj6GCKEmEQE8waGuT5tNQukBkxQsFYIKipbS kLX+9no5DlmtMGESfh1saKx8mpnpuCPWQS1oJPt0HaFk66QX6cfSrgXfy1qT9B2ZJnze 5D4Qga3gwVENuYpDwYpY9emBedHU+Hcf8iCq3sQARY61u5Zu48MPoX8g/rYVp1dA9EfH 9ACKWUwIhO/Milgx3HTTd5U0gvnxpRiSK6moWUEOCbInPLnK2rTjpCm9ncGisDP27JCY Yvlo6xwldxuI3OTG6c19f5AX8XqWTaXpt+DCp/EGvBMnhjTbu7T++I9RSCtL3pKGX90P w27Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jeremy.linton@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=jeremy.linton@arm.com X-Gm-Message-State: AOUpUlGYL4F2CI3/1cwFzQk4sonRz7Gf+wfXZqgF8glbec9Gtu+PqdSm NYlxdvCDeC5doo7eUhZqT6I2DFfCfH+4v7p50YuNTVzlYU13PRVOsHxOSLrHPd0RBQIMOxRtASe TmX8q+BylXTyQA5oH16hwXWjJhS+4knPv5SdRqgt3HXRa8DihOtqlNqIlpOGBfqhDSg== X-Received: by 2002:aca:7c5:: with SMTP id 188-v6mr5265795oih.58.1533153862251; Wed, 01 Aug 2018 13:04:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfjBuzM2836T9aKxm3G7VR41e03zn2la7+K1Hv12Oul55zJP4AaiNz91MUZDCZUJhPiKwwh X-Received: by 2002:aca:7c5:: with SMTP id 188-v6mr5265734oih.58.1533153861342; Wed, 01 Aug 2018 13:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533153861; cv=none; d=google.com; s=arc-20160816; b=iH64/lbAkFBmA4px048AhuEZi8JNDCRxZWF7U+97fL2FDQHHIteETiEKo4PyrABhqh MCKGm2IAKz6gERd7OGq6fD41StlnMyjenuqy5DBhhDpXsk8eBbsI5NSywfkCEyLQVYCk UxV6mDx+s9dKL9E89932inRaVKrOqUZoKqtBEGmWsCkxv4LL1ZNizvJpbAMg294S85Jr Gd2yl/IUYiqopJBcHsBaKklwkSlIDEFTcCGMyOrNy1JrYNM/E54nwcMX18EOtvLH1+Ql fz8Dl2a20xKuej4+/CRTCflcBia4HhjUdIRCk850gGwADL8E18P53P/4NHsWkOXFyVuS RLGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=H1yg/XW+LdTSY5aXgw+GGg0jaXxOBsXiTPpw+Y2V+Q4=; b=DmXegkrIEhj1z19Spl08RgtFIf2oDBLzVXUhKxzWaKKc66EVxAyf8bDWDrhnf6hIW6 kLk7cZ1NfprDBcHChkhz8OEahjMofQ76uRe7WU3LNFxXMI3SVe5D0+V6nrPLr2/WvbTt 73QLmB+/jEF8hJxiDF/a+fB1pYvsyQGVtt6Bw1sMZE9Y/VuJQZVfv6imj9kxTDX4fzjV 11YCeUD4DB2eJHMN2Foo52osBA7c8UlLLi0cG0/DZR8Dt9NcLa0fmyVp8IDawd+/+/rL W0DAyMvHGzNrqHvGzS5pCKu6CszvqeFOEhxe1eXc1F7av1x/hl9smfWYWK74rXjDORvS FD1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jeremy.linton@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=jeremy.linton@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id j133-v6si12637818oif.430.2018.08.01.13.04.20 for ; Wed, 01 Aug 2018 13:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of jeremy.linton@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jeremy.linton@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=jeremy.linton@arm.com 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 Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, Punit.Agrawal@arm.com, Lorenzo.Pieralisi@arm.com, linux-arm-kernel@lists.infradead.org, bhelgaas@google.com, linux-kernel@vger.kernel.org, Jeremy Linton 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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(+)