Received: by 10.213.65.68 with SMTP id h4csp2114274imn; Sun, 8 Apr 2018 20:04:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+rPghvp0qjDo1FNElAvgxN5Ke3TppYkHVGtSM4mGCE5cX5JxCU66zgl7U+uLSfns7y9hNU X-Received: by 2002:a17:902:8a93:: with SMTP id p19-v6mr37885322plo.256.1523243068597; Sun, 08 Apr 2018 20:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243068; cv=none; d=google.com; s=arc-20160816; b=AzBXp/qX0P7LPeceFA+wwEEepoW47P4TdSj3/mkQrMGbi6VxQgS0HUnoIhDsowHyt8 KRP/07bqcOFVYXUvB93Q3+K+mWh/88Vkaq80q/suF/w+V7RCZQHIYBG7P2P078NdB2DY myTGKnQvRRBAb60pBd2fiWD00x/CBvVWLL+vJo5GR4gnlQESS3Jc4e1WwwQkc1xz+GCk 4GHLabx7Tqau6X2OreWSmzQx2uMI+fKfSPSLhmPYHcyvhXtvABz/55NlkRT2JAsCbtj4 SDoBIB2QRzRQsZLZ/mNiGUpA3C1qym1t98VR+fb15ioOyGh6ZyjqHXiq8dqRu/3DVGG9 sCVw== 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=O2jhmZ/T+dcklhekAf6rrZRhpWv/UgMBtktyj11qbt0=; b=WcOHcz0n1GpbR44JlE57wGzDEJ2owQEGxqPCVb+xjagPzg1d/HUf/DSsPPBCTMB8Bk GLdvT701fGNFlh/S/G+7R3Mos6iSo7OUTxlQkyeX5I6zQqys2AZNrYSRiMWN7Y1451Xo XPfT8U7VJpJS9q0GS/L9JfqnqyeEnfGF1cAX18BVxU/IGxAvRMwf4luQm+QYzfmH4y7E S/5E7qmoppGDlCoQnRWGa7pHLMvt0r8abpRUMshT5cKt39YPf1+brg9dLqNjCRctu0O0 ToJSSPk6l6opHyVi9tld1ESahC+NinOHYLAxawpQw5dB4KrUqNMlxspszdfMGwq97WPt XXag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=NO6rHS+l; 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 a1-v6si2068249plp.22.2018.04.08.20.03.51; Sun, 08 Apr 2018 20:04:28 -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=NO6rHS+l; 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 S932434AbeDIAeE (ORCPT + 99 others); Sun, 8 Apr 2018 20:34:04 -0400 Received: from mail-by2nam01on0130.outbound.protection.outlook.com ([104.47.34.130]:18358 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932332AbeDIAd5 (ORCPT ); Sun, 8 Apr 2018 20:33:57 -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=O2jhmZ/T+dcklhekAf6rrZRhpWv/UgMBtktyj11qbt0=; b=NO6rHS+lABu5bbbirUN2c3mbbVfFN5STPbJEz4MrRNyJxBd1RmVM+EcQJ85YW3cz5XQH1XJRrWZg+x4dpM1pksyGpySjecmVOnAXIBx5ya9Mg7tWDYgF/YpecOT5Q2Qo6DSCjvqmWZ6ca/kujPTN5wz1SmMfO6AOw0Jgtk9QIRQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:33:53 +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:33:53 +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.9 258/293] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Topic: [PATCH AUTOSEL for 4.9 258/293] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Index: AQHTz5leRHhz6tT4yEObPBlBpkGTAA== Date: Mon, 9 Apr 2018 00:26:15 +0000 Message-ID: <20180409002239.163177-258-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0806;7:P3T8u9rg7FjoqFDAPD+8VJS/ExO6rJ32CasGE3HzkO118+oLd4BUoSJ2zgMOqRofQ1owlNq6KobUM1ZEPC0illrAe9f4lGR+DKI0oNyunS9OGqFdwWg/vqqqGTKI8FD8JsMmsIGMB7cO3nHskt+plbphAz+kjUfZUggJ/y4ZiKqTS8VyN/RHpUUwhKhRl+pUh7yA35z/fjdYM520gkHdnFHXvwmQHW3SdhCGc4Pp0cl92nR/vqhJDgPhvjwZwxFi;20:6mtaS5P6OpSK2OEqyE9zNDurBOEbMqOBUb/tKbrTjZW0+xruAV3sIOoUOHJzQyXz3nYJGrRkyw+rS/WdA/gA/fi22lM917CTEzcVjgZqRJuhoeW2f41W9cVJaCD4M6hN6FgFEsQjJNbaOHpj8AKViDeWRyqqCpX86Pgz8d/YH7A= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 56961a7d-dcc9-41da-9957-08d59db19236 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: 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)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(59450400001)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(7416002)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(6306002)(86362001)(966005)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;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: 0QLGEtru15c/KjU1aUc6gXNevTSyzj73u1pQgMpv4oX5MkvXAHmHvsYouIDWs35xiU3iERNpT+1AREyFQhGEPm0eLgoka/e0DDLYIlhKCjyuvspHf7UZLbFJ/Enc9w2fr9P9Jnh3moDVG/GZfWz0+uAT0mfhwoyLivB2cIT+IJays4KK3A6+l1h8uhPZVg0XHvtbggI82f93TmLw8GkP7Qg95hU2afvD0j5uBgOz1YuosIV+bLcr7AkhhKJrbK91xINdDdfSqPTKDlyERSg8dFm53ZACFqOb/nte2bB/hRvGeJ9fwJ5iHxqBMdzk8AopxxTYhzVH2fGiM0a1YgO/ULdyz44hsOnStMVMvWowsKcK4k+e1VSTc9bShu++1cX0se1l63Pb4ucGhUiBinJvc9b1VQU4S2H3h4ME8ySPoSs= 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: 56961a7d-dcc9-41da-9957-08d59db19236 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:15.1600 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 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 92f92f477304..c779a12f1ff8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1442,10 +1442,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