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 v4 4/6] ntfs: validate resident volume name values on lookup
Date: Sat, 30 May 2026 23:35:12 +0900 [thread overview]
Message-ID: <20260530143514.3083601-5-charsyam@gmail.com> (raw)
In-Reply-To: <20260530143514.3083601-1-charsyam@gmail.com>
The shared lookup-time attribute validator now has a safe caller path for
$VOLUME_NAME corruption: ntfs_write_volume_label() no longer treats
lookup errors as an absent label, and the mount path reinitializes its
search context before continuing to $VOLUME_INFORMATION.
Add $VOLUME_NAME-specific resident value validation. A volume name is
stored as a UTF-16LE string, so reject odd byte lengths, and reject
values longer than the NTFS volume label limit. Empty labels remain
valid.
Also reject non-resident $VOLUME_NAME records. $VOLUME_NAME is required
to be resident, like $FILE_NAME; a crafted non-resident record would
otherwise pass lookup and ntfs_write_volume_label() would remove it as if
it were a normal resident attribute.
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
---
fs/ntfs/attrib.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 98e0b8ea2edd..7e293b85ad19 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -607,6 +607,14 @@ static bool ntfs_file_name_attr_value_is_valid(const u8 *value, const u32 value_
value_length - offsetof(struct file_name_attr, file_name);
}
+static bool ntfs_volume_name_attr_value_is_valid(const u32 value_length)
+{
+ if (value_length & 1)
+ return false;
+
+ return value_length <= NTFS_MAX_LABEL_LEN * sizeof(__le16);
+}
+
struct ntfs_resident_attr_value {
const u8 *data;
u32 len;
@@ -657,7 +665,7 @@ static bool ntfs_attr_value_is_valid(struct ntfs_volume *vol,
u32 min_len;
if (a->non_resident) {
- if (a->type == AT_FILE_NAME)
+ if (a->type == AT_FILE_NAME || a->type == AT_VOLUME_NAME)
goto corrupt;
if (!ntfs_non_resident_attr_value_is_valid(a))
goto corrupt;
@@ -676,6 +684,10 @@ static bool ntfs_attr_value_is_valid(struct ntfs_volume *vol,
if (!ntfs_file_name_attr_value_is_valid(value.data, value.len))
goto corrupt;
break;
+ case AT_VOLUME_NAME:
+ if (!ntfs_volume_name_attr_value_is_valid(value.len))
+ goto corrupt;
+ break;
}
return true;
--
2.43.0
next prev parent reply other threads:[~2026-05-30 14:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 14:35 [PATCH v4 0/6] ntfs: validate attribute " DaeMyung Kang
2026-05-30 14:35 ` [PATCH v4 1/6] " DaeMyung Kang
2026-05-30 14:35 ` [PATCH v4 2/6] ntfs: do not replace volume name after lookup errors DaeMyung Kang
2026-05-30 14:35 ` [PATCH v4 3/6] ntfs: reinit search context before volume information lookup DaeMyung Kang
2026-05-30 14:35 ` DaeMyung Kang [this message]
2026-05-30 14:35 ` [PATCH v4 5/6] ntfs: update index root allocated size before shrink DaeMyung Kang
2026-05-30 14:35 ` [PATCH v4 6/6] ntfs: validate resident index root values on lookup DaeMyung Kang
2026-06-01 4:37 ` Namjae Jeon
2026-06-01 7:51 ` CharSyam
2026-06-01 8:46 ` Namjae Jeon
2026-06-06 1:40 ` Namjae Jeon
2026-06-05 15:30 ` [PATCH v4 0/6] ntfs: validate attribute " Namjae Jeon
2026-06-07 0:00 ` CharSyam
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=20260530143514.3083601-5-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