linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* dangling pointers and/or reentrancy in scmd_eh_abort_handler?
@ 2014-05-19 14:08 Paolo Bonzini
  2014-05-19 15:08 ` Bart Van Assche
  2014-05-20  8:46 ` Bart Van Assche
  0 siblings, 2 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-05-19 14:08 UTC (permalink / raw)
  To: linux-scsi, Bart Van Assche, Ulrich Obergfell

Hi all,

I'm trying to understand asynchronous abort in the current upstream 
code, and the code seems to have some dubious locking.

Here are some examples of the issue:

1) dangling pointers: scsi_put_command calls cancel_delayed_work(), but 
that doesn't mean that the scmd_eh_abort_handler couldn't be already 
running.  If the scmd_eh_abort_handler starts while the softirq handler 
is calling scsi_put_command (e.g. scsi_finish_command -> 
scsi_io_completion -> scsi_end_request -> scsi_next_command), the 
pointer to the Scsi_Cmnd* becomes invalid in the middle of the abort 
handler.

2) reentrancy: the softirq handler and scmd_eh_abort_handler can run 
concurrently, and call scsi_finish_command without any lock protecting 
the calls.  You can then get memory corruption.



I don't have any reproducer for this; we're seeing related crashes in 
virtio-scsi EH but those are due to a bug in the driver.  But it means 
that I have no sensible way to write the eh_abort_handler.

Example (1) means that the eh_abort_handler cannot use the passed 
Scsi_Cmnd, because it might not even be valid when entering the 
eh_abort_handler.  Example (2) means that the eh_abort_handler cannot 
return SUCCESS if it detects that the command has been completed in the 
meanwhile.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-05-23  9:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19 14:08 dangling pointers and/or reentrancy in scmd_eh_abort_handler? Paolo Bonzini
2014-05-19 15:08 ` Bart Van Assche
2014-05-19 15:25   ` Christoph Hellwig
2014-05-19 16:09   ` Paolo Bonzini
2014-05-19 16:43     ` Bart Van Assche
2014-05-20  7:32       ` Bart Van Assche
2014-05-20  8:10         ` Bart Van Assche
2014-05-20  8:40           ` Paolo Bonzini
2014-05-21 14:16       ` Mark Wu
2014-05-21 20:34         ` Paolo Bonzini
2014-05-23  1:28           ` Elliott, Robert (Server Storage)
2014-05-23  9:22             ` Paolo Bonzini
2014-05-20  8:46 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).