Skip to content

Commit

Permalink
Verify every block pointer is either embedded, hole, or has a valid DVA
Browse files Browse the repository at this point in the history
Now instead of crashing when attempting to read the corrupt block
pointer, ZFS will return ECKSUM, in a stack that looks like this:

```
none:set-error
zfs.ko`arc_read+0x1d82
zfs.ko`dbuf_read+0xa8c
zfs.ko`dmu_buf_hold_array_by_dnode+0x292
zfs.ko`dmu_read_uio_dnode+0x47
zfs.ko`zfs_read+0x2d5
zfs.ko`zfs_freebsd_read+0x7b
kernel`VOP_READ_APV+0xd0
kernel`vn_read+0x20e
kernel`vn_io_fault_doio+0x45
kernel`vn_io_fault1+0x15e
kernel`vn_io_fault+0x150
kernel`dofileread+0x80
kernel`sys_read+0xb7
kernel`amd64_syscall+0x424
kernel`0xffffffff810633cb
```

This patch should hopefully also prevent such corrupt block pointers
from being written to disk in the first place.

Fixes		openzfs#17077
Sponsored by:	ConnectWise
Signed-off-by:	Alan Somers <[email protected]>
  • Loading branch information
asomers committed Feb 20, 2025
1 parent f7b3232 commit 00fb087
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,11 @@ zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp,
}
return (errors == 0);
}
if (unlikely(!BP_IS_EMBEDDED(bp) && !BP_IS_HOLE(bp) &&
BP_GET_NDVAS(bp) <= 0)) {
errors += zfs_blkptr_verify_log(spa, bp, blk_verify,
"blkptr at %px has no valid DVAs", bp);
}
if (unlikely(BP_GET_CHECKSUM(bp) >= ZIO_CHECKSUM_FUNCTIONS)) {
errors += zfs_blkptr_verify_log(spa, bp, blk_verify,
"blkptr at %px has invalid CHECKSUM %llu",
Expand Down

0 comments on commit 00fb087

Please sign in to comment.