initializes the userspace AVC and must be called before any other AVC operation can be performed. A non-NULL
.Imsgprefix
will be prepended to all audit messages produced by the userspace AVC. The default is `uavc'. The remaining arguments, if non-NULL, specify callbacks to be used by the userspace AVC.
The purpose of this functionality is to allow the userspace AVC to be smoothly integrated into existing userspace object managers.
Use an
.Bavc_memory_callback
structure to specify alternate functions for dynamic memory allocation.
.RS
.ta4n10n24n
.nf
struct avc_memory_callback {
void *(*func_malloc)(size_t size);
void (*func_free)(void *ptr);
};
.fi
.ta
.RE
The two fields of the structure should be pointers to functions which behave as
.BRmalloc(3)
and
.BRfree(3),
which are used by default.
Use an
.Bavc_log_callback
structure to specify alternate functions for logging.
.RS
.ta4n10n24n
.nf
struct avc_log_callback {
void (*func_log)(const char *fmt, ...);
void (*func_audit)(void *auditdata,
security_class_t class,
char *msgbuf, size_t msgbufsize);
};
.fi
.ta
.RE
The
.Bfunc_log
callback should accept a
.BRprintf(3)
style format and arguments and log them as desired. The default behavior prints the message on the standard error. The
.Bfunc_audit
callback should interpret the
.Iauditdata
parameter for the given
.IRclass,
printing a human-readable interpretation to
.Imsgbuf
using no more than
.Imsgbufsize
characters. The default behavior is to ignore
.IRauditdata.
Use an
.Bavc_thread_callback
structure to specify functions for starting and manipulating threads.
.RS
.ta4n10n24n
.nf
struct avc_thread_callback {
void *(*func_create_thread)(void (*run)(void));
void (*func_stop_thread)(void *thread);
};
.fi
.ta
.RE
The
.Bfunc_create_thread
callback should create a new thread and return a pointer which references it. The thread should execute the
.Irun
argument, which does not return under normal conditions. The
.Bfunc_stop_thread
callback should cancel the running thread referenced by
.IRthread.
By default, threading is not used; see
.BNETLINKNOTIFICATION
below.
Use an
.Bavc_lock_callback
structure to specify functions to create, obtain, and release locks for use by threads.
.RS
.ta4n10n24n
.nf
struct avc_lock_callback {
void *(*func_alloc_lock)(void);
void (*func_get_lock)(void *lock);
void (*func_release_lock)(void *lock);
void (*func_free_lock)(void *lock);
};
.fi
.ta
.RE
The
.Bfunc_alloc_lock
callback should create a new lock, returning a pointer which references it. The
.Bfunc_get_lock
callback should obtain
.IRlock,
blocking if necessary. The
.Bfunc_release_lock
callback should release
.IRlock.
The
.Bfunc_free_lock
callback should destroy
.IRlock,
freeing any resources associated with it. The default behavior is not to perform any locking. Note that undefined behavior may result if threading is used without appropriate locking.
Beginning with version 2.6.4, the Linux kernel supports SELinux status change notification via netlink. Two message types are currently implemented, indicating changes to the enforcing mode and to the loaded policy in the kernel, respectively. The userspace AVC listens for these messages and takes the appropriate action, modifying the behavior of
.BRavc_has_perm(3)
to reflect the current enforcing mode and flushing the cache on receipt of a policy load notification. Audit messages are produced when netlink notifications are processed.
In the default single-threaded mode, the userspace AVC checks for new netlink messages at the start of each permission query. If threading and locking callbacks are passed to
however, a dedicated thread will be started to listen on the netlink socket. This may increase performance and will ensure that log messages are generated immediately rather than at the time of the next permission query.
currently has a length limit of 15 characters and will be truncated if necessary.
If a provided
.Bfunc_malloc
callback does not set
.Ierrno
appropriately on error, userspace AVC calls may exhibit the
same behavior.
If a netlink thread has been created and an error occurs on the socket (such as an access error), the thread may terminate and cause the userspace AVC to return