From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E941B2EBB9E for ; Thu, 26 Mar 2026 04:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774500314; cv=none; b=RvX3wqUhNOXB3wMCC7g2vHadfiK+uw4lugMgWX7AfguY9EuySnYWxp1gfW5H6oLHhGW+KmG/+rZ24QZYgXOBYi7mgCf2k53UGlMlaDQj+NHESJYjbTQqUr2skvWGQXQy6LGkKHplcAPXKZe14JgTTcjpinOTZfWUWPxckJiB2ro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774500314; c=relaxed/simple; bh=kvA0cYUcshlLGYsJTaWyMulJLXbduJxmAoS3HllArsw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=oV4HCqgyv+ZVr82Wws9POeSEe4jbU5Umqu6GZY/nunELreXmDHIW8KpVgcsEEXYHNviqRWk3JAvdP7+46CN/ITxAqATpUoy/MgBiDvk5eAi8b4X7RKA/IhYKbEqoIu8E+XGk1RyVU6485V2IjRuNGDob3uPi1Gk4da+SCKyzVlg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=BtC/D1zm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="BtC/D1zm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41817C19424; Thu, 26 Mar 2026 04:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774500313; bh=kvA0cYUcshlLGYsJTaWyMulJLXbduJxmAoS3HllArsw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BtC/D1zmpy9Y3CTHB9kBnkMWC1aqLdXaOLqADh/j9iwkPGIOtDpOlTj5ryGwzggNK +vCqSBn/aKaNgTOeBiyj7hveSnWfKPDj1yrVqlsunL3Lf1vaAmPeCJa2zP6/WnEe5A 9ENRJYkN36/307VJL2eJORixC9zScl8qk3rvn+68= Date: Wed, 25 Mar 2026 21:45:12 -0700 From: Andrew Morton To: Inseob Kim Cc: linux-kernel@vger.kernel.org, changbin.du@gmail.com, jbaron@akamai.com, joe@perches.com, Josh Law Subject: Re: [PATCH v2] lib: parser: Fix match_wildcard to correctly handle trailing stars Message-Id: <20260325214512.98de0f2fb847d56de9282b23@linux-foundation.org> In-Reply-To: References: <20260326020630.4139520-1-inseob@google.com> <20260325192534.151e86e439e7e4080a630d4c@linux-foundation.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Thu, 26 Mar 2026 13:12:26 +0900 Inseob Kim wrote: > On Thu, Mar 26, 2026 at 11:25 AM Andrew Morton > wrote: > > > > On Thu, 26 Mar 2026 11:06:04 +0900 Inseob Kim wrote: > > > > > This fixes a bug of match_wildcard that incorrectly handles trailing > > > asterisks. For example, `match_wildcard("abc**", "abc")` must return > > > true, but it returns false. > > > > > > Signed-off-by: Inseob Kim > > > --- > > > v2: > > > - Added Cc. No changes to the code. > > > --- > > > lib/parser.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/lib/parser.c b/lib/parser.c > > > index 73e8f8e5be73..62da0ac0d438 100644 > > > --- a/lib/parser.c > > > +++ b/lib/parser.c > > > @@ -315,7 +315,7 @@ bool match_wildcard(const char *pattern, const char *str) > > > } > > > } > > > > > > - if (*p == '*') > > > + while (*p == '*') > > > ++p; > > > return !*p; > > > } > > > > Thanks, looks right. > > > > We don't appear to have any selftesting for this code. > > Would you prefer test cases for match_wildcard? That would of course be wonderful, but such a contribution is unrelated to this bugfix. Up to you. > > > > Should all of parser.c actually exist? Some of it is a subset of > > lib/glob.c? > > Wildcard is definitely a subset of glob, but we're intentionally using > wildcard for genfscon for example > (https://lore.kernel.org/selinux/20250318083139.1515253-1-takayas@chromium.org/). > I'd like to leave the parser.c as is. That's a nice boot-time improvement, but I don't understand from that why wildcard is preferable to glob?