1/*-
2 * Copyright (c) 1994, Sean Eric Fagan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 16 unchanged lines hidden (view full) ---
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/sys_process.c 253953 2013-08-05 08:55:35Z attilio $");
34
35#include "opt_compat.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/lock.h>
40#include <sys/mutex.h>
41#include <sys/syscallsubr.h>
--- 216 unchanged lines hidden (view full) ---
258 /*
259 * If we are writing, then we request vm_fault() to create a private
260 * copy of each page. Since these copies will not be writeable by the
261 * process, we must explicity request that they be dirtied.
262 */
263 writing = uio->uio_rw == UIO_WRITE;
264 reqprot = writing ? VM_PROT_COPY | VM_PROT_READ : VM_PROT_READ;
265 fault_flags = writing ? VM_FAULT_DIRTY : VM_FAULT_NORMAL;
266
267 /*
268 * Only map in one page at a time. We don't have to, but it
269 * makes things easier. This way is trivial - right?
270 */
271 do {
272 vm_offset_t uva;
273 u_int len;
--- 8 unchanged lines hidden (view full) ---
282 page_offset = uva - pageno;
283
284 /*
285 * How many bytes to copy
286 */
287 len = min(PAGE_SIZE - page_offset, uio->uio_resid);
288
289 /*
290 * Fault and hold the page on behalf of the process.
291 */
292 error = vm_fault_hold(map, pageno, reqprot, fault_flags, &m);
293 if (error != KERN_SUCCESS) {
294 if (error == KERN_RESOURCE_SHORTAGE)
295 error = ENOMEM;
296 else
297 error = EFAULT;
298 break;
299 }
300
--- 9 unchanged lines hidden (view full) ---
310 PAGE_SIZE, VM_PROT_EXECUTE))
311 vm_sync_icache(map, uva, len);
312 vm_map_unlock_read(map);
313 }
314
315 /*
316 * Release the page.
317 */
318 vm_page_lock(m);
319 vm_page_unhold(m);
320 vm_page_unlock(m);
321
322 } while (error == 0 && uio->uio_resid > 0);
323
324 return (error);
325}
326
327static int
328ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
--- 914 unchanged lines hidden ---
2 * Copyright (c) 1994, Sean Eric Fagan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 16 unchanged lines hidden (view full) ---
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/sys_process.c 253953 2013-08-05 08:55:35Z attilio $");
34
35#include "opt_compat.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/lock.h>
40#include <sys/mutex.h>
41#include <sys/syscallsubr.h>
--- 216 unchanged lines hidden (view full) ---
258 /*
259 * If we are writing, then we request vm_fault() to create a private
260 * copy of each page. Since these copies will not be writeable by the
261 * process, we must explicity request that they be dirtied.
262 */
263 writing = uio->uio_rw == UIO_WRITE;
264 reqprot = writing ? VM_PROT_COPY | VM_PROT_READ : VM_PROT_READ;
265 fault_flags = writing ? VM_FAULT_DIRTY : VM_FAULT_NORMAL;
266
267 /*
268 * Only map in one page at a time. We don't have to, but it
269 * makes things easier. This way is trivial - right?
270 */
271 do {
272 vm_offset_t uva;
273 u_int len;
--- 8 unchanged lines hidden (view full) ---
282 page_offset = uva - pageno;
283
284 /*
285 * How many bytes to copy
286 */
287 len = min(PAGE_SIZE - page_offset, uio->uio_resid);
288
289 /*
290 * Fault and hold the page on behalf of the process.
291 */
292 error = vm_fault_hold(map, pageno, reqprot, fault_flags, &m);
293 if (error != KERN_SUCCESS) {
294 if (error == KERN_RESOURCE_SHORTAGE)
295 error = ENOMEM;
296 else
297 error = EFAULT;
298 break;
299 }
300
--- 9 unchanged lines hidden (view full) ---
310 PAGE_SIZE, VM_PROT_EXECUTE))
311 vm_sync_icache(map, uva, len);
312 vm_map_unlock_read(map);
313 }
314
315 /*
316 * Release the page.
317 */
318 vm_page_lock(m);
319 vm_page_unhold(m);
320 vm_page_unlock(m);
321
322 } while (error == 0 && uio->uio_resid > 0);
323
324 return (error);
325}
326
327static int
328ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
--- 914 unchanged lines hidden ---