Commit 77872151 authored by Bob Peterson's avatar Bob Peterson Committed by Andreas Gruenbacher
Browse files

gfs2: check for empty rgrp tree in gfs2_ri_update



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: default avatar <syzbot+e3f23ce40269a4c9053a@syzkaller.appspotmail.com>
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent 515b269d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -985,6 +985,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip)
	if (error < 0)
	if (error < 0)
		return error;
		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);
	set_rgrp_preferences(sdp);


	sdp->sd_rindex_uptodate = 1;
	sdp->sd_rindex_uptodate = 1;