* [PATCH] Check block magic number so we scan only valid blocks.
@ 2010-07-07 15:09 Peter Watkins
2010-07-07 23:52 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Peter Watkins @ 2010-07-07 15:09 UTC (permalink / raw)
To: xfs; +Cc: Peter Watkins
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?
Signed-off-by: Peter Watkins <treestem@gmail.com>
---
db/freesp.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/db/freesp.c b/db/freesp.c
index e1902c6..7825628 100644
--- a/db/freesp.c
+++ b/db/freesp.c
@@ -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++)
--
1.6.0.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Check block magic number so we scan only valid blocks.
2010-07-07 15:09 [PATCH] Check block magic number so we scan only valid blocks Peter Watkins
@ 2010-07-07 23:52 ` Christoph Hellwig
2010-07-08 19:20 ` Peter Watkins
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2010-07-07 23:52 UTC (permalink / raw)
To: Peter Watkins; +Cc: xfs
On Wed, Jul 07, 2010 at 11:09:11AM -0400, Peter Watkins wrote:
> 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?
Yes, it's reasonable. As long as you'd don't expect directly poking at
a life partition giving correct results..
> Should scanfunc_cnt make a similiar check?
Yes.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Check block magic number so we scan only valid blocks.
2010-07-07 23:52 ` Christoph Hellwig
@ 2010-07-08 19:20 ` Peter Watkins
0 siblings, 0 replies; 3+ messages in thread
From: Peter Watkins @ 2010-07-08 19:20 UTC (permalink / raw)
To: xfs; +Cc: Peter Watkins
OK, thanks for taking a look.
Here's the complete patch in case anyone is interested.
-Peter
Signed-off-by: Peter Watkins <treestem@gmail.com>
---
db/freesp.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/db/freesp.c b/db/freesp.c
index e1902c6..c4dabad 100644
--- a/db/freesp.c
+++ b/db/freesp.c
@@ -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++)
--
1.6.0.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-08 19:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-07 15:09 [PATCH] Check block magic number so we scan only valid blocks Peter Watkins
2010-07-07 23:52 ` Christoph Hellwig
2010-07-08 19:20 ` Peter Watkins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox