mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] squashfs: fix NULL pointer deref in squashfs_lookup TRACE
@ 2026-11-26 11:19 Shuai Liu
  2026-11-26 23:49 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Shuai Liu @ 2026-11-26 11:19 UTC (permalink / raw)
  To: phillip
  Cc: akpm, squashfs-devel, linux-kernel, syzbot+f1290205423d04eee4cb,
	Shuai Liu

In squashfs_lookup(), commit 5b515c0ec855 ("Squashfs: don't compute start
or alloc memory on empty directory or index") moved the TRACE statement
to before the block/offset variable initialization, so the TRACE was
rewritten to use squashfs_i(inode) instead of squashfs_i(dir). But
inode is initialized to NULL, so squashfs_i(NULL) evaluates to an
invalid pointer which triggers a kernel page fault when
CONFIG_DYNAMIC_DEBUG or DEBUG enables the pr_debug() call.

Fix: replace squashfs_i(inode) with squashfs_i(dir) in the TRACE.

Fixes: 5b515c0ec855 ("Squashfs: don't compute start or alloc memory on empty directory or index")
Reported-by: syzbot+f1290205423d04eee4cb@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=f1290205423d04eee4cb
Signed-off-by: Shuai Liu <847807867@qq.com>
---
 fs/squashfs/namei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/squashfs/namei.c b/fs/squashfs/namei.c
index c8009e0b2edda..30e9383f09928 100644
--- a/fs/squashfs/namei.c
+++ b/fs/squashfs/namei.c
@@ -134,8 +134,8 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 	int offset, err, length;
 	unsigned int dir_count, size;
 
-	TRACE("Entered squashfs_lookup [%llx:%x]\n", squashfs_i(inode)->start,
-			squashfs_i(inode)->offset);
+	TRACE("Entered squashfs_lookup [%llx:%x]\n", squashfs_i(dir)->start,
+			squashfs_i(dir)->offset);
 
 	if (len > SQUASHFS_NAME_LEN)
 		return ERR_PTR(-ENAMETOOLONG);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] squashfs: fix NULL pointer deref in squashfs_lookup TRACE
  2026-11-26 11:19 [PATCH] squashfs: fix NULL pointer deref in squashfs_lookup TRACE Shuai Liu
@ 2026-11-26 23:49 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-11-26 23:49 UTC (permalink / raw)
  To: Shuai Liu
  Cc: phillip, squashfs-devel, linux-kernel, syzbot+f1290205423d04eee4cb

On Thu, 26 Nov 2026 19:19:24 +0800 Shuai Liu <847807867@qq.com> wrote:

> In squashfs_lookup(), commit 5b515c0ec855 ("Squashfs: don't compute start
> or alloc memory on empty directory or index") moved the TRACE statement
> to before the block/offset variable initialization, so the TRACE was
> rewritten to use squashfs_i(inode) instead of squashfs_i(dir). But
> inode is initialized to NULL, so squashfs_i(NULL) evaluates to an
> invalid pointer which triggers a kernel page fault when
> CONFIG_DYNAMIC_DEBUG or DEBUG enables the pr_debug() call.
> 
> ...
>  
> -	TRACE("Entered squashfs_lookup [%llx:%x]\n", squashfs_i(inode)->start,
> -			squashfs_i(inode)->offset);
> +	TRACE("Entered squashfs_lookup [%llx:%x]\n", squashfs_i(dir)->start,
> +			squashfs_i(dir)->offset);
>  
>  	if (len > SQUASHFS_NAME_LEN)
>  		return ERR_PTR(-ENAMETOOLONG);

Yep, thanks, Phillip squashed this bug in the v4 series.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-26 23:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 11:19 [PATCH] squashfs: fix NULL pointer deref in squashfs_lookup TRACE Shuai Liu
2026-11-26 23:49 ` Andrew Morton

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®