From: Dmitry Morgun <d.morgun@ispras.ru>
To: shaggy@kernel.org
Cc: Dmitry Morgun <d.morgun@ispras.ru>,
jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: [PATCH] jfs: fix out-of-bounds write on symlink inode with negative i_size
Date: Tue, 8 Sep 2026 21:59:42 +0000 [thread overview]
Message-ID: <20260908215942.9458-1-d.morgun@ispras.ru> (raw)
i_size is read from disk without validation: diRead() calls
read_metapage() to get a struct dinode from the on-disk image, then
copy_from_dinode() assigns ip->i_size = le64_to_cpu(dip->di_size)
directly. In jfs_iget(), i_size is checked only against the upper
bound IDATASIZE using a signed comparison, so a negative i_size
passes through to the fast symlink path. There, pointer arithmetic
with the negative offset produces an invalid address far outside
the buffer, causing a kernel crash.
Add an explicit check for negative i_size that returns -EIO,
consistent with how other invalid inode states are handled in the
same function.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Fixes: d69e83d99cf8 ("jfs: ensure symlinks are NUL-terminated")
Signed-off-by: Dmitry Morgun <d.morgun@ispras.ru>
---
fs/jfs/inode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 4066d263e9e1..bf940b2c623f 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -19,6 +19,7 @@
#include "jfs_unicode.h"
#include "jfs_debug.h"
#include "jfs_dmap.h"
+#include "jfs_superblock.h"
struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
@@ -50,6 +51,11 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
inode->i_op = &page_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &jfs_aops;
+ } else if (inode->i_size < 0) {
+ jfs_error(inode->i_sb, "symlink inode has invalid i_size %lld\n",
+ inode->i_size);
+ iget_failed(inode);
+ return ERR_PTR(-EIO);
} else {
inode->i_op = &jfs_fast_symlink_inode_operations;
inode->i_link = JFS_IP(inode)->i_inline;
--
2.34.1
reply other threads:[~2026-09-08 22:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260908215942.9458-1-d.morgun@ispras.ru \
--to=d.morgun@ispras.ru \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=shaggy@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®