gfs2-utils: master - libgfs2: Check block range when inserting into rgrp tree

Bob Peterson rpeterso at fedoraproject.org
Tue Sep 29 18:37:47 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=5055de123b8b117c43f2897b8eb925b4eea65ec5
Commit:        5055de123b8b117c43f2897b8eb925b4eea65ec5
Parent:        243caa0b1d3e5debbeba9c99e1ad002b6eae93c9
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Mon Sep 14 09:52:47 2015 -0500
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Tue Sep 29 13:22:48 2015 -0500

libgfs2: Check block range when inserting into rgrp tree

This patch adds checks to function rindex_read to make sure the
rgrp starting address isn't grossly outside the file system.
It may be in the case of severely corrupt file systems from fsck.
If we added them to the rgrp tree, our calculations will get
screwed up, eventually causing a segfault.
---
 gfs2/libgfs2/super.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index b956366..73354ff 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -166,6 +166,12 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
 			return -1;
 
 		gfs2_rindex_in(&ri, (char *)&buf.bufgfs2);
+		if (gfs2_check_range(sdp, ri.ri_addr) != 0) {
+			*sane = 0;
+			if (prev_rgd == NULL)
+				return -1;
+			ri.ri_addr = prev_rgd->ri.ri_addr + prev_rgd->length;
+		}
 		rgd = rgrp_insert(&sdp->rgtree, ri.ri_addr);
 		memcpy(&rgd->ri, &ri, sizeof(struct gfs2_rindex));
 


More information about the cluster-commits mailing list