From: DaeMyung Kang <charsyam@gmail.com>
To: Namjae Jeon <linkinjeon@kernel.org>, Hyunchul Lee <hyc.lee@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
DaeMyung Kang <charsyam@gmail.com>
Subject: [PATCH v2 3/3] ntfs: only alias volume $UpCase to default on exact match
Date: Thu, 21 May 2026 19:17:51 +0900 [thread overview]
Message-ID: <20260521101751.591345-4-charsyam@gmail.com> (raw)
In-Reply-To: <20260521101751.591345-1-charsyam@gmail.com>
load_and_init_upcase() currently aliases vol->upcase to the global
default upcase whenever the shared prefix matches, and then truncates
vol->upcase_len to that shorter prefix. The result is correct only by
accident: upcase[] accesses in name collation are gated by upcase_len,
so the prefix-equality alias produces the same fold output as keeping
the volume's own shorter table.
Still, prefix equality is not equality: the volume table is logically
distinct from the default and should not be replaced by it unless they
are byte-for-byte identical. Use memcmp() to compare the complete table
in one expression and drop the now-redundant upcase_len rewrite.
No user-visible change is expected for compliant volumes whose $UpCase
has exactly default_upcase_len entries; shorter volume tables are no
longer aliased to the default.
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
---
fs/ntfs/super.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 14fd244f29fe..971c2822f5e3 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1323,7 +1323,6 @@ static bool load_and_init_upcase(struct ntfs_volume *vol)
u8 *addr;
pgoff_t index, max_index;
unsigned int size;
- int i, max;
ntfs_debug("Entering.");
/* Read upcase table and setup vol->upcase and vol->upcase_len. */
@@ -1374,16 +1373,11 @@ static bool load_and_init_upcase(struct ntfs_volume *vol)
mutex_unlock(&ntfs_lock);
return true;
}
- max = default_upcase_len;
- if (max > vol->upcase_len)
- max = vol->upcase_len;
- for (i = 0; i < max; i++)
- if (vol->upcase[i] != default_upcase[i])
- break;
- if (i == max) {
+ if (default_upcase_len == vol->upcase_len &&
+ !memcmp(vol->upcase, default_upcase,
+ default_upcase_len * sizeof(*default_upcase))) {
kvfree(vol->upcase);
vol->upcase = default_upcase;
- vol->upcase_len = max;
ntfs_nr_upcase_users++;
mutex_unlock(&ntfs_lock);
ntfs_debug("Volume specified $UpCase matches default. Using default.");
--
2.43.0
next prev parent reply other threads:[~2026-05-21 10:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 17:01 [PATCH 0/3] ntfs: fix mount failure cleanup and free-count setup DaeMyung Kang
2026-05-20 17:01 ` [PATCH 1/3] ntfs: free volume-wide resources on fill_super failure DaeMyung Kang
2026-05-21 1:03 ` Hyunchul Lee
2026-05-20 17:01 ` [PATCH 2/3] ntfs: wake free-cluster waiters when precalc allocation fails DaeMyung Kang
2026-05-21 1:03 ` Hyunchul Lee
2026-05-20 17:01 ` [PATCH 3/3] ntfs: only alias volume $UpCase to default on exact match DaeMyung Kang
2026-05-21 1:04 ` Hyunchul Lee
2026-05-21 1:02 ` [PATCH 0/3] ntfs: fix mount failure cleanup and free-count setup Hyunchul Lee
2026-05-21 10:17 ` [PATCH v2 " DaeMyung Kang
2026-05-21 10:17 ` [PATCH v2 1/3] ntfs: free volume-wide resources on fill_super failure DaeMyung Kang
2026-05-21 10:17 ` [PATCH v2 2/3] ntfs: avoid heap allocation for free-cluster readahead state DaeMyung Kang
2026-05-21 12:19 ` Namjae Jeon
2026-05-21 12:48 ` CharSyam
2026-05-22 0:00 ` Hyunchul Lee
2026-05-22 0:28 ` Namjae Jeon
2026-05-22 1:22 ` CharSyam
2026-05-22 4:31 ` Namjae Jeon
2026-05-21 10:17 ` DaeMyung Kang [this message]
2026-05-21 13:00 ` [PATCH v3 0/3] ntfs: fix mount failure cleanup and free-count setup DaeMyung Kang
2026-05-21 13:00 ` [PATCH v3 1/3] ntfs: free volume-wide resources on fill_super failure DaeMyung Kang
2026-05-21 13:00 ` [PATCH v3 2/3] ntfs: avoid heap allocation for free-cluster readahead state DaeMyung Kang
2026-05-21 13:00 ` [PATCH v3 3/3] ntfs: only alias volume $UpCase to default on exact match DaeMyung Kang
2026-05-23 14:11 ` [PATCH v3 0/3] ntfs: fix mount failure cleanup and free-count setup Namjae Jeon
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=20260521101751.591345-4-charsyam@gmail.com \
--to=charsyam@gmail.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome