xfsprogs: skip freelist scans of corrupt agf
PATCH 1/1 xfsprogs: skip freelist scans of corrupt agf
If an agf has bad values in the freelist, this can wreak havoc if, for example, first > last and the loop never exits; we index agfl->agfl_bno[i] off into the weeds.
If they're off, warn about it and skip the scan.
Thisis done both in xfs_check and xfs_db's freespace cmd.
Also fix uninit'd variable "i" from previous, similar fix for xfs_repair.
---
db/check.c +10 -0
@@ -4112,6 +4112,16 @@ scan_freelist(return ; } i =be32_to_cpu (agf->agf_flfirst); + +/* verify agf values before proceeding */ +if (be32_to_cpu (agf->agf_flfirst) >=XFS_AGFL_SIZE (mp) || +be32_to_cpu (agf->agf_fllast) >=XFS_AGFL_SIZE (mp)) { +dbprintf (_ ("agf %d freelist blocks bad, skipping " +"freelist scan\n" ), i); +pop_cur (); +return ; + } + count =0 ;for (;;) { bno =be32_to_cpu (agfl->agfl_bno[i]);
db/freesp.c +10 -0
@@ -239,6 +239,16 @@ scan_freelist( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); agfl = iocur_top->data; i =be32_to_cpu (agf->agf_flfirst); + +/* verify agf values before proceeding */ +if (be32_to_cpu (agf->agf_flfirst) >=XFS_AGFL_SIZE (mp) || +be32_to_cpu (agf->agf_fllast) >=XFS_AGFL_SIZE (mp)) { +dbprintf (_ ("agf %d freelist blocks bad, skipping " +"freelist scan\n" ), i); +pop_cur (); +return ; + } +for (;;) { bno =be32_to_cpu (agfl->agfl_bno[i]);addtohist (seqno, bno,1 );
repair/scan.c +1 -1
@@ -1066,6 +1066,7 @@ scan_freelist(return ; } agfl =XFS_BUF_TO_AGFL (agflbuf); + i =be32_to_cpu (agf->agf_flfirst);if (no_modify) {/* agf values not fixed in verify_set_agf, so recheck */
@@ -1078,7 +1079,6 @@ scan_freelist( }else /* should have been fixed in verify_set_agf() */ ASSERT (0 ); - i =be32_to_cpu (agf->agf_flfirst); count =0 ;for (;;) { bno =be32_to_cpu (agfl->agfl_bno[i]);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Eric Sandeen
If an agf has bad values in the freelist, this can wreak havoc if, for example, first > last and the loop never exits; we index agfl->agfl_bno[i] off into the weeds.
If they're off, warn about it and skip the scan.
Thisis done both in
xfs_checkand xfs_db's freespace cmd.Also fix uninit'd variable "i" from previous, similar fix for
xfs_repair.
Looks good.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
This has been commited.
Thanks
--Rich
commit a529cc7f0e5bd1632e5169d015c54e3a6122ee0f
Author: Eric Sandeen <[email protected]> Date: Sat Mar 9 15:21:55 2013 +0000
xfsprogs: skip freelist scans of corrupt agf
If an agf has bad values in the freelist, this can wreak havoc if, for example, first > last and the loop never exits; we index agfl->agfl_bno[i] off into the weeds.
If they're off, warn about it and skip the scan.
This is done both in xfs_check and xfs_db's freespace cmd.
Also fix uninit'd variable "i" from previous, similar fix for xfs_repair.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs