freebsd-nq/sys/security/audit
Attilio Rao 6aba400a70 Fix a deficiency in the selinfo interface:
If a selinfo object is recorded (via selrecord()) and then it is
quickly destroyed, with the waiters missing the opportunity to awake,
at the next iteration they will find the selinfo object destroyed,
causing a PF#.

That happens because the selinfo interface has no way to drain the
waiters before to destroy the registered selinfo object. Also this
race is quite rare to get in practice, because it would require a
selrecord(), a poll request by another thread and a quick destruction
of the selrecord()'ed selinfo object.

Fix this by adding the seldrain() routine which should be called
before to destroy the selinfo objects (in order to avoid such case),
and fix the present cases where it might have already been called.
Sometimes, the context is safe enough to prevent this type of race,
like it happens in device drivers which installs selinfo objects on
poll callbacks. There, the destruction of the selinfo object happens
at driver detach time, when all the filedescriptors should be already
closed, thus there cannot be a race.
For this case, mfi(4) device driver can be set as an example, as it
implements a full correct logic for preventing this from happening.

Sponsored by:	Sandvine Incorporated
Reported by:	rstone
Tested by:	pluknet
Reviewed by:	jhb, kib
Approved by:	re (bz)
MFC after:	3 weeks
2011-08-25 15:51:54 +00:00
..
audit_arg.c Second-to-last commit implementing Capsicum capabilities in the FreeBSD 2011-08-11 12:30:23 +00:00
audit_bsm_domain.c Merge OpenBSM 1.1 changes to the FreeBSD 8.x kernel: 2009-04-19 14:53:17 +00:00
audit_bsm_errno.c Add ECAPMODE, "Not permitted in capability mode", a new kernel errno 2011-03-01 13:14:28 +00:00
audit_bsm_fcntl.c Merge OpenBSM 1.1 changes to the FreeBSD 8.x kernel: 2009-04-19 14:53:17 +00:00
audit_bsm_klib.c Replace sbuf_overflowed() with sbuf_error(), which returns any error 2010-09-10 16:42:16 +00:00
audit_bsm_socket_type.c
audit_bsm_token.c Having thrown the cat out of the house, add a necessary include. 2009-09-08 13:24:36 +00:00
audit_bsm.c Provide ability to audit cap_rights_t arguments. 2011-07-18 12:58:18 +00:00
audit_ioctl.h
audit_pipe.c Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
audit_private.h Provide ability to audit cap_rights_t arguments. 2011-07-18 12:58:18 +00:00
audit_syscalls.c Replace AUDIT_ARG() with variable argument macros with a set more more 2009-06-27 13:58:44 +00:00
audit_trigger.c
audit_worker.c Remove the thread argument from the FSD (File-System Dependent) parts of 2009-05-11 15:33:26 +00:00
audit.c Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/ 2011-02-25 10:11:01 +00:00
audit.h Provide ability to audit cap_rights_t arguments. 2011-07-18 12:58:18 +00:00