xref: /freebsd/share/man/man9/proc_rwmem.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1*09f206ecSMark Johnston.\"
2*09f206ecSMark Johnston.\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
3*09f206ecSMark Johnston.\"
4*09f206ecSMark Johnston.\" Redistribution and use in source and binary forms, with or without
5*09f206ecSMark Johnston.\" modification, are permitted provided that the following conditions
6*09f206ecSMark Johnston.\" are met:
7*09f206ecSMark Johnston.\" 1. Redistributions of source code must retain the above copyright
8*09f206ecSMark Johnston.\"    notice, this list of conditions and the following disclaimer.
9*09f206ecSMark Johnston.\" 2. Redistributions in binary form must reproduce the above copyright
10*09f206ecSMark Johnston.\"    notice, this list of conditions and the following disclaimer in the
11*09f206ecSMark Johnston.\"    documentation and/or other materials provided with the distribution.
12*09f206ecSMark Johnston.\"
13*09f206ecSMark Johnston.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
14*09f206ecSMark Johnston.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15*09f206ecSMark Johnston.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16*09f206ecSMark Johnston.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
17*09f206ecSMark Johnston.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18*09f206ecSMark Johnston.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19*09f206ecSMark Johnston.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20*09f206ecSMark Johnston.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21*09f206ecSMark Johnston.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22*09f206ecSMark Johnston.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*09f206ecSMark Johnston.\"
24*09f206ecSMark Johnston.Dd December 7, 2015
25*09f206ecSMark Johnston.Dt PROC_RWMEM 9
26*09f206ecSMark Johnston.Os
27*09f206ecSMark Johnston.Sh NAME
28*09f206ecSMark Johnston.Nm proc_rwmem ,
29*09f206ecSMark Johnston.Nm proc_readmem ,
30*09f206ecSMark Johnston.Nm proc_writemem
31*09f206ecSMark Johnston.Nd read from or write to a process address space
32*09f206ecSMark Johnston.Sh SYNOPSIS
33*09f206ecSMark Johnston.In sys/types.h
34*09f206ecSMark Johnston.In sys/ptrace.h
35*09f206ecSMark Johnston.Ft int
36*09f206ecSMark Johnston.Fn proc_rwmem "struct proc *p" "struct uio *uio"
37*09f206ecSMark Johnston.Ft ssize_t
38*09f206ecSMark Johnston.Fn proc_readmem "struct thread *td" "struct proc *p" "vm_offset_t va" "void *buf" "size_t len"
39*09f206ecSMark Johnston.Ft ssize_t
40*09f206ecSMark Johnston.Fn proc_writemem "struct thread *td" "struct proc *p" "vm_offset_t va" "void *buf" "size_t len"
41*09f206ecSMark Johnston.Sh DESCRIPTION
42*09f206ecSMark JohnstonThese functions are used to read to or write from the address space of the
43*09f206ecSMark Johnstonprocess
44*09f206ecSMark Johnston.Fa p .
45*09f206ecSMark JohnstonThe
46*09f206ecSMark Johnston.Fn proc_rwmem
47*09f206ecSMark Johnstonfunction requires the caller to specify the I/O parameters using a
48*09f206ecSMark Johnston.Vt "struct uio" ,
49*09f206ecSMark Johnstondescribed in
50*09f206ecSMark Johnston.Xr uio 9 .
51*09f206ecSMark JohnstonThe
52*09f206ecSMark Johnston.Fn proc_readmem
53*09f206ecSMark Johnstonand
54*09f206ecSMark Johnston.Fn proc_writemem
55*09f206ecSMark Johnstonfunctions provide a simpler, less general interface which allows the caller to
56*09f206ecSMark Johnstonread into or write the kernel buffer
57*09f206ecSMark Johnston.Fa buf
58*09f206ecSMark Johnstonof size
59*09f206ecSMark Johnston.Fa len
60*09f206ecSMark Johnstonfrom or to the memory at offset
61*09f206ecSMark Johnston.Fa va
62*09f206ecSMark Johnstonin the address space of
63*09f206ecSMark Johnston.Fa p .
64*09f206ecSMark JohnstonThe operation is performed on behalf of thread
65*09f206ecSMark Johnston.Fa td ,
66*09f206ecSMark Johnstonwhich will most often be the current thread.
67*09f206ecSMark Johnston.Pp
68*09f206ecSMark JohnstonThese functions may sleep and thus may not be called with any non-sleepable
69*09f206ecSMark Johnstonlocks held.
70*09f206ecSMark JohnstonThe process
71*09f206ecSMark Johnston.Fa p
72*09f206ecSMark Johnstonmust be held by the caller using
73*09f206ecSMark Johnston.Xr PHOLD 9 .
74*09f206ecSMark Johnston.Sh RETURN VALUES
75*09f206ecSMark JohnstonThe
76*09f206ecSMark Johnston.Fn proc_rwmem
77*09f206ecSMark Johnstonfunction returns
78*09f206ecSMark Johnston.Dv 0
79*09f206ecSMark Johnstonon success.
80*09f206ecSMark Johnston.Dv EFAULT
81*09f206ecSMark Johnstonis returned if the specified user address is invalid, and
82*09f206ecSMark Johnston.Dv ENOMEM
83*09f206ecSMark Johnstonis returned if the target pages could not be faulted in due to a resource
84*09f206ecSMark Johnstonshortage.
85*09f206ecSMark Johnston.Pp
86*09f206ecSMark JohnstonThe
87*09f206ecSMark Johnston.Fn proc_readmem
88*09f206ecSMark Johnstonand
89*09f206ecSMark Johnston.Fn proc_writemem
90*09f206ecSMark Johnstonfunctions return the number of bytes read or written, respectively.
91*09f206ecSMark JohnstonThis may be smaller than the number of bytes requested, for example if the
92*09f206ecSMark Johnstonrequest spans multiple pages in the process address space and one of them after
93*09f206ecSMark Johnstonthe first is not mapped.
94*09f206ecSMark JohnstonOtherwise, -1 is returned.
95*09f206ecSMark Johnston.Sh SEE ALSO
96*09f206ecSMark Johnston.Xr copyin 9 ,
97*09f206ecSMark Johnston.Xr locking 9 ,
98*09f206ecSMark Johnston.Xr PHOLD 9 ,
99*09f206ecSMark Johnston.Xr uio 9
100*09f206ecSMark Johnston.Sh AUTHORS
101*09f206ecSMark JohnstonThis manual page was written by
102*09f206ecSMark Johnston.An Mark Johnston Aq Mt markj@FreeBSD.org .
103