HomeFreeBSD

Fix errant EFAULT during writes (#8719)

Description

Fix errant EFAULT during writes (#8719)

Commit 98bb45e resolved a deadlock which could occur when
handling a page fault in zfs_write(). This change added
the uio_fault_disable field to the uio structure but failed
to initialize it to B_FALSE. This uninitialized field would
cause uiomove_iov() to call __copy_from_user_inatomic()
instead of copy_from_user() resulting in unexpected EFAULTs.

Resolve the issue by fully initializing the uio, and clearing
the uio_fault_disable flags after it's used in zfs_write().

Additionally, reorder the uio_t field assignments to match
the order the fields are declared in the structure.

Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8640
Closes #8719

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on May 8 2019, 5:04 PM
GitHub <noreply@github.com>Committed on May 8 2019, 5:04 PM
Parents
rG1f02ecc5a56d: Make zfs_special_class_metadata_reserve_pct into a parameter
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG515ddf65042e: Fix errant EFAULT during writes (#8719) (authored by Brian Behlendorf <behlendorf1@llnl.gov>).May 8 2019, 5:04 PM