]> git.proxmox.com Git - mirror_zfs.git/commit
OpenZFS 8378 - crash due to bp in-memory modification of nopwrite block
authorMatthew Ahrens <mahrens@delphix.com>
Fri, 14 Apr 2017 19:59:18 +0000 (12:59 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 4 Jul 2017 22:41:24 +0000 (15:41 -0700)
commit02dc43bc4615537e8e198170a0711e317c8e6dda
tree4867dbc985b020863ef8a53df03b86d3ecb89901
parent8ca78ab00278332a877d7d95e057c0b4aca5f9ad
OpenZFS 8378 - crash due to bp in-memory modification of nopwrite block

Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
The problem is that zfs_get_data() supplies a stale zgd_bp to
dmu_sync(), which we then nopwrite against.
zfs_get_data() doesn't hold any DMU-related locks, so after it
copies db_blkptr to zgd_bp, dbuf_write_ready() could change
db_blkptr, and dbuf_write_done() could remove the dirty record.
dmu_sync() then sees the stale BP and that the dbuf it not dirty,
so it is eligible for nop-writing.
The fix is for dmu_sync() to copy db_blkptr to zgd_bp after
acquiring the db_mtx. We could still see a stale db_blkptr,
but if it is stale then the dirty record will still exist and
thus we won't attempt to nopwrite.

OpenZFS-issue: https://www.illumos.org/issues/8378
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3127742
Closes #6293
cmd/ztest/ztest.c
module/zfs/dmu.c
module/zfs/zfs_vnops.c
module/zfs/zvol.c