Received: by 10.213.65.68 with SMTP id h4csp2115154imn; Sun, 8 Apr 2018 20:05:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/8CFpJmTWucWSajN/fdzEkX8oGlJfvwHGrE/FzvUErm7s9cp1fsQQwOAiNJqvnuW/fvjiO X-Received: by 10.98.172.15 with SMTP id v15mr7287167pfe.129.1523243141309; Sun, 08 Apr 2018 20:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243141; cv=none; d=google.com; s=arc-20160816; b=JtcZl9peApr0cMwt6NGviBNDCZE/NnjvHyjxxF6eHhBPfsdoS2iGO8av/EH2ktbFaW +dN+6obs9mWvEqNfQZIisfF2mNZ7vduEM4EqEO4J4vv/AcdRnjj9L3mYtN8oDNaSLXj8 4BKS98O9Z4dU82ixZrnbrruXUMPfsumf/g6ytbudP0fm4DIwaTely5z+V109+Ghk1X06 goFaM26kQSMnoet3QiroogNb9QGICQWWsuUay9RvNGGf+V1Dj9SQrFQlbKytDlPckoBh sBzXhrah9G3PHcCNBG2jZUnfpIaXbwzNPEq6p/VFgg6mx+OWjDs/42Vio/Jy7ksSzDVN bZng== 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=+LwxDUe/Op/Z598SDF+E4NVe5Vf2iZg6LgBUjRYr7TY=; b=o5QGA8Z8Sxu6GWRps7NzJgD1YFXl50HkQ+gzFM/yFOdKuYUGXRbGeArwAwsOvwSGuU l/oRa3Xh8fLrsVvi++EdPOXgjamGIEfG0qSNj0Kre3JiI2DF7i0OL5aAjl8r+vz0Iwyl wUoPQpRCNwQydLY+/ohuQm4MP8J0kgheNvJFthSOzKIXjQtjQPmGAF7/hfkXJ+GH9ht8 M3iF7lhbUJYL4Q9s+8wG/STu1szzBUcHfiCsWMXQPZBClfVMx6qgxgb7gmW0aB4QQ8P1 JrO9aF1Tjr7BmMhL/4RctnI2MY+epX8LKIBK1gu5ZmOilMdY/VM81SBnJABcnNJofciG GSGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jd8fBJzg; 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 r25si6534124pfh.2.2018.04.08.20.05.04; Sun, 08 Apr 2018 20:05:41 -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=jd8fBJzg; 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 S933059AbeDIAix (ORCPT + 99 others); Sun, 8 Apr 2018 20:38:53 -0400 Received: from mail-co1nam03on0120.outbound.protection.outlook.com ([104.47.40.120]:40064 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932971AbeDIAio (ORCPT ); Sun, 8 Apr 2018 20:38:44 -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=+LwxDUe/Op/Z598SDF+E4NVe5Vf2iZg6LgBUjRYr7TY=; b=jd8fBJzgtQXIOvqIZyx82EfrVIO16f1fr5Bvzw0yEAQclibyBB5Z1O6lLTS7XV/EGFrbCY65zplvL6lWvn8jwzt6EiT63WA4MMPl52VBaQ42yZ9o+36t//qLj1gmcW3oNDspfiLOg3+L07Qs08HoJHCZg+E+Nz3hihc+WK8t4tw= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1125.namprd21.prod.outlook.com (52.132.130.150) 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:38: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:38: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.4 140/162] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Topic: [PATCH AUTOSEL for 4.4 140/162] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages Thread-Index: AQHTz5nWEWW5pFGGVEivzIuPrCMj5Q== Date: Mon, 9 Apr 2018 00:29:36 +0000 Message-ID: <20180409002738.163941-140-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB1125;7:QJa4MZXxikoZvtf2T5TESHUr2TImb9HS83nDVEvLUbZTIAT2CWS9GmVfM94Y4GLIhgmV85HNLSqZ9o1N56qpYsA/qvAAmVg8uQUvyKV1cp/iNwblzSGfBsvD7WIwvoK8lroWOeerT+EtetdvVqR7Wuzh9z9BKdh8nz44nkYv0UCS3ohHPencwR0DiMVNjSKMqXJ06xUC07nE6IlML1/u7oE3FCjMbmD9Vw8ZZ9CdFSookeJcmPv8Yk3f4Orfx/KC;20:5IKT1ZphXtuos4qeEmj6dfC82Pi4x/t/XN35rYB0I3e3oZpamVbNP5hP2Z+Slu4JNGOq9JoQMrZuvmWxLifxvGBrCRN9R6s8N65mkUYQh1NCgRi8pMClMcDNLg/9XCxZnIxSHdhf4805iKW+0scf7Pe85c1nPxikZc1i9c2snTE= X-MS-Office365-Filtering-Correlation-Id: 9076c332-51c5-492c-a9b0-08d59db23e3f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1125; x-ms-traffictypediagnostic: DM5PR2101MB1125: 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)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1125;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1125; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(39380400002)(366004)(376002)(396003)(189003)(199004)(2906002)(25786009)(6512007)(10090500001)(3280700002)(10290500003)(6666003)(6306002)(3660700001)(316002)(110136005)(54906003)(11346002)(107886003)(2616005)(476003)(446003)(36756003)(7416002)(99286004)(86612001)(53936002)(4326008)(486006)(6436002)(3846002)(81156014)(305945005)(966005)(5250100002)(1076002)(102836004)(14454004)(66066001)(7736002)(105586002)(81166006)(59450400001)(106356001)(8676002)(97736004)(6116002)(6506007)(6486002)(5660300001)(186003)(76176011)(22452003)(72206003)(478600001)(2501003)(2900100001)(26005)(86362001)(8936002)(68736007)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1125;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: mGckVFTeLoHgUIbxuWuYIFGPkyAznfy9GWMClkBf7iZuIrCO42aPigAjLM8gSyxY6UGeC/kBDvoAJummsZU8jKFZEEwhNhVQJwtjH7ih2MTk4zw5/TijqseFV5fZWfon2t9EQrz9FvOQ3c9bzYoXXgv52rCxRTMKFMKPn+nNbjfmdFOYshJyuFcBWiEjQl3YDKQfxQXGbJ1TnpUt+AZT1xDcQ4nYVNIVFC1R6CaY4wTHoKiPUJvkJZmR9AO2iT424ylvoKS/STW0FErfmVlU0aZpTWZqjXWfbHwS8cbA39+Bu1J2QQWo+B+W6PRLw/kay5kpboAbOknr8vSuTYmCml+12b8IbT43MZTuHAAEhhhkpv1loY6NRFcAgxqfSdMMDPoDANqAdqv3nIEv+bs4B/c8h+pwAQajyxJawkFaAsc= 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: 9076c332-51c5-492c-a9b0-08d59db23e3f X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:29:36.6151 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1125 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 6196505a1119..77d6f750af3c 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1410,10 +1410,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