From: Kyle Zeng <kylebot@openai.com>
To: stable@vger.kernel.org
Cc: outbounddisclosures@openai.com, Kyle Zeng <kylebot@openai.com>
Subject: [PATCH 6.12.y] reiserfs: validate tail item bounds before conversion
Date: Thu, 11 Jun 2026 15:40:27 -0700 [thread overview]
Message-ID: <20260611224027.74281-1-kylebot@openai.com> (raw)
direct2indirect() moves direct items into an unformatted-node page while
deleting them from the tree. It assumes the item body copied by
reiserfs_delete_item() and the aggregate number of copied tail bytes both
fit in the target tail page.
A corrupted filesystem can violate those assumptions. Multiple direct
items can each fit in the page while their aggregate length exceeds the
filesystem block size, which underflows the final zero-fill length. A
malformed item can also describe an offset and length that cross the page
boundary before the aggregate length is checked.
Validate the per-item page copy and aggregate tail length before calling
reiserfs_delete_item(), and reject corrupt metadata with -EIO after
reporting a filesystem error.
Assisted-by: Codex:gpt-5.5
Signed-off-by: Kyle Zeng <kylebot@openai.com>
---
fs/reiserfs/tail_conversion.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
index 2cec61af2a9e..ba3dd6770d46 100644
--- a/fs/reiserfs/tail_conversion.c
+++ b/fs/reiserfs/tail_conversion.c
@@ -106,6 +106,8 @@ int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode,
* and delete them.
*/
while (1) {
+ unsigned long item_len;
+ unsigned long pgoff;
int tail_size;
/*
@@ -120,6 +122,17 @@ int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode,
RFALSE(!is_direct_le_ih(p_le_ih),
"vs-14055: direct item expected(%K), found %h",
&end_key, p_le_ih);
+ item_len = ih_item_len(p_le_ih);
+ pgoff = (le_ih_k_offset(p_le_ih) - 1) & (PAGE_SIZE - 1);
+ if (item_len > PAGE_SIZE - pgoff ||
+ item_len > blk_size ||
+ total_tail > blk_size - item_len) {
+ reiserfs_error(sb, "PAP-14060",
+ "direct item %h does not fit in tail page",
+ p_le_ih);
+ pathrelse(path);
+ return -EIO;
+ }
tail_size = (le_ih_k_offset(p_le_ih) & (blk_size - 1))
+ ih_item_len(p_le_ih) - 1;
--
2.54.0
next reply other threads:[~2026-06-11 22:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 22:40 Kyle Zeng [this message]
2026-06-12 14:41 ` [PATCH 6.12.y] reiserfs: validate tail item bounds before conversion Sasha Levin
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=20260611224027.74281-1-kylebot@openai.com \
--to=kylebot@openai.com \
--cc=outbounddisclosures@openai.com \
--cc=stable@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