Received: by 10.213.65.68 with SMTP id h4csp2111860imn; Sun, 8 Apr 2018 20:01:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/BjdCYkt9WYwt0V1Z7NaeNgM1n+AW8ofpSQOdb8Dpq3N120qYAv+cGeEJA1AiOFVB1L7+F X-Received: by 10.98.70.8 with SMTP id t8mr27909617pfa.185.1523242879785; Sun, 08 Apr 2018 20:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242879; cv=none; d=google.com; s=arc-20160816; b=eqMVjiZHAzLoBEVUy88FA2N9bHrYScG7npSPHJBT9FCbEanBp3gNsw15FrmZkUHM5L Rkcw8s8kSiOPCaxvBIx1diAzzpjL1fWUsxbalOowujKOoPNS7MYpaUXLq7cbLn+YcRR6 Dy3Z4A2T68gMDyoxUHJxVBStsnztlSJXOOR2aIdC4K/tiNf+cHC1XavJ15pknbDrJ462 21qOSdRpEiNKokEjV4ybcz0ISZ5CqXstNQw2hYXImFH5bfMUbU4qbS+1V9WXIuQSc6M2 4doO+rjb9apzwGFnCj3lt4j/ZMFrmXjM1M+et6hki/2rfjET4rQpuY90ezdIzd6LBFCp nU9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=FghhgUvVekexXSO2GfpRkgAPcqmjpiVGg3m0jwST2yk=; b=X1RAhqwUrTIpzGzMF+YDNj6xiJEkVooZ6HVgBg8uQ3fee0AHJidJEiirfCxU7DpUDv Mh2t2biU5JMGbJes5OjDsMgycyrEyPOBdTwjtDWdeo3zhso1aIFegVnk18s2XTEAgL9x HFY0StNdTuCfUC+j7ycl0d1xybKeW4LD4QOuaVzVe2xkz2nFOMWQSMyuC/qHdDzMdL7k L+/CxrJFEIZSSky9tgI6XyMohQMlmPoYmo8YroU27Qge9pLjs5p3UU0jsQhFxpBJyFD2 YkOe7oZhpAsBA3lfXXMM/CzVnhFm91YkMet/oyRd/cd2STgEYkhcHGHU1/gAlfu26U6h XfqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MWwTrtb+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t185si4580849pgd.557.2018.04.08.20.00.42; Sun, 08 Apr 2018 20:01:19 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MWwTrtb+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754115AbeDIATu (ORCPT + 99 others); Sun, 8 Apr 2018 20:19:50 -0400 Received: from mail-sn1nam02on0102.outbound.protection.outlook.com ([104.47.36.102]:30848 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754087AbeDIATg (ORCPT ); Sun, 8 Apr 2018 20:19:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FghhgUvVekexXSO2GfpRkgAPcqmjpiVGg3m0jwST2yk=; b=MWwTrtb+TiEk1eA+tQqnmjxAwQO+KNYvNbswSeju+8P4keLg4jRi10jUVN2w7Sibq0mXumWAKL0ibGLvxkNkc9QC8NCyBU9KiTA6sI0/ZMkYGlz1q4kFTKJIu7fuxxy7vPPc4YhqkE8Qk8fdisxFZSWtu9cUduWkm8F0ffAR3L4= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0726.namprd21.prod.outlook.com (10.167.108.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:19:30 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:19:30 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Yisheng Xie , Andi Kleen , Chris Salls , Christopher Lameter , David Rientjes , Ingo Molnar , Naoya Horiguchi , Tan Xiaojun , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 120/189] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Topic: [PATCH AUTOSEL for 4.15 120/189] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Index: AQHTz5hEPrB6lLYRukm84/AcHaLVcA== Date: Mon, 9 Apr 2018 00:18:21 +0000 Message-ID: <20180409001637.162453-120-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0726;7:Iu3rpKHF0JIUxtOoI2EdH+TyZhWHNs1uhWQwneMKiUsWJxdn5pi7h48+1a8Bw3zjjNZ6hZsqyB8NMCbL6y9ly5ORf1lX8tGUsvcGRl8sHrkkQzWAmsmY5/bpPMTiJiDmhS8TBwXNfAs2mkMaKAAVONYYHeCn07JyvtMAGX1dtmy0bK43u0rjp2Tu/4uojh3jx6RnIFJn5w9uMkj0SitOIsZufOgZ29J4eb0lrOUnYsKMqDRPsLyeZqqGTWZafrKq;20:SsgfdCfRPgiclsaEdNglF/qisZ/NhCEEqh6W5tGEmj4bPlmfWE5lTQCKM6sbaZZS0zHGc3SP8XwKv66tiF1Jb4zmcZDbUAa+AR+m2fVkzCrJt7VN3uQp6EJBpGe7yxnOur7lCzcPPp1iVmHA9p0vSFZU5Juiwchu31l8xydy2jM= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 22d1f294-2c4f-4a2d-de52-08d59daf9000 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0726; x-ms-traffictypediagnostic: DM5PR2101MB0726: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(192374486261705)(50582790962513)(211936372134217)(42068640409301)(153496737603132)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0726;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0726; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(346002)(39380400002)(39860400002)(396003)(376002)(199004)(189003)(6306002)(6486002)(26005)(6512007)(4326008)(81166006)(6666003)(6436002)(81156014)(8676002)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(966005)(86362001)(76176011)(7416002)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(59450400001)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(6116002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0726;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: vIsHqdCRek35WEkPM8LbPGrKcIehTRoCr2xYMwF3sLQ82EkyaTUhP5FvD0rjWuTvB6W/qHe47Q2oljf77JjqwnDISt04sTWpoZUOnRZNBmb5WmR9MsGCf9YBhDCkpVQzHOP+2d3jfLEl86JbWPpD1GWbLpMCZi8yq8DuXIS8CoGJJVx/36raH/s/BG89n9qubZLk5n/Cyk00ggrkmah5n+RNtar/mYpzZvLmtJLzr76tB6TYd2ZO2ibQNMmbKwCFdbRs9VPFILy3z9dUjikf6zODSUVtjia6/Q8NaV1QqtN3TFmUCWILGcrJhquTkdlb6po20CbVr/R+b9WG8YHpQf4iKqfTYaiY/iFEQOWoAsDnsaQUmxVJxBhMdhmzsZ6poaf82Y3hmehZOlLHL3vMWRIAd+WR6LGSD+gh+YKIu0s= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22d1f294-2c4f-4a2d-de52-08d59daf9000 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:21.8648 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0726 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 =3D 0; old_nodes =3D 0xf; ret =3D 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-xieyisheng= 1@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 --- mm/mempolicy.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index c9b807eca74c..277b6454954e 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1435,10 +1435,14 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned= long, maxnode, goto out_put; } =20 - if (!nodes_subset(*new, node_states[N_MEMORY])) { - err =3D -EINVAL; + task_nodes =3D 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; - } =20 err =3D security_task_movememory(task); if (err) --=20 2.15.1