]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
gfs2: check for empty rgrp tree in gfs2_ri_update
authorBob Peterson <rpeterso@redhat.com>
Tue, 24 Nov 2020 15:44:36 +0000 (10:44 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Dec 2020 12:39:06 +0000 (13:39 +0100)
commit 778721510e84209f78e31e2ccb296ae36d623f5e 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>
fs/gfs2/rgrp.c

index c4eb6a5fcea995c207bd4c475f603a735de9cf8a..87656030ec7da93b946ed69724a0974c97690af7 100644 (file)
@@ -990,6 +990,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;