xref: /freebsd/share/man/man9/syscall_helper_register.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1*4b69e622SConrad Meyer.\" Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org>
2*4b69e622SConrad Meyer.\" All rights reserved.
3*4b69e622SConrad Meyer.\"
4*4b69e622SConrad Meyer.\" Redistribution and use in source and binary forms, with or without
5*4b69e622SConrad Meyer.\" modification, are permitted provided that the following conditions
6*4b69e622SConrad Meyer.\" are met:
7*4b69e622SConrad Meyer.\" 1. Redistributions of source code must retain the above copyright
8*4b69e622SConrad Meyer.\"    notice, this list of conditions and the following disclaimer.
9*4b69e622SConrad Meyer.\" 2. Redistributions in binary form must reproduce the above copyright
10*4b69e622SConrad Meyer.\"    notice, this list of conditions and the following disclaimer in the
11*4b69e622SConrad Meyer.\"    documentation and/or other materials provided with the distribution.
12*4b69e622SConrad Meyer.\"
13*4b69e622SConrad Meyer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*4b69e622SConrad Meyer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*4b69e622SConrad Meyer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*4b69e622SConrad Meyer.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*4b69e622SConrad Meyer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*4b69e622SConrad Meyer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*4b69e622SConrad Meyer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*4b69e622SConrad Meyer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*4b69e622SConrad Meyer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*4b69e622SConrad Meyer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*4b69e622SConrad Meyer.\" SUCH DAMAGE.
24*4b69e622SConrad Meyer.\"
25*4b69e622SConrad Meyer.Dd February 10, 2018
26*4b69e622SConrad Meyer.Dt SYSCALL_HELPER_REGISTER 9
27*4b69e622SConrad Meyer.Os
28*4b69e622SConrad Meyer.Sh NAME
29*4b69e622SConrad Meyer.Nm syscall_helper_register ,
30*4b69e622SConrad Meyer.Nm syscall_helper_unregister
31*4b69e622SConrad Meyer.Nd kernel syscall registration routines
32*4b69e622SConrad Meyer.\"
33*4b69e622SConrad Meyer.Sh SYNOPSIS
34*4b69e622SConrad Meyer.In sys/sysent.h
35*4b69e622SConrad Meyer.Ft int
36*4b69e622SConrad Meyer.Fn syscall_helper_register "struct syscall_helper_data *sd" "int flags"
37*4b69e622SConrad Meyer.Ft int
38*4b69e622SConrad Meyer.Fn syscall_helper_unregister "struct syscall_helper_data *sd"
39*4b69e622SConrad Meyer.\"
40*4b69e622SConrad Meyer.Ss INITIALIZER MACROS
41*4b69e622SConrad Meyer.Ft struct syscall_helper_data
42*4b69e622SConrad Meyer.Fn SYSCALL_INIT_HELPER "syscallname"
43*4b69e622SConrad Meyer.Ft struct syscall_helper_data
44*4b69e622SConrad Meyer.Fn SYSCALL_INIT_HELPER_F "syscallname" "int flags"
45*4b69e622SConrad Meyer.\"
46*4b69e622SConrad Meyer.Ss COMPATIBILITY INITIALIZER MACROS
47*4b69e622SConrad Meyer.Ft struct syscall_helper_data
48*4b69e622SConrad Meyer.Fn SYSCALL_INIT_HELPER_COMPAT "syscallname"
49*4b69e622SConrad Meyer.Ft struct syscall_helper_data
50*4b69e622SConrad Meyer.Fn SYSCALL_INIT_HELPER_COMPAT_F "syscallname" "int flags"
51*4b69e622SConrad Meyer.\"
52*4b69e622SConrad Meyer.Sh DESCRIPTION
53*4b69e622SConrad MeyerThe
54*4b69e622SConrad Meyer.Fn syscall_helper_register
55*4b69e622SConrad Meyerregisters a system call.
56*4b69e622SConrad MeyerThis function takes the structure
57*4b69e622SConrad Meyer.Va struct syscall_helper_data sd ,
58*4b69e622SConrad Meyerwhich specifies the parameters for syscall registration:
59*4b69e622SConrad Meyer.Pp
60*4b69e622SConrad Meyer.Bd -literal -offset indent -compact
61*4b69e622SConrad Meyerstruct syscall_helper_data {
62*4b69e622SConrad Meyer	struct sysent	new_sysent;
63*4b69e622SConrad Meyer	struct sysent	old_sysent;
64*4b69e622SConrad Meyer	int		syscall_no;
65*4b69e622SConrad Meyer	int		registered;
66*4b69e622SConrad Meyer};
67*4b69e622SConrad Meyer.Ed
68*4b69e622SConrad Meyer.Pp
69*4b69e622SConrad MeyerThe only valid flag for the
70*4b69e622SConrad Meyer.Fa flags
71*4b69e622SConrad Meyerargument to
72*4b69e622SConrad Meyer.Fn syscall_helper_register
73*4b69e622SConrad Meyeris
74*4b69e622SConrad Meyer.Dv SY_THR_STATIC .
75*4b69e622SConrad MeyerThis flag prevents the syscall from being unregistered.
76*4b69e622SConrad Meyer.\"
77*4b69e622SConrad Meyer.Pp
78*4b69e622SConrad MeyerBefore use, the structure must be initialized with one of the
79*4b69e622SConrad Meyer.Fn SYSCALL_INIT_HELPER*
80*4b69e622SConrad Meyermacros.
81*4b69e622SConrad MeyerIn new code, syscall implementation functions shall be named
82*4b69e622SConrad Meyer.Fn sys_syscallname
83*4b69e622SConrad Meyerand the regular macros shall be used.
84*4b69e622SConrad Meyer.Pp
85*4b69e622SConrad MeyerFor legacy syscall functions named without "sys_" prefixes, the "COMPAT"
86*4b69e622SConrad Meyerversions of the macros may be used.
87*4b69e622SConrad Meyer.Pp
88*4b69e622SConrad MeyerThe only valid flag for the
89*4b69e622SConrad Meyer.Fa flags
90*4b69e622SConrad Meyerargument to the "F" variants of the initializer macros is
91*4b69e622SConrad Meyer.Dv SYF_CAPENABLED .
92*4b69e622SConrad MeyerThis flag indicates that the syscall is allowed in capability mode.
93*4b69e622SConrad Meyer.Pp
94*4b69e622SConrad MeyerThe
95*4b69e622SConrad Meyer.Fn syscall_helper_unregister
96*4b69e622SConrad Meyerunregisters a system call.
97*4b69e622SConrad MeyerThis function takes the same structure
98*4b69e622SConrad Meyer.Va struct syscall_helper_data sd
99*4b69e622SConrad Meyerthat was previously initialized in the manner described above and used in a
100*4b69e622SConrad Meyersuccessful invocation of
101*4b69e622SConrad Meyer.Fn syscall_helper_register .
102*4b69e622SConrad Meyer.\"
103*4b69e622SConrad Meyer.Sh RETURN VALUES
104*4b69e622SConrad MeyerIf successful,
105*4b69e622SConrad Meyer.Fn syscall_helper_register
106*4b69e622SConrad Meyerand
107*4b69e622SConrad Meyer.Fn syscall_helper_unregister
108*4b69e622SConrad Meyerwill return 0.
109*4b69e622SConrad MeyerOtherwise, they will return an error.
110*4b69e622SConrad Meyer.\"
111*4b69e622SConrad Meyer.Sh ERRORS
112*4b69e622SConrad MeyerThe
113*4b69e622SConrad Meyer.Fn syscall_helper_register
114*4b69e622SConrad Meyercall will fail and the syscall will not be registered if:
115*4b69e622SConrad Meyer.Bl -tag -width Er
116*4b69e622SConrad Meyer.It Bq Er EINVAL
117*4b69e622SConrad MeyerThe
118*4b69e622SConrad Meyer.Fa flags
119*4b69e622SConrad Meyerargument contained a value other than
120*4b69e622SConrad Meyer.Dv SY_THR_STATIC .
121*4b69e622SConrad Meyer.It Bq Er EINVAL
122*4b69e622SConrad MeyerThe specified syscall number,
123*4b69e622SConrad Meyer.Dv sd.syscall_no
124*4b69e622SConrad Meyer.Dv ( SYS_syscallname ) ,
125*4b69e622SConrad Meyerwas outside of the valid range of system call numbers (zero through
126*4b69e622SConrad Meyer.Dv SYS_MAXSYSCALL ) .
127*4b69e622SConrad Meyer.It Bq Er ENFILE
128*4b69e622SConrad MeyerThe system call table does not have any available slots.
129*4b69e622SConrad Meyer.It Bq Er EEXIST
130*4b69e622SConrad MeyerThe specified syscall number,
131*4b69e622SConrad Meyer.Dv sd.syscall_no
132*4b69e622SConrad Meyer.Dv ( SYS_syscallname ) ,
133*4b69e622SConrad Meyerwas already in use.
134*4b69e622SConrad Meyer.El
135*4b69e622SConrad Meyer.\"
136*4b69e622SConrad Meyer.Sh SEE ALSO
137*4b69e622SConrad Meyer.Xr SYSCALL_MODULE 9
138