Skip to contentSkip to conversation

squashfs: fix NULL pointer deref in squashfs_lookup TRACE

PATCH New Shuai Liu 1 participant 1 message Nov 26 SquashFS file system

lore
Share & tools
lore

Shuai Liu

author
#0 lore raw

PATCH 1/1 squashfs: fix NULL pointer deref in squashfs_lookup TRACE

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 [email protected]
---
 fs/squashfs/namei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/squashfs/namei.c +2 -2
index c8009e0b2edda..30e9383f09928 100644
@@ -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);
Signature · 1 line
2.43.0