mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: glaubitz@physik.fu-berlin.de, frank.li@vivo.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	vdubeyko@coreweave.com, Viacheslav Dubeyko <slava@dubeyko.com>
Subject: [PATCH 0/3] hfsplus: fix "Illegal name" fsck failures from non-canonical decomposition
Date: Fri, 18 Sep 2026 17:16:04 -0700	[thread overview]
Message-ID: <20260919001607.2777138-1-slava@dubeyko.com> (raw)

The xfstests generic/339 (fsstress-style dirhash collision testing)
leaves an HFS+ volume corrupted and, as a result, fsck.hfsplus
reports a long run of "Illegal name".

The root cause is that fs/hfsplus/unicode.c's decomposition table
(Apple Technote #1150) decomposes each source character entirely on
its own and never does anything further with the result. Real fsck_hfs
has carried a permanent "FixDecomps" fixup in CatalogCheck.c for
exactly what that leaves unhandled:

 - combining marks contributed by two different source characters
   landing adjacent must be in ascending Unicode combining-class order,
   not just input order;
 - a small, fixed set of characters either weren't decomposed at all,
   or were decomposed into a sequence Apple corrected back in Mac OS X
   10.2 ("Jaguar"), and this driver's table still predates that.

A name that violates either of these gets flagged "Illegal name" by any
real macOS system (or fsck_hfs) that later reads the volume, even
though nothing else about it is wrong.

This series makes hfsplus store, hash and compare names the same way
current macOS does:

 1/3 adds the data: a Unicode combining-class table generated from UCD
     12.1.0, and two legacy-decomposition correction tables decoded
     programmatically from hfsprogs 540.1's own DecompData.h. Pure
     data, no behavior change.

 2/3 adds the logic that uses that data: canonical reordering of
     decomposed names, a fallback to the legacy decomposition table,
     and legacy sequence substitution, all applied in hfsplus_asc2uni()
     so this is what actually gets stored. hfsplus_hash_dentry() and
     hfsplus_compare_dentry() are reworked to canonicalize names the
     same way, so a lookup can't disagree with what a create() of the
     same name actually wrote.

 3/3 adds KUnit coverage for both: reordering, stability of equal-class
     marks, the legacy decomposition and sequence fixups, and that
     hashing/comparison agree across differently-typed-but-equivalent
     spellings of the same name.

Viacheslav Dubeyko (3):
  hfsplus: add Unicode combining-class and legacy decomposition data
  hfsplus: canonicalize decomposed catalog names like fsck_hfs expects
  hfsplus: add KUnit coverage for canonical reordering and legacy fixups

 fs/hfsplus/hfsplus_fs.h   |   6 +-
 fs/hfsplus/tables.c       | 496 ++++++++++++++++++++++++++++++++++++++
 fs/hfsplus/unicode.c      | 390 ++++++++++++++++++++----------
 fs/hfsplus/unicode.h      |  63 +++++
 fs/hfsplus/unicode_test.c | 309 ++++++++++++++++++++++++
 5 files changed, 1127 insertions(+), 137 deletions(-)
 create mode 100644 fs/hfsplus/unicode.h

-- 
2.43.0


             reply	other threads:[~2026-09-19  0:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19  0:16 Viacheslav Dubeyko [this message]
2026-09-19  0:16 ` [PATCH 1/3] hfsplus: add Unicode combining-class and legacy decomposition data Viacheslav Dubeyko
2026-09-19  0:16 ` [PATCH 2/3] hfsplus: canonicalize decomposed catalog names like fsck_hfs expects Viacheslav Dubeyko
2026-09-19  0:16 ` [PATCH 3/3] hfsplus: add KUnit coverage for canonical reordering and legacy fixups Viacheslav Dubeyko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260919001607.2777138-1-slava@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vdubeyko@coreweave.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®