From patchwork Fri Jan 26 13:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunsheng Luo X-Patchwork-Id: 192590 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp654302dyb; Fri, 26 Jan 2024 05:23:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhkq+nedS8F+1rsXX+z02cWPne8QW7E493FDNa37uRGZW0nMbhssLrAqJMxIi6GpUfWaaF X-Received: by 2002:a17:906:f9c9:b0:a31:58fc:bd83 with SMTP id lj9-20020a170906f9c900b00a3158fcbd83mr837971ejb.10.1706275400097; Fri, 26 Jan 2024 05:23:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706275400; cv=pass; d=google.com; s=arc-20160816; b=G8K85kLo4u7ewokjYdf6RIWdGQ/ovJUKKryf8dxw/ZmTvrs9h2766Irm4pVkFHdVte WtiSYv2p4wFKfjK2LMagGt7BQgpvBaaH2CAqn+SsiyOclfa5InBYUFFq9pHbcmBn0PNV gTlSBao1VK54cYfnEXCtyyWgN2SLde2p/v97jCt5kTkdJYeLuSIestUsnang2zbRwaJO mdoRzSgMf+UxCrCOMJHm2Djyrh6/jfkLHbmC8rpoT0u3s/5w9jiUtzUTujRZfai9fwdl iFdYvE5cKQXTk+2xAq4b2K/nlLjJwQfYoZ04xFNLNDV/nvW0GfCLzbTYJhA5NVZ/R2S3 TpGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=14wpf6z8IKq3p4uqbz679bnQzGIxLBIASvO13vfqTvM=; fh=Gps2WlHT2FGWyEretgDsroJjmn2OHGl9PDc8SLKwie8=; b=NA4NwOv+ksHzt7i0xYWTMwl9pQNYlnxtfh/WUNRUKk32fUQdbu/pVx/KdY2aT71apK BhOAe0f3xddDvO0vMFBUL6e7z0doxaAydeXlb1/eviHEBcvsrj+lMa9tLYyTIo5ZLgkf ATiGNBm29ZNXIij1MI/4HRwR7svHtGPKfJ0SS1uhimIJTrXS6rOwZL+wIWi3RgLuhXA9 xTv9jk/B/Kftnpf0Yue/DV59U6Urg/fajSEuO5gboKlAGD5TdlFqvd0g/5AwSaOr+9nS CUxBmt/krA78eremM2tMirMzY8m/hDXgNCk6oBjp9X5ATGuNG4fIEY99nq9hyUOV9qeB NtgQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ustc.edu dmarc=pass fromdomain=ustc.edu); spf=pass (google.com: domain of linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ustc.edu Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k7-20020a17090627c700b00a31074e5d35si598027ejc.79.2024.01.26.05.23.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 05:23:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ustc.edu dmarc=pass fromdomain=ustc.edu); spf=pass (google.com: domain of linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ustc.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AF2CD1F224E0 for ; Fri, 26 Jan 2024 13:23:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A687E1B971; Fri, 26 Jan 2024 13:23:05 +0000 (UTC) Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E181A1B940 for ; Fri, 26 Jan 2024 13:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706275384; cv=none; b=nXQBNXajGqLuMzdzI815GgBTXxnMo2WbL0qj7qyMTOwRoAgN1vr7065MXYj6rGD9BJCAxTvUjB9SDH9RtT0QgvxXa4dTuUiHucAtdpHAaJ5XfH6SGQ9KPtwyfM6MDC7FrDFXWS1D3M+F0M/BErTKubuPCs+PtRRQJ7PC9rIpxKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706275384; c=relaxed/simple; bh=iHHNC/KB9/++EkjfGa817hv7W5M7/4V/utIeoP4fako=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tCVsQ7Aow3xACOBpCsal+5s5aX7kgKJaxMcf9dAthDaD94LglBvwyIAv4D8+3N9oBXQvnQmPzNyg3TrCa5+rQkJ9dmPm059u+MzhD5cMF4SQWr0ko6MPxNVXF4R3+JXRLdjTiGQZb8Lg7HPSGf+8xp8lp68s3T2koQ1Tjm2IZb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ustc.edu; spf=pass smtp.mailfrom=ustc.edu; arc=none smtp.client-ip=45.254.49.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ustc.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ustc.edu Received: from localhost.localdomain (unknown [61.151.228.146]) by smtp.qiye.163.com (Hmail) with ESMTPA id 84CB97E011A; Fri, 26 Jan 2024 21:22:44 +0800 (CST) From: Chunsheng Luo To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chunsheng Luo Subject: [PATCH] mempolicy: check home_node is in the nodes of policy Date: Fri, 26 Jan 2024 08:22:40 -0500 Message-ID: <20240126132240.24518-1-luochunsheng@ustc.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDQk0YVkpPShlMTE4YTUhOSFUTARMWGhIXJBQOD1 lXWRgSC1lBWU1KVUpOSlVJSUNVSk9NWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Tid: 0a8d45efdf7703a2kunm84cb97e011a X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Mz46TBw5LjMKNg0QLREjHQ8V PzgaFEpVSlVKTEtNSUxOSE1OSk9LVTMWGhIXVRcOFBgTDhUIEx4VHDsOCA8YVR4fDkVZV1kSC1lB WU1KVUpOSlVJSUNVSk9NWVdZCAFZQUpPQkI3Bg++ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789159434020469900 X-GMAIL-MSGID: 1789159434020469900 set_mempolicy_home_node should be used after setting the memory policy. If the home_node isn't in the nodes of policy, we should return failure to avoid misunderstanding. Signed-off-by: Chunsheng Luo --- mm/mempolicy.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 10a590ee1c89..9282be2ae18e 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1536,6 +1536,12 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le err = -EOPNOTSUPP; break; } + + if (!node_isset(home_node, old->nodes)) { + err = -EINVAL; + break; + } + new = mpol_dup(old); if (IS_ERR(new)) { err = PTR_ERR(new);