Skip to contentSkip to conversation

v2 xfsprogs: fix inode crash in xfs_repair

PATCH In review Mark Tinguely 2 participants 3 messages Aug 16, 2013 – Aug 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v2 xfsprogs: fix inode crash in xfs_repair

Adding the lost+found in phase 6 could allocate an inode from a new inode chunk. Since this chunk was not around in phase 3 when the inode chunk are verificated and added to the avl tree, the avl tree look up will return a NULL pointer. This results in a NULL defererence and segmentation fault.

Add the newly created inode chunk as if found in the chunk verification phase.

---
v2:
1) add comment.
2) simplify the if statement.

 repair/incore_ino.c |    2 +-
 repair/phase6.c     |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
repair/incore_ino.c +1 -1
Index: b/repair/incore_ino.c
===================================================================
@@ -700,7 +700,7 @@ get_inode_parent(ino_tree_node_t *irec,
 	return(0LL);
 }
 
-static void
+void
 alloc_ex_data(ino_tree_node_t *irec)
 {
 	parent_list_t 	*ptbl;
repair/phase6.c +16 -0
Index: b/repair/phase6.c
===================================================================
@@ -930,6 +930,22 @@ mk_orphanage(xfs_mount_t *mp)
 	irec = find_inode_rec(mp,
 			XFS_INO_TO_AGNO(mp, ino),
 			XFS_INO_TO_AGINO(mp, ino));
+
+	if (irec == NULL) {
+		/*
+		 * This inode is allocated from a newly created inode
+		 * chunk and therefore did not exist when inode chunks
+		 * were processed in phase3. Add this group of inodes to
+		 * the entry avl tree as if they were discovered in phase3.
+		 */
+		irec = set_inode_free_alloc(mp, XFS_INO_TO_AGNO(mp, ino),
+					    XFS_INO_TO_AGINO(mp, ino));
+		alloc_ex_data(irec);
+
+		for (i = 0; i < XFS_INODES_PER_CHUNK; i++)
+			set_inode_free(irec, i);
+	}
+
 	ino_offset = get_inode_offset(mp, ino, irec);
 
 	/*

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#2 lore raw
In reply to Mark Tinguely

Thanks for the patch Mark, it has been committed.

--Rich

commit 3ac87fbf6ac29494dc46134323733551aac1737c

Author: Mark Tinguely <[email protected]>
Date:   Fri Aug 16 18:12:43 2013 +0000

xfsprogs: fix inode crash in xfs_repair

Adding the lost+found in phase 6 could allocate an inode from a new inode chunk. Since this chunk was not around in phase 3 when the inode chunks are verificated and added to the avl tree, the avl tree look up will return a NULL pointer. This results in a NULL defererence and segmentation fault.

Add the newly created inode chunk as if found in the chunk verification phase.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs