Skip to contentSkip to conversation

xfs: superblock buffers need to be sector sized

PATCH In review Dave Chinner 2 participants 3 messages Feb 24, 2015 – Feb 25, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: superblock buffers need to be sector sized

From: Dave Chinner <[email protected]>

In secondary_sb_wack() we zero the unused portion of both the on-disk superblock and the in-memory copy that we have. When the device sector size is 4k, this causes xfs_repair to crash like so:

# xfs_repair /dev/ram1
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
bad magic number
bad on-disk superblock 3 - bad magic number
primary/secondary superblock 3 conflict - AG superblock geometry info conflicts with filesystem geometry
zeroing unused portion of secondary superblock (AG #3)
#

The stack trace is indicative:

#0  memset ()
#1  0x000000000040404b in secondary_sb_wack
#2  verify_set_agheader
#3  0x0000000000427b4b in scan_ag
#4  0x000000000042a2ca in worker_thread
#5  0x00007ffff77ba0a4 in start_thread
#6  0x00007ffff74efc2d in clone

Which points at memset overrunning the in memory buffer, as it is only 512 bytes in length.

---
 repair/scan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
repair/scan.c +1 -1
index ce8d7f5..12aa782 100644
@@ -1485,7 +1485,7 @@ scan_ag(
 	int		status;
 	char		*objname = NULL;
 
-	sb = (struct xfs_sb *)calloc(BBSIZE, 1);
+	sb = (struct xfs_sb *)calloc(BBTOB(XFS_FSS_TO_BB(mp, 1)), 1);
 	if (!sb) {
 		do_error(_("can't allocate memory for superblock\n"));
 		return;
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Dave Chinner

From: Dave Chinner <[email protected]>

In secondary_sb_wack() we zero the unused portion of both the on-disk superblock and the in-memory copy that we have. When the device sector size is 4k, this causes xfs_repair to crash like so:

# xfs_repair /dev/ram1
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
bad magic number
bad on-disk superblock 3 - bad magic number
primary/secondary superblock 3 conflict - AG superblock geometry info conflicts with filesystem geometry
zeroing unused portion of secondary superblock (AG #3)
#

The stack trace is indicative:

#0  memset ()
#1  0x000000000040404b in secondary_sb_wack
#2  verify_set_agheader
#3  0x0000000000427b4b in scan_ag
#4  0x000000000042a2ca in worker_thread
#5  0x00007ffff77ba0a4 in start_thread
#6  0x00007ffff74efc2d in clone
Quoted 5 lines

Which points at memset overrunning the in memory buffer, as it is only 512 bytes in length.

---

The patch subject line should probably say 'xfsprogs:' or 'repair:,' otherwise this looks good to me:

Quoted 23 lines
 repair/scan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
repair/scan.c +1 -1
index ce8d7f5..12aa782 100644
@@ -1485,7 +1485,7 @@ scan_ag(
 	int		status;
 	char		*objname = NULL;
 
-	sb = (struct xfs_sb *)calloc(BBSIZE, 1);
+	sb = (struct xfs_sb *)calloc(BBTOB(XFS_FSS_TO_BB(mp, 1)), 1);
 	if (!sb) {
 		do_error(_("can't allocate memory for superblock\n"));
 		return;
Signature · 6 lines
2.0.0

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

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

#2 lore raw
Quoted 29 lines · Brian Foster
Quoted 28 lines · Dave Chinner

From: Dave Chinner <[email protected]>

In secondary_sb_wack() we zero the unused portion of both the on-disk superblock and the in-memory copy that we have. When the device sector size is 4k, this causes xfs_repair to crash like so:

# xfs_repair /dev/ram1
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
bad magic number
bad on-disk superblock 3 - bad magic number
primary/secondary superblock 3 conflict - AG superblock geometry info conflicts with filesystem geometry
zeroing unused portion of secondary superblock (AG #3)
#

The stack trace is indicative:

#0  memset ()
#1  0x000000000040404b in secondary_sb_wack
#2  verify_set_agheader
#3  0x0000000000427b4b in scan_ag
#4  0x000000000042a2ca in worker_thread
#5  0x00007ffff77ba0a4 in start_thread
#6  0x00007ffff74efc2d in clone
Quoted 8 lines
Quoted 5 lines

Which points at memset overrunning the in memory buffer, as it is only 512 bytes in length.

---

The patch subject line should probably say 'xfsprogs:' or 'repair:,' otherwise this looks good to me:

Right, my mistake.

Quoted 1 line

Thanks,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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