diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -246,8 +246,14 @@ found: error = uiomove_fromphys(&m, offset, tlen, uio); - if (uio->uio_rw == UIO_WRITE && error == 0) + if (uio->uio_rw == UIO_WRITE) { + /* + * Even a failed copy may have changed the page's contents, + * because uiomove_fromphys() can copy part of the data before + * it fails. + */ vm_page_set_dirty(m); + } vm_page_activate(m); vm_page_sunbusy(m);