Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp198915rdd; Wed, 22 Nov 2023 13:14:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUj/NlKSkWzKE+TQuSLsYZD4Hq+nx2CvnJbZvOnSgKqlFOs1871mS5+4UcPFb8IYTKabT2 X-Received: by 2002:a05:6a21:a5a4:b0:18b:5100:4aac with SMTP id gd36-20020a056a21a5a400b0018b51004aacmr3148291pzc.13.1700687669933; Wed, 22 Nov 2023 13:14:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700687669; cv=none; d=google.com; s=arc-20160816; b=l9GHXTvnSdmv4OQD9h5FYBdyFlJ0lBG6G8jIoo70CXKgfji2Oq3uRfmbcbmfCD95V0 t/HZmNyYKau+aDv2v6n3o/Rgauo6oDX5PozREt2yMZzv42ykIzKfsqZnmft8NgHJ/m1D ws4mKdyDBkBTUjA52pwRGdXK7YC/+u/da1i+YyjrPyucUnKGI3b9yuBSad/qPrKOoHmD 5bQcpj8BmVSObvPmxunEIPrInqF/5s9zmRI+HuxI4c4NJBs+bNQKm7wIRRM5IC3EaAiT feG40h9i/9+zJ7lkxeRMLdw4aXU2YZWEkllo+pXuJf1+HBPBnV1Hgldi+PwoOp9w2NKE JZ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HOrPhfU2mXxyBlZrT3heEZSZHpuQWnnIT7HedEB0hRs=; fh=oGSAV5gRGUhpxAQmPPuhXynNS/gQQ/xIjVhrkaeHVfk=; b=HFcv7Xi40sOLejmuEbxrWbD6VDzKazPAuXqG43FmbEuOzBElkaOXT0BFWX1cUYxKH2 XuwQtEoffndUr9O/OKMMEudePCCH0t72iwNyEC8WcUYSUGYp0NeAnEsA66KO9sfAlo0j EdjSSzbUZ8gHMf6vZCmxsl7V9XiAi4BCWZ0SLLrJ0Wmk6agwXuiLP2R/TPSKpb9eN/Fc yloT5VelQTiqyT+9TPq+eCUCgkgyalP0ZVNLpQtVUo5FKLxbikQawETlZJHqXmgq1biE 0fDmR4GwWMfEJVXpiJRM6fc38h1TshJ/u0h0pa7tHKEBiAjJoTjGhu9h8R697KUpxN4Z 722Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JlX5uNar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u11-20020a63ef0b000000b005b3b8896199si235527pgh.591.2023.11.22.13.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 13:14:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JlX5uNar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 610248274AE8; Wed, 22 Nov 2023 13:13:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344335AbjKVVNM (ORCPT + 99 others); Wed, 22 Nov 2023 16:13:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344372AbjKVVMz (ORCPT ); Wed, 22 Nov 2023 16:12:55 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E45FF1719; Wed, 22 Nov 2023 13:12:35 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id 41be03b00d2f7-5bd306f86a8so167434a12.0; Wed, 22 Nov 2023 13:12:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700687555; x=1701292355; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HOrPhfU2mXxyBlZrT3heEZSZHpuQWnnIT7HedEB0hRs=; b=JlX5uNarejalLnI2Pu9HRXNhGvHcdL33My/bwG9ec8rFnYIwKhWNLJ0Xq6ol+iUSR6 Daqhk/EcldqH7f2dIz328o5byD9vx3Uybrwb7v9Qaz9MYOtXGViOpheoTDS67EnuZqNR lc9P2iVzKMtElT+73SsU6L2wEPfkYvsrOvccYSZw9EdPAMRhi9LachWT0FMA9TDeOuP1 lL1jcHeIi0DV3QgZO1YCyAJhwvFX2wEFJBALpog+DvgCb2qtkg648KTK0Ob23P8j/Rqb kf/eOggQdNf8S3eHc8d9YFvl95uktY65xUJPfEoraCwpjmMNeczSPz3ke8iAm8ZjvfpY D13w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700687555; x=1701292355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HOrPhfU2mXxyBlZrT3heEZSZHpuQWnnIT7HedEB0hRs=; b=MTwSuOl3ZAWmV/EQawgctdZwe0NbRgG8+AfqKVztIbCqG052bzG+4nhQqrVzGKklt8 2FqWDWEVk2aai994xPJ/9fMKBSgYJGp3Z9T8SbGNp0tE3KzHYF8izyQRIaW2W+y0vZIu s3N/JzxoT4UqgAEDgj0etk1WCXbz7sZmsLsd5gG9Qq3SNGr7SCFx/HQhoEsD9i7A6LVq pMgzeH+ZO83KzTSL5Ib+r4N6FcyzEpjKKivy6dcBJ13n1Ak3B/DGxU6BtQyVvTgE65WE IDCFIMp3adGSZrDsCMGjadBtzh2VZ49tQLemagBmse5qOuovvQumt0g9VijPD8Rz2viF yKDw== X-Gm-Message-State: AOJu0YwLOEOxni1bAR4+hJxFVu3LW9/51buaUaF4Va0WlKrAdB0v7soW jv1pJb62R2i6ThTmv9dV9Q== X-Received: by 2002:a05:6a21:9982:b0:189:11e8:6237 with SMTP id ve2-20020a056a21998200b0018911e86237mr4066108pzb.51.1700687554935; Wed, 22 Nov 2023 13:12:34 -0800 (PST) Received: from fedora.mshome.net ([75.167.214.230]) by smtp.gmail.com with ESMTPSA id j18-20020a635512000000b005bdbce6818esm132136pgb.30.2023.11.22.13.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 13:12:34 -0800 (PST) From: Gregory Price X-Google-Original-From: Gregory Price To: linux-mm@kvack.org Cc: linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, arnd@arndb.de, tglx@linutronix.de, luto@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, mhocko@kernel.org, tj@kernel.org, ying.huang@intel.com, Gregory Price Subject: [RFC PATCH 10/11] mm/mempolicy: mpol_parse_str should ignore trailing characters in nodelist Date: Wed, 22 Nov 2023 16:11:59 -0500 Message-Id: <20231122211200.31620-11-gregory.price@memverge.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231122211200.31620-1-gregory.price@memverge.com> References: <20231122211200.31620-1-gregory.price@memverge.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 13:13:33 -0800 (PST) When validating MPOL_PREFERRED, the nodelist has already been parsed and error checked by nodelist_parse. So rather than looping through the string again, we should just check that the weight of the nodemask is 1, which is the actual condition we care to check. This also handles the case where newline characters are present. Signed-off-by: Gregory Price --- mm/mempolicy.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index a418af0a1359..eac71f2adfdc 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -3159,12 +3159,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol) * nodelist (or nodes) cannot be empty. */ if (nodelist) { - char *rest = nodelist; - while (isdigit(*rest)) - rest++; - if (*rest) - goto out; - if (nodes_empty(nodes)) + if (nodes_weight(nodes) != 1) goto out; } break; -- 2.39.1