diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-08-14 05:46:07 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-08-14 14:35:38 +0000 |
| commit | 1a71d24ecd0dbaf61fd2a44166e9be07c328b198 (patch) | |
| tree | 7e281a0f2668be1f71b8f47c3b67e7ca1ab4948b | |
| parent | f6000e9dd934db9fefc31eaa07a7d8fa9277484e (diff) | |
kern/sys_process.c: make vmspace_rwmem() similar to io functions
In particular, if there were any bytes moved, and then vm_fault()
faulted, do not return an error, but report the short io instead.
PR: 297512
Reviewed by: markj
Tested by: Stéphane D'Alu <sdalu@sdalu.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58838
| -rw-r--r-- | sys/kern/sys_process.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 73e6b64e900b..46848ca150c0 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -451,6 +451,7 @@ vmspace_rwmem(struct vmspace *vm, struct uio *uio) vm_map_t map; vm_offset_t pageno; /* page number */ vm_prot_t reqprot; + ssize_t orig_resid; int error, fault_flags, page_offset, writing; map = &vm->vm_map; @@ -464,10 +465,12 @@ vmspace_rwmem(struct vmspace *vm, struct uio *uio) reqprot = writing ? VM_PROT_COPY | VM_PROT_READ : VM_PROT_READ; fault_flags = writing ? VM_FAULT_DIRTY : VM_FAULT_NORMAL; + orig_resid = uio->uio_resid; + if (writing) { error = priv_check(curthread, PRIV_PROC_MEM_WRITE); if (error != 0) - goto out; + return (error); } /* @@ -524,9 +527,7 @@ vmspace_rwmem(struct vmspace *vm, struct uio *uio) vm_page_unwire(m, PQ_ACTIVE); } while (error == 0 && uio->uio_resid > 0); - -out: - return (error); + return (uio->uio_resid == orig_resid ? error : 0); } int |
