tmp_suning_uos_patched/drivers
Herbert Xu 4b2f0260c7 [PATCH] nbd: fix TX/RX race condition
Janos Haar of First NetCenter Bt.  reported numerous crashes involving the
NBD driver.  With his help, this was tracked down to bogus bio vectors
which in turn was the result of a race condition between the
receive/transmit routines in the NBD driver.

The bug manifests itself like this:

CPU0				CPU1
do_nbd_request
	add req to queuelist
	nbd_send_request
		send req head
		for each bio
			kmap
			send
				nbd_read_stat
					nbd_find_request
					nbd_end_request
			kunmap

When CPU1 finishes nbd_end_request, the request and all its associated
bio's are freed.  So when CPU0 calls kunmap whose argument is derived from
the last bio, it may crash.

Under normal circumstances, the race occurs only on the last bio.  However,
if an error is encountered on the remote NBD server (such as an incorrect
magic number in the request), or if there were a bug in the server, it is
possible for the nbd_end_request to occur any time after the request's
addition to the queuelist.

The following patch fixes this problem by making sure that requests are not
added to the queuelist until after they have been completed transmission.

In order for the receiving side to be ready for responses involving
requests still being transmitted, the patch introduces the concept of the
active request.

When a response matches the current active request, its processing is
delayed until after the tranmission has come to a stop.

This has been tested by Janos and it has been successful in curing this
race condition.

From: Herbert Xu <herbert@gondor.apana.org.au>

  Here is an updated patch which removes the active_req wait in
  nbd_clear_queue and the associated memory barrier.

  I've also clarified this in the comment.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cc: <djani22@dynamicweb.hu>
Cc: Paul Clements <Paul.Clements@SteelEye.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-06 08:33:20 -08:00
..
acorn
acpi [PATCH] driver core: replace "hotplug" by "uevent" 2006-01-04 16:18:08 -08:00
atm [PATCH] drivers/atm/adummy.c NULL noise removal 2005-12-15 10:04:31 -08:00
base [PATCH] pcmcia: merge suspend into device model 2006-01-06 00:02:03 +01:00
block [PATCH] nbd: fix TX/RX race condition 2006-01-06 08:33:20 -08:00
bluetooth [PATCH] pcmcia: add some IDs for ide-cs and dtl1_cs 2006-01-06 00:31:07 +01:00
cdrom
char [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
connector [PATCH] Add timestamp field to process events 2005-12-12 08:57:42 -08:00
cpufreq [CPUFREQ] CPU frequency display in /proc/cpuinfo 2005-12-06 19:35:11 -08:00
crypto
dio
eisa
fc4 [SPARC]: introduce a SPARC Kconfig symbol 2005-12-22 23:09:54 -08:00
firmware [PATCH] dell_rbu: NULL noise removal 2005-12-15 10:04:30 -08:00
hwmon [PATCH] hwmon: w83792d fix unused fan pins 2005-11-29 21:39:22 -08:00
i2c [PATCH] i2c: Fix i2c-mv64xxx compilation error 2005-12-16 11:25:25 -08:00
ide [PATCH] pcmcia: add some IDs for ide-cs and dtl1_cs 2006-01-06 00:31:07 +01:00
ieee1394 Merge with http://kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 2006-01-05 08:03:40 -05:00
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6 2006-01-04 18:44:12 -08:00
input Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6 2006-01-04 18:44:12 -08:00
isdn [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
macintosh [PATCH] driver core: replace "hotplug" by "uevent" 2006-01-04 16:18:08 -08:00
mca
md Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild 2006-01-04 16:36:52 -08:00
media [PATCH] USB: remove .owner field from struct usb_driver 2006-01-04 13:48:34 -08:00
message Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2006-01-04 16:30:12 -08:00
mfd [PATCH] input: fix ucb1x00-ts breakage after conversion to dynamic input_dev allocation 2005-12-12 08:57:45 -08:00
misc
mmc [PATCH] driver core: replace "hotplug" by "uevent" 2006-01-04 16:18:08 -08:00
mtd [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
net [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
nubus
oprofile
parisc [PARISC] Make superio.c initialize before any driver needs it 2005-11-17 16:44:57 -05:00
parport [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
pci Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6 2006-01-04 18:44:12 -08:00
pcmcia [PATCH] pcmcia: cleanup cs.c, reduce size 2006-01-06 00:28:15 +01:00
pnp Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6 2006-01-04 18:44:12 -08:00
rapidio
s390 [PATCH] driver kill hotplug word from sn and others fix 2006-01-04 16:18:08 -08:00
sbus [PATCH] sbus/char/uctrl: missing prototypes and NULL noise removal 2005-12-15 10:01:28 -08:00
scsi [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
serial [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
sh
sn
tc [MIPS] zs.c: Resurrect the deceased zs.c for now. 2005-11-17 16:23:39 +00:00
telephony [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
usb [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback 2006-01-06 00:03:24 +01:00
video [ATYFB]: Fix onboard video on SPARC Blade 100 for 2.6.{13,14,15} 2006-01-05 13:12:41 -08:00
w1 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6 2006-01-04 18:44:12 -08:00
zorro
Kconfig
Makefile Link USB drivers later in the kernel 2005-12-03 20:50:51 -08:00