Skip to content

lib/glob: bug fixes, new features, and tests

Josh Law linux-kselftest lkml 4 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest8 patches 6 repliesIn review
  2. v38 patches 0 repliesSuperseded
  3. v28 patches 0 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v17 patches0 repliesSuperseded

Changes in v4 from the cover letter

- Resend: v3 accidentally included stale v2 patch files in the same email thread. No code changes from v3.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8lib/glob: normalize inverted character class rangeslib/glob.c+7 -10 replies
2/8lib/glob: treat trailing backslash as literal characterlib/glob.c+2 -10 replies
3/8lib/glob: accept [^...] as character class negation syntaxlib/glob.c+4 -40 replies
4/8lib/glob: add case-insensitive glob_match_nocase()include/linux/glob.h lib/glob.c+65 -110 replies
5/8lib/glob: add glob_validate() for pattern syntax checkinginclude/linux/glob.h lib/glob.c+44 -00 replies
6/8lib/tests: add glob test cases for escapes, edge cases, and new featureslib/tests/glob_kunit.c+47 -00 replies
7/8lib/tests: add kunit tests for glob_match_nocase() and glob_validate()lib/tests/glob_kunit.c+77 -00 replies
8/8kunit: validate glob filter patterns before uselib/kunit/executor.c+13 -00 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid GowJosh Law
SeriesA-b T-b T-b
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/8] lib/glob: bug fixes, new features, and tests

Bug fixes, extensions, and test coverage for lib/glob.c:

Patches 1-3 fix corner cases in the existing glob_match():
- Inverted character class ranges like [z-a] are now normalized instead of silently failing to match.
- A trailing backslash is treated as a literal '\' rather than reading past the end of the pattern string.
- [^...] is accepted as an alias for [!...] to match the regex-style negation syntax documented in glob(7).

Patches 4-5 add two new utility functions:
- glob_match_nocase() for case-insensitive matching, useful for subsystems like ATA that need case-folded denylist comparisons.
- glob_validate() for checking pattern syntax before use, so callers can reject malformed patterns early with a clear error.

Patches 6-7 add kunit test coverage:
- 47 new test cases for glob_match covering escapes, inverted ranges, caret negation, edge cases, and unclosed brackets.
- 11 test cases for glob_match_nocase.
- 17 test cases for glob_validate.

Patch 8 adds a real in-tree caller for glob_validate() in the kunit executor, validating user-provided filter_glob patterns and returning -EINVAL for malformed ones.

Changes since v3:
- Resend: v3 accidentally included stale v2 patch files in the same email thread. No code changes from v3.

Changes since v2:
- Fixed missing '^' in __glob_match metacharacter comment (patch 4).
- Dropped unnecessary braces in glob_validate case '[' (patch 5).
- Added real-world example to glob_validate() commit message (patch 5).

Changes since v1:
- Added patch 8 (kunit executor caller for glob_validate).
- Updated glob_match_nocase() commit message to reference the ATA denylist as the intended caller (follow-up patch).

Josh Law (8):
lib/glob: normalize inverted character class ranges lib/glob: treat trailing backslash as literal character lib/glob: accept [^...] as character class negation syntax lib/glob: add case-insensitive glob_match_nocase() lib/glob: add glob_validate() for pattern syntax checking lib/tests: add glob test cases for escapes, edge cases, and new
features
lib/tests: add kunit tests for glob_match_nocase() and glob_validate()
kunit: validate glob filter patterns before use

 include/linux/glob.h   |   2 +
 lib/glob.c             | 123 ++++++++++++++++++++++++++++++++++++----
 lib/kunit/executor.c   |  13 +++++
 lib/tests/glob_kunit.c | 124 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 252 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1