From: Joanne Koong <joannelkoong@gmail.com>
To: Edward Adam Davis <eadavis@qq.com>
Cc: syzbot+2d215d165f9354b9c4ea@syzkaller.appspotmail.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
miklos@szeredi.hu, syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] fuse: Block access to folio overlimit
Date: Mon, 25 Aug 2025 11:02:30 -0700 [thread overview]
Message-ID: <CAJnrk1acbc80OLZe9Pf7a-8HPRmkJhz=bZVRPOnJQWB78neVVg@mail.gmail.com> (raw)
In-Reply-To: <tencent_F0CF4B761BAA2549BAA0BB1E33D09E561B08@qq.com>
On Fri, Aug 22, 2025 at 6:17 PM Edward Adam Davis <eadavis@qq.com> wrote:
>
> syz reported a slab-out-of-bounds Write in fuse_dev_do_write.
>
> Using the number of bytes alone as the termination condition in a loop
> can prematurely exhaust the allocated memory if the incremented byte count
> is less than PAGE_SIZE.
I don't think the last part of this is quite right. It's fine if the
incremented byte count is less than PAGE_SIZE (which will always be
the case if there's an offset). We only run into this issue when the
number of bytes to retrieve gets truncated by fc->max_pages as the
upper bound and there's an offset.
>
> Add a loop termination condition to prevent overruns.
>
> Fixes: 3568a9569326 ("fuse: support large folios for retrieves")
> Reported-by: syzbot+2d215d165f9354b9c4ea@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=2d215d165f9354b9c4ea
> Tested-by: syzbot+2d215d165f9354b9c4ea@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> fs/fuse/dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index e80cd8f2c049..5150aa25e64b 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -1893,7 +1893,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
>
> index = outarg->offset >> PAGE_SHIFT;
>
> - while (num) {
> + while (num && ap->num_folios < num_pages) {
> struct folio *folio;
> unsigned int folio_offset;
> unsigned int nr_bytes;
> --
> 2.43.0
Thanks for the fix.
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
next prev parent reply other threads:[~2025-08-25 18:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 22:57 [syzbot] [fuse?] KASAN: slab-out-of-bounds Write in fuse_dev_do_write syzbot
2025-08-23 0:53 ` Joanne Koong
2025-08-23 0:55 ` syzbot
2025-08-23 1:13 ` Joanne Koong
2025-08-23 1:15 ` syzbot
2025-08-23 1:17 ` [PATCH] fuse: Block access to folio overlimit Edward Adam Davis
2025-08-25 18:02 ` Joanne Koong [this message]
2025-08-27 1:45 ` [PATCH V2] " Edward Adam Davis
2025-08-27 12:27 ` Miklos Szeredi
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='CAJnrk1acbc80OLZe9Pf7a-8HPRmkJhz=bZVRPOnJQWB78neVVg@mail.gmail.com' \
--to=joannelkoong@gmail.com \
--cc=eadavis@qq.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=syzbot+2d215d165f9354b9c4ea@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).