All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-scsi <linux-scsi@vger.kernel.org>,
	Bart Van Assche <bvanassche@acm.org>,
	Ulrich Obergfell <uobergfe@redhat.com>
Subject: dangling pointers and/or reentrancy in scmd_eh_abort_handler?
Date: Mon, 19 May 2014 16:08:27 +0200	[thread overview]
Message-ID: <537A105B.4080504@redhat.com> (raw)

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

             reply	other threads:[~2014-05-19 14:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 14:08 Paolo Bonzini [this message]
2014-05-19 15:08 ` dangling pointers and/or reentrancy in scmd_eh_abort_handler? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=537A105B.4080504@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bvanassche@acm.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=uobergfe@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.