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 v5 4/4] ntfs: validate index root allocated_size on lookup
Date: Sun, 7 Jun 2026 14:17:23 +0900 [thread overview]
Message-ID: <20260607051723.1499833-5-charsyam@gmail.com> (raw)
In-Reply-To: <20260607051723.1499833-1-charsyam@gmail.com>
The resident $INDEX_ROOT validator already checks the index root header
fields, but it still does not bound index_length through allocated_size or
ensure allocated_size stays within the resident index area.
Callers consume index.allocated_size as the resident root capacity.
ntfs_ie_add() uses it to decide whether an insertion can be done in place,
and ntfs_ie_insert() then updates the root without re-checking the resident
value boundary.
Read allocated_size in the resident $INDEX_ROOT validator, require it to be
8-byte aligned, require index_length <= allocated_size, and require
allocated_size <= the resident index area. Valid slack remains allowed.
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
---
fs/ntfs/attrib.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index cf49eade6b22..49c8f1f3b9dd 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -657,15 +657,19 @@ static bool ntfs_index_root_attr_value_is_valid(const u8 *value, const u32 value
u32 index_size;
u32 entries_offset;
u32 index_length;
+ u32 allocated_size;
ir = (const struct index_root *)value;
index_size = value_length - offsetof(struct index_root, index);
entries_offset = le32_to_cpu(ir->index.entries_offset);
index_length = le32_to_cpu(ir->index.index_length);
+ allocated_size = le32_to_cpu(ir->index.allocated_size);
- if ((entries_offset | index_length) & 7 ||
+ if ((entries_offset | index_length | allocated_size) & 7 ||
entries_offset < sizeof(struct index_header) ||
entries_offset > index_length ||
+ index_length > allocated_size ||
+ allocated_size > index_size ||
index_length - entries_offset < sizeof(struct index_entry_header))
return false;
--
2.43.0
next prev parent reply other threads:[~2026-06-07 5:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-07 5:17 [PATCH v5 0/4] ntfs: finish index root lookup validation DaeMyung Kang
2026-06-07 5:17 ` [PATCH v5 1/4] ntfs: reject non-resident records for resident-only attributes DaeMyung Kang
2026-06-07 5:17 ` [PATCH v5 2/4] ntfs: grow index root value before reparent header update DaeMyung Kang
2026-06-07 5:17 ` [PATCH v5 3/4] ntfs: update index root allocated size before shrink DaeMyung Kang
2026-06-07 5:17 ` DaeMyung Kang [this message]
2026-06-08 5:08 ` [PATCH v5 4/4] ntfs: validate index root allocated_size on lookup Hyunchul Lee
2026-06-08 5:38 ` 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=20260607051723.1499833-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
all inboxes | Powered by JetHome®