Debian Codegraph @

libselinux/man/man3/avc_add_callback.3

raw
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Author: Eamon Walsh ([email protected]) 2004
4 .TH "avc_add_callback" "3" "9 June 2004" "" "SELinux API documentation"
5 .SH "NAME"
6 avc_add_callback \- additional event notification for SELinux userspace object managers
7 .
8 .SH "SYNOPSIS"
9 .B #include <selinux/selinux.h>
10 .br
11 .B #include <selinux/avc.h>
12 .sp
13 .BI "int avc_add_callback(int (*" callback ")(uint32_t " event ,
14 .in +\w'int avc_add_callback(int (*callback)('u
15 .BI "security_id_t " ssid ,
16 .br
17 .BI "security_id_t " tsid ,
18 .br
19 .BI "security_class_t " tclass ,
20 .br
21 .BI "access_vector_t " perms ,
22 .br
23 .BI "access_vector_t *" out_retained "),"
24 .in
25 .in +\w'int avc_add_callback('u
26 .BI "uint32_t " events ", security_id_t " ssid ,
27 .br
28 .BI "security_id_t " tsid ", security_class_t " tclass ,
29 .br
30 .BI "access_vector_t " perms ");"
31 .in
32 .
33 .SH "DESCRIPTION"
34 .BR avc_add_callback ()
35 is used to register callback functions on security events. The purpose of this functionality is to allow userspace object managers to take additional action when a policy change, usually a policy reload, causes permissions to be granted or revoked.
36
37 .I events
38 is the
39 .RI bitwise- or
40 of security events on which to register the callback; see
41 .B SECURITY EVENTS
42 below.
43
44 .IR ssid ,
45 .IR tsid ,
46 .IR tclass ,
47 and
48 .I perms
49 specify the source and target SID's, target class, and specific permissions that the callback wishes to monitor. The special symbol
50 .B SECSID_WILD
51 may be passed as the
52 .I source
53 or
54 .I target
55 and will cause any SID to match.
56
57 .I callback
58 is the callback function provided by the userspace object manager. The
59 .I event
60 argument indicates the security event which occurred; the remaining arguments
61 are interpreted according to the event as described below. The return value
62 of the callback should be zero on success, \-1 on error with
63 .I errno
64 set appropriately (but see
65 .B RETURN VALUE
66 below).
67 .
68 .SH "SECURITY EVENTS"
69 In all cases below,
70 .I ssid
71 and/or
72 .I tsid
73 may be set to
74 .BR SECSID_WILD ,
75 indicating that the change applies to all source and/or target SID's. Unless otherwise indicated, the
76 .I out_retained
77 parameter is unused.
78 .
79 .TP
80 .B AVC_CALLBACK_GRANT
81 Previously denied permissions are now granted for
82 .IR ssid ,
83 .I tsid
84 with respect to
85 .IR tclass .
86 .I perms
87 indicates the permissions to grant.
88 .TP
89 .B AVC_CALLBACK_TRY_REVOKE
90 Previously granted permissions are now conditionally revoked for
91 .IR ssid ,
92 .I tsid
93 with respect to
94 .IR tclass .
95 .I perms
96 indicates the permissions to revoke. The callback should set
97 .I out_retained
98 to the subset of
99 .I perms
100 which are retained as migrated permissions. Note that
101 .I out_retained
102 is ignored if the callback returns \-1.
103 .TP
104 .B AVC_CALLBACK_REVOKE
105 Previously granted permissions are now unconditionally revoked for
106 .IR ssid ,
107 .I tsid
108 with respect to
109 .IR tclass .
110 .I perms
111 indicates the permissions to revoke.
112 .TP
113 .B AVC_CALLBACK_RESET
114 Indicates that the cache was flushed. The SID, class, and permission arguments are unused and are set to NULL.
115 .TP
116 .B AVC_CALLBACK_AUDITALLOW_ENABLE
117 The permissions given by
118 .I perms
119 should now be audited when granted for
120 .IR ssid ,
121 .I tsid
122 with respect to
123 .IR tclass .
124 .TP
125 .B AVC_CALLBACK_AUDITALLOW_DISABLE
126 The permissions given by
127 .I perms
128 should no longer be audited when granted for
129 .IR ssid ,
130 .I tsid
131 with respect to
132 .IR tclass .
133 .TP
134 .B AVC_CALLBACK_AUDITDENY_ENABLE
135 The permissions given by
136 .I perms
137 should now be audited when denied for
138 .IR ssid ,
139 .I tsid
140 with respect to
141 .IR tclass .
142 .TP
143 .B AVC_CALLBACK_AUDITDENY_DISABLE
144 The permissions given by
145 .I perms
146 should no longer be audited when denied for
147 .IR ssid ,
148 .I tsid
149 with respect to
150 .IR tclass .
151 .
152 .SH "RETURN VALUE"
153 On success,
154 .BR avc_add_callback ()
155 returns zero. On error, \-1 is returned and
156 .I errno
157 is set appropriately.
158
159 A return value of \-1 from a callback is interpreted as a failed policy operation. If such a return value is encountered, all remaining callbacks registered on the event are called. In threaded mode, the netlink handler thread may then terminate and cause the userspace AVC to return
160 .B EINVAL
161 on all further permission checks until
162 .BR avc_destroy (3)
163 is called. In non-threaded mode, the permission check on which the error occurred will return \-1 and the value of
164 .I errno
165 encountered to the caller. In both cases, a log message is produced and the kernel may be notified of the error.
166 .
167 .SH "ERRORS"
168 .TP
169 .B ENOMEM
170 An attempt to allocate memory failed.
171 .
172 .SH "NOTES"
173 If the userspace AVC is running in threaded mode, callbacks registered via
174 .BR avc_add_callback ()
175 may be executed in the context of the netlink handler thread. This will likely introduce synchronization issues requiring the use of locks. See
176 .BR avc_init (3).
177
178 Support for dynamic revocation and retained permissions is mostly unimplemented in the SELinux kernel module. The only security event that currently gets exercised is
179 .BR AVC_CALLBACK_RESET .
180 .
181 .SH "AUTHOR"
182 Eamon Walsh <[email protected]>
183 .
184 .SH "SEE ALSO"
185 .ad l
186 .nh
187 .BR avc_init (3),
188 .BR avc_has_perm (3),
189 .BR avc_context_to_sid (3),
190 .BR avc_cache_stats (3),
191 .BR security_compute_av (3)
192 .BR selinux (8)