xref: /illumos-gate/usr/src/man/man3proc/pr_ioctl.3proc (revision a7d7cafedfa26f9e421bbcaf42b7387ef67c0a31)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd November 27, 2023
15.Dt PR_IOCTL 3PROC
16.Os
17.Sh NAME
18.Nm pr_ioctl
19.Nd inject ioctl system call into victim process
20.Sh LIBRARY
21.Lb libproc
22.Sh SYNOPSIS
23.In libproc.h
24.Ft int
25.Fo pr_ioctl
26.Fa "struct ps_prochandle *P"
27.Fa "int fd"
28.Fa "int code"
29.Fa "void *buf"
30.Fa "size_t size"
31.Fc
32.Sh DESCRIPTION
33The
34.Fn pr_ioctl
35function injects the
36.Xr ioctl 2
37system call into the target process
38.Fa P
39by means of the agent LWP.
40If the process handle
41.Fa P
42is the value
43.Dv NULL
44then this will be equivalent to calling
45.Xr ioctl 2
46on the currently running process.
47.Pp
48The arguments
49.Fa fd ,
50.Fa code ,
51and
52.Fa buf
53have the same meaning as in
54.Xr ioctl 2 .
55See
56.Xr ioctl 2
57for the full description and purpose of the
58.Sy ioctl
59system call and its arguments.
60.Pp
61Unlike the traditional
62.Xr ioctl 2
63system call, the
64.Fn pr_ioctl
65function needs to know the maximum size of the buffer
66.Fa buf
67such that it can be properly injected into the address space of the
68target process.
69.Pp
70The
71.Fn pr_ioctl
72function only works on active processes.
73Process handles that correspond to core files, zombie processes, or ELF objects
74do not support system call injection.
75.Sh RETURN VALUES
76Upon successful completion, the
77.Fn pr_ioctl
78function's return value is that described in
79.Xr ioctl 2 .
80Otherwise,
81.Sy -1
82is returned and
83.Sy errno
84is set to
85.Er ENOSYS
86to indicate that the system call could not be injected.
87.Sh ERRORS
88For the full list of errors see the
89.Sy ERRORS
90section in
91.Xr ioctl 2 .
92.Pp
93The
94.Fn pr_ioctl
95function will fail if:
96.Bl -tag -width Er
97.It Er ENOSYS
98An error occurred while trying to invoke the agent LWP and inject a
99system call in the process handle
100.Fa P
101or the process handle
102.Fa P
103does not support system call injection.
104.El
105.Sh INTERFACE STABILITY
106.Sy Uncommitted
107.Sh MT-LEVEL
108See
109.Sy LOCKING
110in
111.Xr libproc 3LIB .
112.Sh SEE ALSO
113.Xr ioctl 2 ,
114.Xr libproc 3LIB ,
115.Xr proc 5
116