freebsd-skq/sys
ken 1abc90f894 Fix a bug in the device pager code that can trigger an assertion
in devfs if a particular race condition is hit in the device pager
code.

This was a side effect of change 227530 which changed the device
pager interface to call a new destructor routine for the cdev.
That destructor routine, old_dev_pager_dtor(), takes a VM object
handle.

The object handle is cast to a struct cdev *, and passed into
dev_rel().

That works in most cases, except the case in cdev_pager_allocate()
where there is a race condition between two threads allocating an
object backed by the same device.  The loser of the race
deallocates its object at the end of the function.

The problem is that before inserting the object into the
dev_pager_object_list, the object's handle is changed from the
struct cdev pointer to the object's own address.  This is to avoid
conflicts with the winner of the race, which already inserted an
object in the list with a handle that is a pointer to the same cdev
structure.

The object is then passed to vm_object_deallocate(), and eventually
makes its way down to old_dev_pager_dtor().  That function passes
the handle pointer (which is actually a VM object, not a struct
cdev as usual) into dev_rel().  dev_rel() decrements the reference
count in the assumed struct cdev (which happens to be 0), and
that triggers the assertion in dev_rel() that the reference count
is greater than or equal to 0.

The fix is to add a cdev pointer to the VM object, and use that
pointer when calling the cdev_pg_dtor() routine.

vm_object.h:	Add a struct cdev pointer to the VM object
		structure.

device_pager.c:	In cdev_pager_allocate(), populate the new cdev
		pointer.

		In dev_pager_dealloc(), use the new cdev pointer
		when calling the object's cdev_pg_dtor() routine.

Reviewed by:	kib
Sponsored by:	Spectra Logic Corporation
MFC after:	1 week
2013-01-09 16:48:38 +00:00
..
amd64 Add a "pause" to busy wait loops in the cpu reset path. 2013-01-09 02:11:16 +00:00
arm Define IPI_IRQ_START and IPI_IRQ_END. 2013-01-09 01:54:17 +00:00
boot Bring in some userboot changes from the bhyve branch to reduce diffs. 2013-01-08 03:27:37 +00:00
bsm
cam Make SES driver to not fall out on some errors in Additional Status page. 2012-12-20 19:51:32 +00:00
cddl zfs: solaris doesn't have KM_ZERO, kmem_zalloc should be used instead 2012-12-23 19:58:41 +00:00
compat
conf Add basic support for the Ubiquiti EdgeRouter Lite. 2013-01-02 23:17:50 +00:00
contrib Use the right USB clock type on the EdgeRouter Lite. This fixes USB. 2013-01-02 23:29:54 +00:00
crypto
ddb
dev Fix format size. 2013-01-08 22:42:15 +00:00
fs Add support for IO_APPEND flag in fuse 2013-01-08 12:21:50 +00:00
gdb
geom Reset provider-specific fields when resending I/O request in low memory 2012-12-26 20:07:47 +00:00
gnu/fs
i386 Enable the UFS quotas for big-iron GENERIC kernels. 2013-01-03 19:03:41 +00:00
ia64 Remove firewire devices missed in r244992. 2013-01-04 15:29:50 +00:00
isa
kern lockmgr: unlock interlock (if requested) when dealing with upgrade/downgrade 2013-01-06 21:47:59 +00:00
kgssapi Piete.Brooks at cl.cam.ac.uk reported via email a crash which was 2012-12-18 00:25:48 +00:00
libkern
mips Mips Atheros AR71XX: make PCI base slot configurable through hints. 2013-01-06 20:50:31 +00:00
modules Link if_ath_spectral.c into the build. 2013-01-02 04:00:54 +00:00
net - Add dashes before copyright notices. 2013-01-07 19:36:11 +00:00
net80211 Add in the missing radiotap definitions from the sipsolutions.net 2013-01-08 06:59:21 +00:00
netatalk
netgraph Use DEVMETHOD_END, as suggested by hselasky@. 2012-12-26 19:14:21 +00:00
netinet Temporarily revert rev 244678. This is causing loopback problems with 2013-01-03 10:21:28 +00:00
netinet6 The in6_setscope() function determines the scope zone id of an address 2013-01-09 00:36:06 +00:00
netipsec
netipx
netnatm
netncp
netpfil In netpfil/pf: 2012-12-28 09:19:49 +00:00
netsmb
nfs
nfsclient
nfsserver
nlm
ofed
opencrypto
pc98 MFi386: r232521 2013-01-04 09:52:09 +00:00
pci
powerpc Enable the UFS quotas for big-iron GENERIC kernels. 2013-01-03 19:03:41 +00:00
rpc
security
sparc64 Revert bogus part of r241740. 2013-01-03 23:12:08 +00:00
sys Change function argument type instead of casting. 2013-01-09 09:29:22 +00:00
teken
tools Fix build on ARM (and probably other platforms) 2012-12-28 06:52:53 +00:00
ufs The process_deferred_inactive() function locks the vnodes of the ufs 2013-01-01 16:14:48 +00:00
vm Fix a bug in the device pager code that can trigger an assertion 2013-01-09 16:48:38 +00:00
x86 Add macros required to enable VMX operation on Intel processors. 2013-01-05 04:20:14 +00:00
xdr
xen
Makefile