From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Snitzer Subject: Re: [PATCH 2/2] dm: Avoid use-after-free of a mapped device Date: Fri, 22 Feb 2013 06:08:29 -0500 Message-ID: <20130222110829.GA30269@redhat.com> References: <51274C2F.6070500@acm.org> <51274CC3.9070204@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <51274CC3.9070204@acm.org> Sender: linux-scsi-owner@vger.kernel.org To: Bart Van Assche Cc: device-mapper development , linux-scsi , Alasdair G Kergon , Jens Axboe , Tejun Heo , James Bottomley List-Id: dm-devel.ids On Fri, Feb 22 2013 at 5:47am -0500, Bart Van Assche wrote: > As the comment above rq_completed() explains, md members must > not be touched after the dm_put() at the end of that function > has been invoked. Avoid that the md->queue can be run > asynchronously after the last md reference has been dropped by > running that queue synchronously. This patch fixes the > following kernel oops: > > general protection fault: 0000 [#1] SMP > RIP: 0010:[] [] mempool_free+0x24/0xb0 > Call Trace: > > [] bio_put+0x97/0xc0 > [] end_clone_bio+0x35/0x90 [dm_mod] > [] bio_endio+0x1d/0x30 > [] req_bio_endio.isra.51+0xa3/0xe0 > [] blk_update_request+0x118/0x520 > [] blk_update_bidi_request+0x27/0xa0 > [] blk_end_bidi_request+0x2c/0x80 > [] blk_end_request+0x10/0x20 > [] scsi_io_completion+0xfb/0x6c0 [scsi_mod] > [] scsi_finish_command+0xbd/0x120 [scsi_mod] > [] scsi_softirq_done+0x13f/0x160 [scsi_mod] > [] blk_done_softirq+0x80/0xa0 > [] __do_softirq+0xf1/0x250 > [] call_softirq+0x1c/0x30 > [] do_softirq+0x8d/0xc0 > [] irq_exit+0xd5/0xe0 > [] do_IRQ+0x63/0xe0 > [] common_interrupt+0x6f/0x6f > > [] srp_queuecommand+0x8c/0xcb0 [ib_srp] > [] scsi_dispatch_cmd+0x148/0x310 [scsi_mod] > [] scsi_request_fn+0x31e/0x520 [scsi_mod] > [] __blk_run_queue+0x37/0x50 > [] blk_delay_work+0x29/0x40 > [] process_one_work+0x1c3/0x5c0 > [] worker_thread+0x15e/0x440 > [] kthread+0xdb/0xe0 > [] ret_from_fork+0x7c/0xb0 Your commit header should probably reference commit a8c32a5c98943d370ea606a2e7dc04717eb92206 ("dm: fix deadlock with request based dm and queue request_fn recursion") and cc: stable with "v3.7+" guidance. Acked-by: Mike Snitzer