linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Edward Adam Davis <eadavis@qq.com>
Cc: syzbot+604424eb051c2f696163@syzkaller.appspotmail.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	phillip@squashfs.org.uk, squashfs-devel@lists.sourceforge.net,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] squashfs: fix oob in squashfs_readahead
Date: Wed, 15 Nov 2023 14:39:17 -0800	[thread overview]
Message-ID: <20231115143917.fdec61135bf3436fc15d2d2c@linux-foundation.org> (raw)
In-Reply-To: <tencent_35864B36740976B766CA3CC936A496AA3609@qq.com>

On Wed, 15 Nov 2023 12:05:35 +0800 Edward Adam Davis <eadavis@qq.com> wrote:

> Before performing a read ahead operation in squashfs_read_folio() and 
> squashfs_readahead(), check if i_size is not 0 before continuing.

I'll merge this for testing, pending Phillip's review.  One thing:

> --- a/fs/squashfs/block.c
> +++ b/fs/squashfs/block.c
> @@ -323,7 +323,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;
> +		res = length < 0 ? -EIO : -EFBIG;
>  		goto out;
>  	}

Seems a bit ugly to test `length' twice for the same thing.  How about

	if (length < 0) {
		res = -EIO;
		got out;
	}
	if (length > output->length || (index + length) > msblk->bytes_used) {
		res = -EFBIG;
		goto out;
	}

?


  reply	other threads:[~2023-11-15 22:39 UTC|newest]

Thread overview: 8+ 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 15:27 ` Phillip Lougher
2023-11-15  4:05 ` [PATCH] squashfs: fix oob in squashfs_readahead Edward Adam Davis
2023-11-15 22:39   ` Andrew Morton [this message]
2023-11-16 15:14   ` Phillip Lougher
2023-11-18  2:12     ` Edward Adam Davis
     [not found]   ` <CGME20231117131718eucas1p13328b32942cce99a99197eb28e14a981@eucas1p1.samsung.com>
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=20231115143917.fdec61135bf3436fc15d2d2c@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=eadavis@qq.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@squashfs.org.uk \
    --cc=squashfs-devel@lists.sourceforge.net \
    --cc=syzbot+604424eb051c2f696163@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).