public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+604424eb051c2f696163@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [syzbot] [PATCH] Test oob in squashfs readahead
Date: Mon, 13 Nov 2023 22:35:41 -0800	[thread overview]
Message-ID: <000000000000dfb54d060a16fec6@google.com> (raw)
In-Reply-To: <000000000000b1fda20609ede0d1@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [PATCH] Test oob in squashfs readahead
Author: eadavis@qq.com

please test squashfs readahead oob

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 13d88ac54ddd

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 581ce9519339..7db8f2920c9e 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -287,6 +287,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 
 		if (index + 2 > msblk->bytes_used) {
 			res = -EIO;
+			printk("srd1: i:%d, bu:%d \n", index, msblk->bytes_used);
 			goto out;
 		}
 		res = squashfs_bio_read(sb, index, 2, &bio, &offset);
@@ -295,6 +296,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 
 		if (WARN_ON_ONCE(!bio_next_segment(bio, &iter_all))) {
 			res = -EIO;
+			printk("srd2 \n");
 			goto out_free_bio;
 		}
 		/* Extract the length of the metadata block */
@@ -305,6 +307,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 		} else {
 			if (WARN_ON_ONCE(!bio_next_segment(bio, &iter_all))) {
 				res = -EIO;
+				printk("srd3 \n");
 				goto out_free_bio;
 			}
 			data = bvec_virt(bvec);
@@ -324,6 +327,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 	if (length < 0 || length > output->length ||
 			(index + length) > msblk->bytes_used) {
 		res = -EIO;
+		printk("srd4: l:%d, ol: %d, bu: %d \n", length, output->length, msblk->bytes_used);
 		goto out;
 	}
 
@@ -336,10 +340,12 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 
 	if (compressed) {
 		if (!msblk->stream) {
+			printk("srd5 \n");
 			res = -EIO;
 			goto out_free_bio;
 		}
 		res = msblk->thread_ops->decompress(msblk, bio, offset, length, output);
+		printk("srd6: r: %d \n", res);
 	} else {
 		res = copy_bio_to_actor(bio, output, offset, length);
 	}
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 8ba8c4c50770..b54d6b993357 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -461,6 +461,12 @@ static int squashfs_read_folio(struct file *file, struct folio *folio)
 	TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
 				page->index, squashfs_i(inode)->start);
 
+	if (!file_end) {
+		printk("i:%p, is:%d, %s\n", inode, i_size_read(inode), __func__);
+		res = -EINVAL;
+		goto out;
+	}
+
 	if (page->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >>
 					PAGE_SHIFT))
 		goto out;
@@ -547,6 +553,11 @@ static void squashfs_readahead(struct readahead_control *ractl)
 	int i, file_end = i_size_read(inode) >> msblk->block_log;
 	unsigned int max_pages = 1UL << shift;
 
+	if (!file_end && !start) {
+		printk("i:%p, is:%d, %s\n", inode, i_size_read(inode), __func__);
+		return;
+	}
+
 	readahead_expand(ractl, start, (len | mask) + 1);
 
 	pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL);
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index aa3411354e66..e7c2ccd6a382 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -403,9 +403,11 @@ int squashfs_read_inode(struct inode *inode, long long ino)
 	} else
 		squashfs_i(inode)->xattr_count = 0;
 
+	printk("in: %p, fs: %d, it: %d, %s\n", inode, inode->i_size, type, __func__);
 	return 0;
 
 failed_read:
+	printk("in: %p, fs: %d, it: %d, %s\n", inode, inode->i_size, type, __func__);
 	ERROR("Unable to read inode 0x%llx\n", ino);
 	return err;
 }


  parent reply	other threads:[~2023-11-14  6:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12  5:32 [syzbot] [squashfs?] KASAN: slab-out-of-bounds Write in squashfs_readahead (2) syzbot
2023-11-13 11:00 ` [syzbot] [PATCH] Test oob in squashfs readahead syzbot
2023-11-13 12:10 ` syzbot
2023-11-13 15:27 ` [syzbot] [squashfs?] KASAN: slab-out-of-bounds Write in squashfs_readahead (2) Phillip Lougher
2023-11-14  0:22 ` [syzbot] [PATCH] Test oob in squashfs readahead syzbot
2023-11-14  1:04 ` syzbot
2023-11-14  1:55 ` syzbot
2023-11-14  3:33 ` syzbot
2023-11-14  4:06 ` syzbot
2023-11-14  6:35 ` syzbot [this message]
2023-11-14  7:53 ` syzbot
2023-11-14  8:58 ` syzbot
2023-11-15  2:21 ` syzbot
     [not found] ` <tencent_35864B36740976B766CA3CC936A496AA3609@qq.com>
2023-11-15 22:39   ` [PATCH] squashfs: fix oob in squashfs_readahead Andrew Morton
2023-11-16 15:14   ` Phillip Lougher
2023-11-17 13:17   ` Marek Szyprowski
2023-11-17 15:48     ` Andrew Morton

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=000000000000dfb54d060a16fec6@google.com \
    --to=syzbot+604424eb051c2f696163@syzkaller.appspotmail.com \
    --cc=linux-kernel@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