Received: by 10.213.65.68 with SMTP id h4csp2122096imn; Sun, 8 Apr 2018 20:14:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49bDpC2Z7wjJ+xpw3T1ntHiMdylMUun3xBJ1U4jEI4RK6AV386/LsuMrghe8qJNJZzRCUvs X-Received: by 10.98.178.207 with SMTP id z76mr27907641pfl.37.1523243693029; Sun, 08 Apr 2018 20:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243692; cv=none; d=google.com; s=arc-20160816; b=kDJ9LW0k/GJaLfyl2MYhkWwCBmQqySLX+dIXJitbZvdDmZ70aAJivH0g7pF/qMvcGp l/OfWMpSpWozuUVK9bv+lJbtoj+RRnomvz48e7mRt3OXxLNxOlfVlZu/5OsbISyrWhYc fhlha4H64knkI9ConUJSZuTwDZjJov55Ik81yxGFF7ZmKtV0eN2F3oQbyR6N+kFlsNgD 9Y5VjYfF0p3oudmrRVvzb7d0P1+tkmyNMIxsITkheviceRbi759Dgg0i+qbrey1JJjJ7 XVndoTapC5aXFhoqTHeGAqDby/Tgj0p/7WGt7l+eUbPjPf4wWkb6oZoT0pDefnhWhNgR 1eGg== 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=d4QqrP+n7TvCGUCSSYaMb7z8nqbX0v2xrUuNvWKG86s=; b=IP6u5ZzfLs1uBUGkii75hNdtMJpeBKWd0Qk2zcx+Lc2WDxxgYiLvlCo6EVBgo/sDcK W6a00tyCGQqiiu6zdw3wswasypjaspfQXNbDnOxgRIN1Xxe/QuwnbJXZi2zliUYKpZF2 Yh540mTWzoA6AYZtpFY9xF290YtmqppQ/18orkqc6crQVYt5S/9zm4sViNMF2hCZt3wh /4eg+UOmkHsAtwvT5DmiTVRd+vVb1Hjd2rs708ur0feYehmZjNq5shN/fGB0HKLjPB4w XveWQDRZXhVBePGQXEGh3fEfVz65uoYt3qFyAr1ITErGQ9jGx3eZkvi76p7TgIhCS61P Scvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=a0ChMfzO; 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 d16-v6si13191160pll.214.2018.04.08.20.14.16; Sun, 08 Apr 2018 20:14:52 -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=a0ChMfzO; 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 S1752961AbeDIDF3 (ORCPT + 99 others); Sun, 8 Apr 2018 23:05:29 -0400 Received: from mail-sn1nam02on0128.outbound.protection.outlook.com ([104.47.36.128]:23328 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932102AbeDIAYn (ORCPT ); Sun, 8 Apr 2018 20:24:43 -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=d4QqrP+n7TvCGUCSSYaMb7z8nqbX0v2xrUuNvWKG86s=; b=a0ChMfzOHIMaElVQ5CWPl1dgaHuf/LaxhKmrHWQiYQRuAZHdOh9bY2L0oOaqsMEtK36Q/webrFqpV3WZC65W78aUFeb1qr+YFfsvYwVxs+6vWejYUbPz4gxMJ1el3qeYLCFEhs9/dzYMqACKXdXwKT/44mF7BFHRgbnS1eN7G5Y= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0983.namprd21.prod.outlook.com (52.132.133.29) 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:24:41 +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:24:41 +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.14 100/161] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Topic: [PATCH AUTOSEL for 4.14 100/161] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Index: AQHTz5iq+RvDn6adlky2u7hm4xIJsw== Date: Mon, 9 Apr 2018 00:21:12 +0000 Message-ID: <20180409001936.162706-100-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0983;7:qBV7lmnzQHcLABxmhYi5AAJQn2eZNNrqmZ/nd/pmZea6EOjeSoa93ysQ/3gOZj51HC6xWRai4fRUIAEoZJm4urDVw7CTMsunwW5iP530nvtCbRObhhfpSrRfFgzhrV9xibufFp6zBf4qqRXGsRGMUJdBCw+BXpvHFugOOign5cqlJ1Fr0EKqqYCs7h7rdGFfeUoccZRpnBmsOINH+6fp7crkG2FJXM3X10pp8h2UGnDWJLFFx4Wt6D8MK7DO2tMx;20:60MhMi8DLWBKhkcFu84pnomMQFzPyhu5W/dWZP0Ipe5UtGPdoadTUrbHm6rfteq6f0kTIrg4ztrXj74e+NYKyoSk50VlROz3c+D5m6rmxl9vBHDozMMKbpzGo8M46MD7iO7xbRiXP9wSUZa509iQMB8mbJRaC4Tyxe1NIKpuGE8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: c0d60eb2-d6e9-4acc-ffc0-08d59db04940 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0983; x-ms-traffictypediagnostic: DM5PR2101MB0983: 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)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0983;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0983; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(346002)(376002)(39380400002)(366004)(199004)(189003)(478600001)(59450400001)(72206003)(10290500003)(3846002)(102836004)(6506007)(6116002)(25786009)(6436002)(66066001)(99286004)(54906003)(86612001)(6666003)(105586002)(53936002)(76176011)(316002)(486006)(7736002)(22452003)(3660700001)(86362001)(97736004)(106356001)(8936002)(110136005)(5660300001)(11346002)(446003)(81166006)(81156014)(2906002)(8676002)(2900100001)(1076002)(476003)(2616005)(7416002)(10090500001)(6486002)(107886003)(36756003)(4326008)(966005)(2501003)(68736007)(186003)(305945005)(3280700002)(5250100002)(6306002)(6512007)(26005)(14454004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0983;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: ePcn+jt/z5BO83ifP+MKGbll1nADtcN68IbtAj+sJmdRGq1X79HJV0R22duPKDJKhUkMgiR1bp/MLljtQYo9tBz9lQ2bZ7SRJpBTHhniu/1kxQ5Q+AxMCxutMxOPwbrkuPRmQp856v6+FUGHAXd6tzS5FzZ4v073JYUg4UPlIArKzGGp/e0vsjL4IH+QCgdeIrZrZnBSX2I2c2fFMgGVOtZt6U5AKk6PdjJOGIv7s7Id5iWQgdWjonCt62q1MnKT+3bnYo4lvzc7eQx/mH2y4kVLtsKG5dfY6zeDhKOxRI3PErai2vKJ4XmfxrjpJOR+XfM7KEkP1SmCJQ02AgopXP8p7M2+IDpyehKxsbi9zheiN+8OqJfdTgU/3eKuOoFuB8Wg9Y3LuB4sNvQkmIa/7B4QIRVNpve6AUTEZUPvODs= 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: c0d60eb2-d6e9-4acc-ffc0-08d59db04940 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:12.2375 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 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 80b67805b51d..2d3077ce50cd 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1440,10 +1440,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