Received: by 10.192.165.148 with SMTP id m20csp538957imm; Wed, 25 Apr 2018 03:56:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx485ROqCbeF7rYeCCoM/ho1ZfLPO5p91LMpzO8ghF7Tx5hvhlMGYc5MW4Uhop1Z9Ss58l/+U X-Received: by 10.99.97.151 with SMTP id v145mr23782590pgb.35.1524653804842; Wed, 25 Apr 2018 03:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653804; cv=none; d=google.com; s=arc-20160816; b=VQVFlgS04yiIALjobNwZfdRcGxVYssnRSBTzNCLi2qOouw6ENH1ACjzvu1+Uqj5mD2 5lLCaX0NERyY1cHc7MrgD3dfgjsT+k3vYQJ6DMQK6lYPQbUwkaugm4lztGhqbAhQWgo9 9K0mt+cMZJy4CpwDqGtWQdKkIsoxs2iIFewJkGdrtkHl0dvwhn1WHiTgVSdiSaVECJmV 58Ygeji6qzyPI+fsie/P1YYNvRU+yVvcp2uLrOSZKbiNHYSMQfxcnqWKEuD1fc2UI6gt m8SQz37k/Deepn+nwK/65ZIiP62V3GBKB0SD0oIYLvJqWeLGx0G6pIdIigZNio0wObvE 3NjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9CLkNfYCcivcpZG4jgC6se2BJA4QJCqPYhAzyzZw3Os=; b=LcTht2I9rC1bBak0Q0bMuLXalCgQa+4oQbYDI+jNq4lI5OKjAFOdrBOtSK4QXVNOWF WthbqiJrPBP/INb/f5hNMl2m3urfz0eFP0s8vE78WEs521Ma6ReJeYyTkrJy76psMCO+ cy+WoIaFUv7XIUsQ4cX3t212rTp9tb9O4rJ8aX+tw0biVPQ6LQnaLwwrAZf1nrVZQAyY ebvw7uPlPIzZTVRNAd0HDSBb4bZI7cE84F+e6sUmXVk+fgjJjmnFgfsMgUZK6H6KWaPe sHRDPDmbonpx/47nNTESbQ8/Tg+dTxLO4b5tNJnraZsGy9TROGvYNJqHg10UXdMg0/Ie 5GUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j65si13556315pge.336.2018.04.25.03.56.30; Wed, 25 Apr 2018 03:56:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753514AbeDYKzY (ORCPT + 99 others); Wed, 25 Apr 2018 06:55:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52978 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754202AbeDYKnW (ORCPT ); Wed, 25 Apr 2018 06:43:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 329D54A3; Wed, 25 Apr 2018 10:43:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yisheng Xie , Vlastimil Babka , Andi Kleen , Chris Salls , Christopher Lameter , David Rientjes , Ingo Molnar , Naoya Horiguchi , Tan Xiaojun , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 112/183] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Date: Wed, 25 Apr 2018 12:35:32 +0200 Message-Id: <20180425103246.947698207@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yisheng Xie [ Upstream commit 0486a38bcc4749808edbc848f1bcf232042770fc ] As in manpage of migrate_pages, the errno should be set to EINVAL when none of the node IDs specified by new_nodes are on-line and allowed by the process's current cpuset context, or none of the specified nodes contain memory. However, when test by following case: new_nodes = 0; old_nodes = 0xf; ret = migrate_pages(pid, old_nodes, new_nodes, MAX); The ret will be 0 and no errno is set. As the new_nodes is empty, we should expect EINVAL as documented. To fix the case like above, this patch check whether target nodes AND current task_nodes is empty, and then check whether AND node_states[N_MEMORY] is empty. Link: http://lkml.kernel.org/r/1510882624-44342-4-git-send-email-xieyisheng1@huawei.com Signed-off-by: Yisheng Xie Acked-by: Vlastimil Babka Cc: Andi Kleen Cc: Chris Salls Cc: Christopher Lameter Cc: David Rientjes Cc: Ingo Molnar Cc: Naoya Horiguchi Cc: Tan Xiaojun Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- mm/mempolicy.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1440,10 +1440,14 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pi goto out_put; } - if (!nodes_subset(*new, node_states[N_MEMORY])) { - err = -EINVAL; + task_nodes = cpuset_mems_allowed(current); + nodes_and(*new, *new, task_nodes); + if (nodes_empty(*new)) + goto out_put; + + nodes_and(*new, *new, node_states[N_MEMORY]); + if (nodes_empty(*new)) goto out_put; - } err = security_task_movememory(task); if (err)