Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751849AbcDRC0b (ORCPT ); Sun, 17 Apr 2016 22:26:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35313 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751697AbcDRC03 (ORCPT ); Sun, 17 Apr 2016 22:26:29 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xishi Qiu , Vlastimil Babka , Naoya Horiguchi , Joonsoo Kim , David Rientjes , "Laura Abbott" , Hui Zhu , Wang Xiaoqiang , Andrew Morton , Linus Torvalds Subject: [PATCH 3.14 05/37] mm: fix invalid node in alloc_migrate_target() Date: Mon, 18 Apr 2016 11:25:37 +0900 Message-Id: <20160418022400.978451000@linuxfoundation.org> X-Mailer: git-send-email 2.8.0 In-Reply-To: <20160418022400.661946311@linuxfoundation.org> References: <20160418022400.661946311@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1640 Lines: 48 3.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xishi Qiu commit 6f25a14a7053b69917e2ebea0d31dd444cd31fd5 upstream. It is incorrect to use next_node to find a target node, it will return MAX_NUMNODES or invalid node. This will lead to crash in buddy system allocation. Fixes: c8721bbbdd36 ("mm: memory-hotplug: enable memory hotplug to handle hugepage") Signed-off-by: Xishi Qiu Acked-by: Vlastimil Babka Acked-by: Naoya Horiguchi Cc: Joonsoo Kim Cc: David Rientjes Cc: "Laura Abbott" Cc: Hui Zhu Cc: Wang Xiaoqiang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/page_isolation.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -259,11 +259,11 @@ struct page *alloc_migrate_target(struct * now as a simple work-around, we use the next node for destination. */ if (PageHuge(page)) { - nodemask_t src = nodemask_of_node(page_to_nid(page)); - nodemask_t dst; - nodes_complement(dst, src); + int node = next_online_node(page_to_nid(page)); + if (node == MAX_NUMNODES) + node = first_online_node; return alloc_huge_page_node(page_hstate(compound_head(page)), - next_node(page_to_nid(page), dst)); + node); } if (PageHighMem(page))