diff options
| author | Bob Peterson <rpeterso@redhat.com> | 2020-11-24 18:44:36 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-12-11 15:22:11 +0300 |
| commit | cecb2b21c1de948505ef1119499d37e20cb990df (patch) | |
| tree | 5f4f37f82a0bc02a47e7b9adaa6a7a5f61a2f23a | |
| parent | 1b1e68927e09bad4a29624e494fd7a73c1b7719b (diff) | |
| download | linux-cecb2b21c1de948505ef1119499d37e20cb990df.tar.xz | |
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>
| -rw-r--r-- | fs/gfs2/rgrp.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index d035309cedd0..5196781fc30f 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -989,6 +989,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; |
