summaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2020-11-24 10:44:36 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-11 13:38:01 +0100
commita6b1752469c053c46bc3bb758784aec36c83997b (patch)
tree80c0ae2a3ea22d25b27c888c2e77d0b06bfc04f0 /fs/gfs2
parent0bde9d5348624c35d31f3275fb11d790154c320f (diff)
downloadlinux-stable-a6b1752469c053c46bc3bb758784aec36c83997b.tar.gz
linux-stable-a6b1752469c053c46bc3bb758784aec36c83997b.tar.bz2
linux-stable-a6b1752469c053c46bc3bb758784aec36c83997b.zip
gfs2: check for empty rgrp tree in gfs2_ri_update
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>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/rgrp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 9621badb9599..56a94535c246 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1000,6 +1000,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;