mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aibing Chen <chenaibing@cmss.chinamobile.com>
To: akpm@linux-foundation.org, phillip@squashfs.org.uk
Cc: phillip.lougher@gmail.com, squashfs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org,
	syzbot+5d7ba5f6127ed887f459@syzkaller.appspotmail.com,
	syzbot+0b7a8fb8279a59e8a188@syzkaller.appspotmail.com,
	Aibing Chen <chenaibing@cmss.chinamobile.com>
Subject: [PATCH 2/2] squashfs: return -EIO on out-of-bounds directory entry in lookup
Date: Sat, 14 Nov 2026 22:51:28 +0800	[thread overview]
Message-ID: <20261114145128.625-2-chenaibing@cmss.chinamobile.com> (raw)
In-Reply-To: <20261114145128.625-1-chenaibing@cmss.chinamobile.com>

The three squashfs_dir_space() bounds checks added to
squashfs_lookup() by commit 5213b0a08263 ("Squashfs: fix variables in
directory code and add more sanity checks") jump to read_failure
without setting err.  err then holds the positive number of bytes
read by the last successful squashfs_read_metadata() (8 for a
directory entry), and squashfs_lookup() returns ERR_PTR(err) with a
positive value, which IS_ERR() does not catch.  The VFS dereferences
the bogus pointer and crashes:

  general protection fault in lookup_open ...
  RIP: lookup_open+0x890/0x16e0 fs/namei.c:4648
  ...
  squashfs_lookup fs/squashfs/namei.c:250 [inline]
  ...

The squashfs_dir_space() checks validate on-disk directory content,
so jump to data_error (which sets err = -EIO), matching the
neighbouring content validation checks.

Reported-by: syzbot+0b7a8fb8279a59e8a188@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0b7a8fb8279a59e8a188
Fixes: 5213b0a08263 ("Squashfs: fix variables in directory code and add more sanity checks")
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
 fs/squashfs/namei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/squashfs/namei.c b/fs/squashfs/namei.c
index 5f8decee2..5dc21ddaf 100644
--- a/fs/squashfs/namei.c
+++ b/fs/squashfs/namei.c
@@ -203,7 +203,7 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 		 * Read directory header.
 		 */
 		if (!squashfs_dir_space(dir, length, sizeof(dirh)))
-			goto read_failure;
+			goto data_error;
 
 		err = squashfs_read_metadata(dir->i_sb, &dirh, &block,
 				&offset, sizeof(dirh));
@@ -222,7 +222,7 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 			 * Read directory entry.
 			 */
 			if (!squashfs_dir_space(dir, length, sizeof(*dire)))
-				goto read_failure;
+				goto data_error;
 
 			err = squashfs_read_metadata(dir->i_sb, dire, &block,
 					&offset, sizeof(*dire));
@@ -237,7 +237,7 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 				goto data_error;
 
 			if (!squashfs_dir_space(dir, length, size))
-				goto read_failure;
+				goto data_error;
 
 			err = squashfs_read_metadata(dir->i_sb, dire->name,
 					&block, &offset, size);
-- 
2.50.1.windows.1




      reply	other threads:[~2026-11-14 14:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 14:51 [PATCH 1/2] squashfs: return -EINVAL on invalid directory inode size Aibing Chen
2026-11-14 14:51 ` Aibing Chen [this message]

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=20261114145128.625-2-chenaibing@cmss.chinamobile.com \
    --to=chenaibing@cmss.chinamobile.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip.lougher@gmail.com \
    --cc=phillip@squashfs.org.uk \
    --cc=squashfs-devel@lists.sourceforge.net \
    --cc=syzbot+0b7a8fb8279a59e8a188@syzkaller.appspotmail.com \
    --cc=syzbot+5d7ba5f6127ed887f459@syzkaller.appspotmail.com \
    /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®