Check block magic number so we scan only valid blocks.
PATCH 1/1 Check block magic number so we scan only valid blocks.
Hello,
Occasionally I've hit a SEGV while querying free space in xfs_db on a mounted file system. In scanfunc_bno, block->bb_numrecs has crazy values. And bb_magic is not XFS_ABTB_MAGIC.
Does a check like this, similiar to other places, make sense? Should scanfunc_cnt make a similiar check?
--- db/freesp.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
db/freesp.c +3 -0
@@ -286,6 +286,9 @@ scanfunc_bno(xfs_alloc_ptr_t *pp;xfs_alloc_rec_t *rp; +if (be32_to_cpu (block->bb_magic) !=XFS_ABTB_MAGIC ) +return ; +if (level ==0 ) { rp =XFS_ALLOC_REC_ADDR (mp, block,1 );for (i =0 ; i <be16_to_cpu (block->bb_numrecs); i++)
Signature · 6 lines
1.6.0.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Peter Watkins
Hello,
Occasionally I've hit a SEGV while querying free space in
xfs_dbon a mounted file system. Inscanfunc_bno,block->bb_numrecshas crazy values. Andbb_magicis notXFS_ABTB_MAGIC.Does a check like this, similiar to other places, make sense?
Yes, it's reasonable. As long as you'd don't expect directly poking at a life partition giving correct results..
Quoted 1 line
Should
scanfunc_cntmake a similiar check?
Yes.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/1 Check block magic number so we scan only valid blocks.
OK, thanks for taking a look.
Here's the complete patch in case anyone is interested.
-Peter
--- db/freesp.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
db/freesp.c +6 -0
@@ -286,6 +286,9 @@ scanfunc_bno(xfs_alloc_ptr_t *pp;xfs_alloc_rec_t *rp; +if (be32_to_cpu (block->bb_magic) !=XFS_ABTB_MAGIC ) +return ; +if (level ==0 ) { rp =XFS_ALLOC_REC_ADDR (mp, block,1 );for (i =0 ; i <be16_to_cpu (block->bb_numrecs); i++)
@@ -310,6 +313,9 @@ scanfunc_cnt(xfs_alloc_ptr_t *pp;xfs_alloc_rec_t *rp; +if (be32_to_cpu (block->bb_magic) !=XFS_ABTC_MAGIC ) +return ; +if (level ==0 ) { rp =XFS_ALLOC_REC_ADDR (mp, block,1 );for (i =0 ; i <be16_to_cpu (block->bb_numrecs); i++)
Signature · 6 lines
1.6.0.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs