fs/fuse/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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.
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
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>
syz reported a slab-out-of-bounds Write in fuse_dev_do_write.
When the number of bytes to be retrieved is truncated to the upper limit
by fc->max_pages and there is an offset, the oob is triggered.
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>
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
---
V1 -> V2: update root cause
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
On Wed, 27 Aug 2025 at 03:46, Edward Adam Davis <eadavis@qq.com> wrote: > > syz reported a slab-out-of-bounds Write in fuse_dev_do_write. > > When the number of bytes to be retrieved is truncated to the upper limit > by fc->max_pages and there is an offset, the oob is triggered. > > Add a loop termination condition to prevent overruns. Applied, thanks. Miklos
© 2016 - 2025 Red Hat, Inc.