1avc_add_callback(3) SELinux API documentation avc_add_callback(3)
2
3
4
6 avc_add_callback - additional event notification for SELinux userspace
7 object managers
8
10 #include <selinux/selinux.h>
11 #include <selinux/avc.h>
12
13 int avc_add_callback(int (*callback)(uint32_t event,
14 security_id_t ssid,
15 security_id_t tsid,
16 security_class_t tclass,
17 access_vector_t perms,
18 access_vector_t *out_retained),
19 uint32_t events, security_id_t ssid,
20 security_id_t tsid, security_class_t tclass,
21 access_vector_t perms);
22
24 avc_add_callback() is used to register callback functions on security
25 events. The purpose of this functionality is to allow userspace object
26 managers to take additional action when a policy change, usually a pol‐
27 icy reload, causes permissions to be granted or revoked.
28
29 events is the bitwise-or of security events on which to register the
30 callback; see SECURITY EVENTS below.
31
32 ssid, tsid, tclass, and perms specify the source and target SID's, tar‐
33 get class, and specific permissions that the callback wishes to moni‐
34 tor. The special symbol SECSID_WILD may be passed as the source or
35 target and will cause any SID to match.
36
37 callback is the callback function provided by the userspace object man‐
38 ager. The event argument indicates the security event which occurred;
39 the remaining arguments are interpreted according to the event as
40 described below. The return value of the callback should be zero on
41 success, -1 on error with errno set appropriately (but see RETURN VALUE
42 below).
43
45 In all cases below, ssid and/or tsid may be set to SECSID_WILD, indi‐
46 cating that the change applies to all source and/or target SID's.
47 Unless otherwise indicated, the out_retained parameter is unused.
48
49 AVC_CALLBACK_GRANT
50 Previously denied permissions are now granted for ssid, tsid
51 with respect to tclass. perms indicates the permissions to
52 grant.
53
54 AVC_CALLBACK_TRY_REVOKE
55 Previously granted permissions are now conditionally revoked for
56 ssid, tsid with respect to tclass. perms indicates the permis‐
57 sions to revoke. The callback should set out_retained to the
58 subset of perms which are retained as migrated permissions.
59 Note that out_retained is ignored if the callback returns -1.
60
61 AVC_CALLBACK_REVOKE
62 Previously granted permissions are now unconditionally revoked
63 for ssid, tsid with respect to tclass. perms indicates the per‐
64 missions to revoke.
65
66 AVC_CALLBACK_RESET
67 Indicates that the cache was flushed. The SID, class, and per‐
68 mission arguments are unused and are set to NULL.
69
70 AVC_CALLBACK_AUDITALLOW_ENABLE
71 The permissions given by perms should now be audited when
72 granted for ssid, tsid with respect to tclass.
73
74 AVC_CALLBACK_AUDITALLOW_DISABLE
75 The permissions given by perms should no longer be audited when
76 granted for ssid, tsid with respect to tclass.
77
78 AVC_CALLBACK_AUDITDENY_ENABLE
79 The permissions given by perms should now be audited when denied
80 for ssid, tsid with respect to tclass.
81
82 AVC_CALLBACK_AUDITDENY_DISABLE
83 The permissions given by perms should no longer be audited when
84 denied for ssid, tsid with respect to tclass.
85
87 On success, avc_add_callback() returns zero. On error, -1 is returned
88 and errno is set appropriately.
89
90 A return value of -1 from a callback is interpreted as a failed policy
91 operation. If such a return value is encountered, all remaining call‐
92 backs registered on the event are called. In threaded mode, the
93 netlink handler thread may then terminate and cause the userspace AVC
94 to return EINVAL on all further permission checks until avc_destroy(3)
95 is called. In non-threaded mode, the permission check on which the
96 error occurred will return -1 and the value of errno encountered to the
97 caller. In both cases, a log message is produced and the kernel may be
98 notified of the error.
99
101 ENOMEM An attempt to allocate memory failed.
102
104 If the userspace AVC is running in threaded mode, callbacks registered
105 via avc_add_callback() may be executed in the context of the netlink
106 handler thread. This will likely introduce synchronization issues
107 requiring the use of locks. See avc_init(3).
108
109 Support for dynamic revocation and retained permissions is mostly unim‐
110 plemented in the SELinux kernel module. The only security event that
111 currently gets exercised is AVC_CALLBACK_RESET.
112
114 Eamon Walsh <ewalsh@tycho.nsa.gov>
115
117 avc_init(3), avc_has_perm(3), avc_context_to_sid(3),
118 avc_cache_stats(3), security_compute_av(3) selinux(8)
119
120
121
122 9 June 2004 avc_add_callback(3)