kernel-ark/drivers/ieee1394
Stefan Richter 638570b543 ieee1394: raw1394: fix possible deadlock in multithreaded clients
Regression in 2.6.28-rc1:  When I added the new state_mutex which
prevents corruption of raw1394's internal state when accessed by
multithreaded client applications, the following possible though
highly unlikely deadlock slipped in:

Thread A:                  Thread B:
 - acquire mmap_sem         - raw1394_write() or raw1394_ioctl()
 - raw1394_mmap()           - acquire state_mutex
 - acquire state_mutex      - copy_to/from_user(), possible page fault:
                              acquire mmap_sem

The simplest fix is to use mutex_trylock() instead of mutex_lock() in
raw1394_mmap().  This changes the behavior under contention in a way
which is visible to userspace clients.  However, since multithreaded
access was entirely buggy before state_mutex was added and libraw1394's
documentation advised application programmers to use a handle only in a
single thread, this change in behaviour should not be an issue in
practice at all.

Since we have to use mutex_trylock() in raw1394_mmap() regardless
whether /dev/raw1394 was opened with O_NONBLOCK or not, we now use
mutex_trylock() unconditionally everywhere for state_mutex, just to have
consistent behavior.

Reported-by: Johannes Weiner <hannes@saeurebad.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2008-10-31 08:48:26 +01:00
..
config_roms.c
config_roms.h
csr1212.c ieee1394: Use DIV_ROUND_UP 2008-10-15 22:21:07 +02:00
csr1212.h
csr.c
csr.h
dma.c
dma.h
dv1394-private.h
dv1394.c ieee1394: dv1394, video1394: remove unnecessary expressions 2008-10-15 22:21:09 +02:00
dv1394.h
eth1394.c ieee1394: Use DIV_ROUND_UP 2008-10-15 22:21:07 +02:00
eth1394.h
highlevel.c
highlevel.h
hosts.c ieee1394: struct device - replace bus_id with dev_name(), dev_set_name() 2008-10-31 08:48:25 +01:00
hosts.h
ieee1394_core.c
ieee1394_core.h
ieee1394_hotplug.h
ieee1394_transactions.c
ieee1394_transactions.h
ieee1394_types.h
ieee1394-ioctl.h
ieee1394.h
init_ohci1394_dma.c
iso.c
iso.h
Kconfig
Makefile
nodemgr.c ieee1394: struct device - replace bus_id with dev_name(), dev_set_name() 2008-10-31 08:48:25 +01:00
nodemgr.h ieee1394: survive a few seconds connection loss 2008-10-15 22:21:09 +02:00
ohci1394.c
ohci1394.h
pcilynx.c
pcilynx.h
raw1394-private.h ieee1394: raw1394: replace BKL by local mutex, make ioctl() and mmap() thread-safe 2008-10-15 22:21:08 +02:00
raw1394.c ieee1394: raw1394: fix possible deadlock in multithreaded clients 2008-10-31 08:48:26 +01:00
raw1394.h
sbp2.c ieee1394: sbp2: enforce s/g segment size limit 2008-10-15 22:21:07 +02:00
sbp2.h ieee1394: sbp2: enforce s/g segment size limit 2008-10-15 22:21:07 +02:00
video1394.c ieee1394: dv1394, video1394: remove unnecessary expressions 2008-10-15 22:21:09 +02:00
video1394.h