From: Baul Lee <baul.lee@xbow.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: hch@infradead.org, federico.kirschbaum@xbow.com,
Baul Lee <baul.lee@xbow.com>,
stable@vger.kernel.org
Subject: [PATCH] freevxfs: fix off-page read on a crafted dirblock
Date: Sun, 26 Jul 2026 15:25:14 +0900 [thread overview]
Message-ID: <20260726062514.43756-1-baul.lee@xbow.com> (raw)
vxfs_readdir() and vxfs_find_entry() both advance the intra-page offset
pg_ofs by VXFS_DIRBLKOV(sbi, dbp) at each dirblock boundary and then
dereference
de = (struct vxfs_direct *)(kaddr + pg_ofs);
without re-checking pg_ofs against PAGE_SIZE in between. The enclosing
while (pg_ofs < PAGE_SIZE && pos < limit) test only gates loop
re-entry, not the deref that follows the addition in the same
iteration.
VXFS_DIRBLKOV() is 2 * d_nhash + 4, and d_nhash is an unvalidated
on-disk __fs16, so the overhead is attacker arithmetic of up to roughly
32 pages. kaddr is page_address() of the single order-0 page-cache
page returned by vxfs_get_page(), so nothing else bounds the addition
and the de->d_reclen load lands off the mapped page. Directory pages
are consumed unvalidated: vxfs_check_page() was never implemented, only
a commented-out call survives.
Both sites are reachable on any mounted crafted freevxfs image, the
vxfs_readdir() one from an unprivileged getdents64(2) and the
vxfs_find_entry() one from any path walk into the directory. When
d_ino is non-zero vxfs_readdir() also feeds the off-page bytes to
dir_emit(), so they reach userspace. KASAN reports a 2-byte
out-of-bounds read in vxfs_readdir().
Re-check pg_ofs against PAGE_SIZE right after the addition and before
the deref in both loops, restoring the invariant they already assume.
The added break leaves the page the same way the existing zero-d_reclen
break does. Well-formed directories, whose overhead never pushes
pg_ofs past a single dirblock, are unaffected.
Discovered by XBOW, triaged by Baul Lee <baul.lee@xbow.com>
Fixes: 12495ea3ac47 ("freevxfs: refactor readdir and lookup code")
Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
Reported-by: Baul Lee <baul.lee@xbow.com>
Cc: stable@vger.kernel.org
Signed-off-by: Baul Lee <baul.lee@xbow.com>
---
fs/freevxfs/vxfs_lookup.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index 138e08de976e..b068f93359fb 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -87,6 +87,8 @@ vxfs_find_entry(struct inode *ip, struct dentry *dp, struct page **ppp)
pos += overhead;
pg_ofs += overhead;
+ if (pg_ofs >= PAGE_SIZE)
+ break;
}
de = (struct vxfs_direct *)(kaddr + pg_ofs);
@@ -237,6 +239,8 @@ vxfs_readdir(struct file *fp, struct dir_context *ctx)
pos += overhead;
pg_ofs += overhead;
+ if (pg_ofs >= PAGE_SIZE)
+ break;
}
de = (struct vxfs_direct *)(kaddr + pg_ofs);
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-07-26 6:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 6:25 Baul Lee [this message]
2026-07-28 7:24 ` Christian Brauner
2026-08-04 7:00 ` [PATCH v2] freevxfs: fix off-page reads in the directory walkers Baul Lee
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=20260726062514.43756-1-baul.lee@xbow.com \
--to=baul.lee@xbow.com \
--cc=federico.kirschbaum@xbow.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®