This is a note to let you know that I've just added the patch titled gfs2: check for empty rgrp tree in gfs2_ri_update to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: gfs2-check-for-empty-rgrp-tree-in-gfs2_ri_update.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 778721510e84209f78e31e2ccb296ae36d623f5e Mon Sep 17 00:00:00 2001 From: Bob Peterson <rpeterso@xxxxxxxxxx> Date: Tue, 24 Nov 2020 10:44:36 -0500 Subject: gfs2: check for empty rgrp tree in gfs2_ri_update From: Bob Peterson <rpeterso@xxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Bob Peterson <rpeterso@xxxxxxxxxx> Signed-off-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/gfs2/rgrp.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1017,6 +1017,10 @@ static int gfs2_ri_update(struct gfs2_in 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; Patches currently in stable-queue which might be from rpeterso@xxxxxxxxxx are queue-4.4/gfs2-check-for-empty-rgrp-tree-in-gfs2_ri_update.patch