Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash when attempting to read a block pointer with no valid DVAs #17078

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ typedef struct blkptr {
(u_longlong_t)DVA_GET_ASIZE(dva), \
ws); \
} \
ASSERT3S(copies, >, 0); \
if (BP_IS_ENCRYPTED(bp)) { \
len += func(buf + len, size - len, \
"salt=%llx iv=%llx:%llx%c", \
Expand All @@ -695,7 +694,8 @@ typedef struct blkptr {
BP_GET_BYTEORDER(bp) == 0 ? "BE" : "LE", \
BP_IS_GANG(bp) ? "gang" : "contiguous", \
BP_GET_DEDUP(bp) ? "dedup" : "unique", \
copyname[copies], \
copies >= 0 && copies <= 3 ? copyname[copies] : \
"invalid", \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks confusing. I suppose we can get out of 0-3 range only due to a bug in this code itself.

ws, \
(u_longlong_t)BP_GET_LSIZE(bp), \
(u_longlong_t)BP_GET_PSIZE(bp), \
Expand Down
10 changes: 10 additions & 0 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,16 @@ zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp,
bp, (longlong_t)BPE_GET_PSIZE(bp));
}
return (errors == 0);
} else if (BP_IS_HOLE(bp)) {
/*
* Holes are allowed (expected, even) to have no DVAs, no
* checksum, and no psize.
*/
return (errors == 0);
} else if (unlikely(!DVA_IS_VALID(&bp->blk_dva[0]))) {
/* Non-hole, non-embedded BPs _must_ have at least one DVA */
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,
Expand Down
Loading