1
0
Fork 0

gfs2: check for empty rgrp tree in gfs2_ri_update

commit 778721510e upstream.

If gfs2 tries to mount a (corrupt) file system that has no resource
groups it still tries to set preferences on the first one, which causes
a kernel null pointer dereference. This patch adds a check to function
gfs2_ri_update so this condition is detected and reported back as an
error.

Reported-by: syzbot+e3f23ce40269a4c9053a@syzkaller.appspotmail.com
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5.4-rM2-2.2.x-imx-squashed
Bob Peterson 2020-11-24 10:44:36 -05:00 committed by Greg Kroah-Hartman
parent c358e7e99d
commit cd928d387b
1 changed files with 4 additions and 0 deletions

View File

@ -1008,6 +1008,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip)
if (error < 0)
return error;
if (RB_EMPTY_ROOT(&sdp->sd_rindex_tree)) {
fs_err(sdp, "no resource groups found in the file system.\n");
return -ENOENT;
}
set_rgrp_preferences(sdp);
sdp->sd_rindex_uptodate = 1;