avc_add_callback (3) - Linux Man Pages
avc_add_callback: additional event notification for SELinux userspace object managers
avc_add_callback - additional event notification for SELinux userspace object managers
int avc_add_callback(int (*callback)(uint32_t event,
access_vector_t *out_retained), uint32_t events, security_id_t ssid,
security_id_t tsid, security_class_t tclass,
DESCRIPTIONavc_add_callback() 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.
events is the bitwise-or of security events on which to register the callback; see SECURITY EVENTS below.
ssid, tsid, tclass, and perms specify the source and target SID's, target class, and specific permissions that the callback wishes to monitor. The special symbol SECSID_WILD may be passed as the source or target and will cause any SID to match.
callback is the callback function provided by the userspace object manager. The event argument indicates the security event which occurred; the remaining arguments are interpreted according to the event as described below. The return value of the callback should be zero on success, -1 on error with errno set appropriately (but see RETURN VALUE below).
SECURITY EVENTSIn all cases below, ssid and/or tsid may be set to SECSID_WILD, indicating that the change applies to all source and/or target SID's. Unless otherwise indicated, the out_retained parameter is unused.
- Previously denied permissions are now granted for ssid, tsid with respect to tclass. perms indicates the permissions to grant.
- Previously granted permissions are now conditionally revoked for ssid, tsid with respect to tclass. perms indicates the permissions to revoke. The callback should set out_retained to the subset of perms which are retained as migrated permissions. Note that out_retained is ignored if the callback returns -1.
- Previously granted permissions are now unconditionally revoked for ssid, tsid with respect to tclass. perms indicates the permissions to revoke.
- Indicates that the cache was flushed. The SID, class, and permission arguments are unused and are set to NULL.
- The permissions given by perms should now be audited when granted for ssid, tsid with respect to tclass.
- The permissions given by perms should no longer be audited when granted for ssid, tsid with respect to tclass.
- The permissions given by perms should now be audited when denied for ssid, tsid with respect to tclass.
- The permissions given by perms should no longer be audited when denied for ssid, tsid with respect to tclass.
RETURN VALUEOn success, avc_add_callback() returns zero. On error, -1 is returned and errno is set appropriately.
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 EINVAL on all further permission checks until avc_destroy(3) is called. In non-threaded mode, the permission check on which the error occurred will return -1 and the value of errno encountered to the caller. In both cases, a log message is produced and the kernel may be notified of the error.
- An attempt to allocate memory failed.