linux/drivers/firewire
Jay Fenlason 08bd34c98d firewire: cdev: fix responses to nodes at different card
My box has two firewire cards in it: card0 and card1.
My application opens /dev/fw0 (card 0) and allocates an address space.
The core makes the address space available on both cards.
Along comes the remote device, which sends a READ_QUADLET_REQUEST to
card1.  The request gets passed up to my application, which calls
ioctl_send_response().

ioctl_send_response() then calls fw_send_response() with card0,
because that's the card it's bound to.
Card0's driver drops the response, because it isn't part of
a transaction that it has outstanding.

So in core-cdev: handle_request(), we need to stash the
card of the inbound request in the struct inbound_transaction_resource and
use that card to send the response to.

The hard part will be refcounting the card correctly
so it can't get deallocated while we hold a pointer to it.

Here's a trivial patch, which does not do the card refcounting, but at
least demonstrates what the problem is.

Note that we can't depend on the fact that the core-cdev:client
structure holds a card open, because in this case the card it holds
open is not the card the request came in on.

..and there's no way for the core to tell cdev "this card is gone,
kill any inbound transactions on it", while cdev holds the transaction
open until userspace issues a SEND_RESPONSE ioctl, which may be a very,
very long time.  But when it does, it calls fw_send_response(), which
will dereference the card...

So how unhappy are we about userspace potentially holding a fw_card
open forever?

Signed-off-by: Jay Fenlason <fenlason@redhat.com>

Reference counting to be addressed in a separate change.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (whitespace)
2010-06-20 23:11:56 +02:00
..
core-card.c firewire: drop sizeof expressions from some request size arguments 2010-06-19 13:01:40 +02:00
core-cdev.c firewire: cdev: fix responses to nodes at different card 2010-06-20 23:11:56 +02:00
core-device.c firewire: core: align driver match with modalias 2010-03-24 22:01:47 +01:00
core-iso.c firewire: core: fw_iso_resource_manage: fix error handling 2010-03-15 14:29:44 +01:00
core-topology.c firewire: normalize STATE_CLEAR/SET CSR access interface 2010-06-19 13:01:41 +02:00
core-transaction.c firewire: remove an unused function argument 2010-06-20 23:11:55 +02:00
core.h firewire: rename CSR access driver methods 2010-06-19 13:01:41 +02:00
Kconfig firewire, ieee1394: update Kconfig help 2009-12-29 19:58:17 +01:00
Makefile firewire: net: add Kconfig item, rename driver 2009-06-14 14:26:29 +02:00
net.c firewire: remove an unused function argument 2010-06-20 23:11:55 +02:00
ohci.c firewire: rename CSR access driver methods 2010-06-19 13:01:41 +02:00
ohci.h firewire: add CSR cmstr support 2010-06-10 08:36:37 +02:00
sbp2.c firewire: remove an unused function argument 2010-06-20 23:11:55 +02:00