From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+9d20c3ad7d29227de28d@syzkaller.appspotmail.com
Cc: agruenba@redhat.com, swhiteho@redhat.com,
akpm@linux-foundation.org, apopple@nvidia.com, byungchul@sk.com,
david@kernel.org, gfs2@lists.linux.dev, gourry@gourry.net,
joshua.hahnjy@gmail.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, matthew.brost@intel.com, rakie.kim@sk.com,
syzkaller-bugs@googlegroups.com, ying.huang@linux.alibaba.com,
ziy@nvidia.com
Subject: [PATCH] gfs2: valid the length of rgrp header
Date: Thu, 20 Aug 2026 12:21:38 +0800 [thread overview]
Message-ID: <tencent_D69518E8F6ED56CE0479766DD82CC56EF00A@qq.com> (raw)
In-Reply-To: <6a863306.ae6ddae5.3da009.0013.GAE@google.com>
When mounting a deliberately corrupted filesystem image, an excessively
large rgrp header length is used in a call to kzalloc_objs() within
compute_bitstructs(), and the memory allocator cannot handle such a large
allocation request. This triggers [1].
Add a check for the rgrp header length to avoid [1].
[1]
WARNING: mm/page_alloc.c:5280 at __alloc_frozen_pages_noprof+0x2427/0x2dc0 mm/page_alloc.c:5280, CPU#1: syz-executor256/5629
Call Trace:
alloc_pages_mpol+0x1fb/0x540 mm/mempolicy.c:2490
___kmalloc_large_node+0xe5/0x120 mm/slub.c:5274
__kmalloc_large_node_noprof+0x1c/0x70 mm/slub.c:5305
__do_kmalloc_node mm/slub.c:5322 [inline]
__kmalloc_noprof+0x5a1/0x820 mm/slub.c:5359
_kmalloc_noprof include/linux/slab.h:992 [inline]
_kzalloc_noprof include/linux/slab.h:1309 [inline]
compute_bitstructs fs/gfs2/rgrp.c:766 [inline]
read_rindex_entry+0x4a1/0x1250 fs/gfs2/rgrp.c:931
gfs2_ri_update+0x6f/0x3b0 fs/gfs2/rgrp.c:1001
gfs2_rindex_update+0x40b/0x480 fs/gfs2/rgrp.c:1051
init_inodes+0x1f78/0x2790 fs/gfs2/ops_fstype.c:872
gfs2_fill_super+0x1d3d/0x2cf0 fs/gfs2/ops_fstype.c:1250
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1640
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1332
vfs_get_tree+0x92/0x320 fs/super.c:1700
fc_mount fs/namespace.c:1198 [inline]
Fixes: bb8d8a6f54c1 ("[GFS2] Fix sign problem in quota/statfs and cleanup _host structures")
Reported-by: syzbot+9d20c3ad7d29227de28d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9d20c3ad7d29227de28d
Tested-by: syzbot+9d20c3ad7d29227de28d@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/gfs2/rgrp.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 5988a165a830..53d097ce668e 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -899,6 +899,7 @@ static int read_rindex_entry(struct gfs2_inode *ip)
struct gfs2_rindex buf;
int error;
struct gfs2_rgrpd *rgd;
+ size_t size;
if (pos >= i_size_read(&ip->i_inode))
return 1;
@@ -917,6 +918,13 @@ static int read_rindex_entry(struct gfs2_inode *ip)
rgd->rd_sbd = sdp;
rgd->rd_addr = be64_to_cpu(buf.ri_addr);
rgd->rd_length = be32_to_cpu(buf.ri_length);
+
+ size = rgd->rd_length * sizeof(struct gfs2_bitmap);
+ if (get_order(size) > MAX_PAGE_ORDER) {
+ error = -EINVAL;
+ goto fail;
+ }
+
rgd->rd_data0 = be64_to_cpu(buf.ri_data0);
rgd->rd_data = be32_to_cpu(buf.ri_data);
rgd->rd_bitbytes = be32_to_cpu(buf.ri_bitbytes);
--
2.43.0
next prev parent reply other threads:[~2026-08-20 4:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 22:49 [syzbot] [mm?] [gfs2?] WARNING in read_rindex_entry syzbot
2026-08-20 0:14 ` Andrew Morton
2026-08-20 1:35 ` Zi Yan
2026-08-20 4:21 ` Edward Adam Davis [this message]
2026-08-21 12:54 ` [PATCH] gfs2: valid the length of rgrp header Andreas Gruenbacher
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=tencent_D69518E8F6ED56CE0479766DD82CC56EF00A@qq.com \
--to=eadavis@qq.com \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=david@kernel.org \
--cc=gfs2@lists.linux.dev \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=rakie.kim@sk.com \
--cc=swhiteho@redhat.com \
--cc=syzbot+9d20c3ad7d29227de28d@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.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