diff options
author | Brian Behlendorf <[email protected]> | 2021-09-09 18:02:07 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-09 19:02:07 -0600 |
commit | b9ec4a15e5ab40e6c32dd445ecebcd3a3fed1ef9 (patch) | |
tree | 6c1f1a80a67ad6714876b49aebe58c6d4b1a83d2 /module/zfs/arc.c | |
parent | 5a54a4e0517959dd917c0f78d692f7364e597a68 (diff) |
Verify embedded blkptr's in arc_read()
The block pointer verification check in arc_read() should also
cover embedded block pointers. While highly unlikely, accessing
a damaged block pointer can result in panic. To further harden
the code extend the existing check to include embedded block
pointers and add a comment explaining the rational for this
sanity check. Lastly, correct a flaw in zfs_blkptr_verify()
so the error count is checked even when checking a untrusted
config to verify the non-pool-specific portions of a block
pointer.
Reviewed-by: Matthew Ahrens <[email protected]>
Reviewed-by: Tony Nguyen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #12535
Diffstat (limited to 'module/zfs/arc.c')
-rw-r--r-- | module/zfs/arc.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 7697c5391..6acd36313 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -5911,17 +5911,24 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, */ fstrans_cookie_t cookie = spl_fstrans_mark(); top: + /* + * Verify the block pointer contents are reasonable. This should + * always be the case since the blkptr is protected by a checksum. + * However, if there is damage it's desirable to detect this early + * and treat it as a checksum error. This allows an alternate blkptr + * to be tried when one is available (e.g. ditto blocks). + */ + if (!zfs_blkptr_verify(spa, bp, zio_flags & ZIO_FLAG_CONFIG_WRITER, + BLK_VERIFY_LOG)) { + rc = SET_ERROR(ECKSUM); + goto out; + } + if (!embedded_bp) { /* * Embedded BP's have no DVA and require no I/O to "read". * Create an anonymous arc buf to back it. */ - if (!zfs_blkptr_verify(spa, bp, zio_flags & - ZIO_FLAG_CONFIG_WRITER, BLK_VERIFY_LOG)) { - rc = SET_ERROR(ECKSUM); - goto out; - } - hdr = buf_hash_find(guid, bp, &hash_lock); } |