Skip to contentSkip to conversation

libxfs: verifier should set buffer error when da block has a bad magic number

PATCH Darrick J. Wong 2 participants 3 messages Aug 25, 2015 XFS filesystem

lore
Share & tools
lore
#0 lore raw

If xfs_da3_node_read_verify() doesn't recognize the magic number of a buffer it's just read, set the buffer error to -EFSCORRUPTED so that the error can be sent up to userspace. Without this patch we'll ASSERT on the bad magic eventually while trying to traverse or change the block, but we really ought to fail fast in the verifier.

---
 fs/xfs/libxfs/xfs_da_btree.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_da_btree.c +1 -0
index 2385f8c..ec4a5a1 100644
@@ -238,6 +238,7 @@ xfs_da3_node_read_verify(
 
 	/* corrupt block */
 	xfs_verifier_error(bp);
+	xfs_buf_ioerror(bp, -EFSCORRUPTED);
 }
 
 const struct xfs_buf_ops xfs_da3_node_buf_ops = {

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

#1 lore raw
Quoted 16 lines · Darrick J. Wong

If xfs_da3_node_read_verify() doesn't recognize the magic number of a buffer it's just read, set the buffer error to -EFSCORRUPTED so that the error can be sent up to userspace. Without this patch we'll ASSERT on the bad magic eventually while trying to traverse or change the block, but we really ought to fail fast in the verifier.

---
 fs/xfs/libxfs/xfs_da_btree.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_da_btree.c +0 -0
index 2385f8c..ec4a5a1 100644

fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_read_verify( · line 242

Quoted 5 lines
fs/xfs/libxfs/xfs_da_btree.c +1 -0
@@ -238,6 +238,7 @@ xfs_da3_node_read_verify(
 
 	/* corrupt block */
 	xfs_verifier_error(bp);
+	xfs_buf_ioerror(bp, -EFSCORRUPTED);
 }

That should be in the default block of the switch statement, otherwise it will overwrite the error from the node format crc/ verifier failures....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 18 lines · Dave Chinner
Quoted 17 lines · Darrick J. Wong

If xfs_da3_node_read_verify() doesn't recognize the magic number of a buffer it's just read, set the buffer error to -EFSCORRUPTED so that the error can be sent up to userspace. Without this patch we'll ASSERT on the bad magic eventually while trying to traverse or change the block, but we really ought to fail fast in the verifier.

---
 fs/xfs/libxfs/xfs_da_btree.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_da_btree.c +0 -0
index 2385f8c..ec4a5a1 100644
@@ -238,6 +238,7 @@ xfs_da3_node_read_verify(
 
Quoted 8 lines

fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_read_verify( · line 242

Quoted 4 lines
fs/xfs/libxfs/xfs_da_btree.c +1 -0
 	/* corrupt block */
 	xfs_verifier_error(bp);
+	xfs_buf_ioerror(bp, -EFSCORRUPTED);
 }

That should be in the default block of the switch statement, otherwise it will overwrite the error from the node format crc/ verifier failures....

Aha, I missed that. Thank you.

--D

Quoted 12 lines

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

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