freebsd-dev/sys
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
..
amd64 In HEAD when doing no further checkes there is no reason use the 2011-08-20 19:21:46 +00:00
arm - Move the PG_UNMANAGED flag from m->flags to m->oflags, renaming the flag 2011-08-09 21:01:36 +00:00
boot Add kern.cam.boot_delay description (with reasonable default) to 2011-08-23 20:25:11 +00:00
bsm Add ECAPMODE, "Not permitted in capability mode", a new kernel errno 2011-03-01 13:14:28 +00:00
cam Fixes for sure bus reference miscounting and potential device and 2011-08-12 20:09:38 +00:00
cddl Generalize ffs_pages_remove() into vn_pages_remove(). 2011-08-25 08:17:39 +00:00
compat Add experimental support for process descriptors 2011-08-18 22:51:30 +00:00
conf Add experimental support for process descriptors 2011-08-18 22:51:30 +00:00
contrib Use the correct byte order for the ip_divert(4) mbuf tag port meta 2011-08-25 09:38:33 +00:00
crypto Fix a bug in the result of manual assembly. 2011-03-02 14:56:58 +00:00
ddb Fix making kernel dumps from the debugger by creating a command 2011-06-07 01:28:12 +00:00
dev Fix a missing initialisation of bt_flags when setting up the TDMA beacon. 2011-08-24 14:11:00 +00:00
fs Fix the NFSv4 server so that it returns NFSERR_SYMLINK when 2011-08-20 21:26:35 +00:00
gdb Modify kdb_trap() so that it re-calls the dbbe_trap function as long as 2011-02-18 22:25:11 +00:00
geom Add some spare fields to the g_class and g_geom structures needed to implement 2011-07-17 20:35:30 +00:00
gnu Second-to-last commit implementing Capsicum capabilities in the FreeBSD 2011-08-11 12:30:23 +00:00
i386 In HEAD when doing no further checkes there is no reason use the 2011-08-20 19:21:46 +00:00
ia64 - Move the PG_UNMANAGED flag from m->flags to m->oflags, renaming the flag 2011-08-09 21:01:36 +00:00
isa Move VT switching hack for suspend/resume from bus drivers to syscons.c 2011-05-09 18:46:49 +00:00
kern Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
kgssapi Add a small comment about unloading the kgsappi module. 2011-07-16 08:05:49 +00:00
libkern Fix typos - remove duplicate "is". 2011-02-23 09:22:33 +00:00
mips Fix a typo in cb_dumpdata() about wrongly calling wdog_kern_pat(). 2011-08-13 17:17:04 +00:00
modules Fix two cases involving opt_capsicum.h and module builds: 2011-08-15 07:32:44 +00:00
net Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
net80211 This patch fixes beacon frame sequence number generation. The code 2011-08-24 08:53:33 +00:00
netatalk
netgraph Second-to-last commit implementing Capsicum capabilities in the FreeBSD 2011-08-11 12:30:23 +00:00
netinet Increase the defaults for the maximum socket buffer limit, 2011-08-25 09:20:13 +00:00
netinet6 Fix if_addr_mtx recursion in mld6. 2011-08-22 23:39:40 +00:00
netipsec Update packet filter (pf) code to OpenBSD 4.5. 2011-06-28 11:57:25 +00:00
netipx
netnatm
netncp
netsmb Change some variables from int to size_t. This is more accurate since 2011-01-08 23:06:54 +00:00
nfs Set proper root device name when legacy NFS client is compiled into kernel. 2011-06-29 15:17:29 +00:00
nfsclient Merge 220876, 220877, and 221537 from the new NFS client to the old: 2011-08-09 15:29:58 +00:00
nfsserver Second-to-last commit implementing Capsicum capabilities in the FreeBSD 2011-08-11 12:30:23 +00:00
nlm Add a lock flags argument to the VFS_FHTOVP() file system 2011-05-22 01:07:54 +00:00
ofed Add the fo_chown and fo_chmod methods to struct fileops and use them 2011-08-16 20:07:47 +00:00
opencrypto Add the fo_chown and fo_chmod methods to struct fileops and use them 2011-08-16 20:07:47 +00:00
pc98 In HEAD when doing no further checkes there is no reason use the 2011-08-20 19:21:46 +00:00
pci Add new device id of D-Link DGE-530T Rev. C controller. DGE-503T 2011-07-30 01:06:12 +00:00
powerpc Add support for the Blu-Ray drive found in the Sony Playstation 3 and fix 2011-08-14 00:20:37 +00:00
rpc Fix the kgssapi so that it can be loaded as a module. Currently 2011-06-19 22:08:55 +00:00
security Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
sparc64 - Move the PG_UNMANAGED flag from m->flags to m->oflags, renaming the flag 2011-08-09 21:01:36 +00:00
sys Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
teken Fix various whitespace inconsistencies in sys/teken. 2011-06-26 18:25:10 +00:00
tools GNU awk does not output escaped newlines in multi-line printc statements. This 2011-03-31 21:33:33 +00:00
ufs Generalize ffs_pages_remove() into vn_pages_remove(). 2011-08-25 08:17:39 +00:00
vm Update some comments in swap_pager.c. 2011-08-22 20:44:18 +00:00
x86 Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
xdr
xen Monitor and emit events for XenStore changes to XenBus trees 2011-06-11 04:59:01 +00:00
Makefile Include sys/xen in cscope tag file generation. 2011-06-10 20:51:41 +00:00