Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756282Ab2HHDmr (ORCPT ); Tue, 7 Aug 2012 23:42:47 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:44185 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753032Ab2HHDmq (ORCPT ); Tue, 7 Aug 2012 23:42:46 -0400 MIME-Version: 1.0 In-Reply-To: <5020E031.9080406@acm.org> References: <501CE4E5.20604@acm.org> <501D51D1.2010806@cs.wisc.edu> <501D83A1.7040900@acm.org> <501DA3F0.4090009@cs.wisc.edu> <50200561.4020100@acm.org> <5020E031.9080406@acm.org> Date: Wed, 8 Aug 2012 12:42:44 +0900 Message-ID: Subject: Re: [PATCH] fix NULL-pointer dereference on scsi_run_queue From: Chanho Min To: Bart Van Assche Cc: Mike Christie , James Bottomley , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Axboe , Tejun Heo Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1186 Lines: 24 > I'm afraid that without the second half of that patch the following race > is still possible: > - sdev reference count drops to zero while scsi_run_queue() is in > progress and while that sdev is on the starved_list of its SCSI host; > scsi_device_dev_release_usercontext() call is scheduled but not yet > executed. > - scsi_run_queue() takes that sdev off the local starved_list. > - scsi_run_queue() calls get_device() and that call fails since the > sdev reference count is zero. > - scsi_device_dev_release_usercontext() gets scheduled and frees the > sdev. > - scsi_run_queue() proceeds and calls __blk_run_queue() on a freed > queue, which is what we were trying to avoid. Thank you for the explanation. It look correct. Let's check one more thing. What If __scsi_remove_device doesn't release device? : reference count is more than 2. So We lost starved_list but device is exist. Is there any issue about this? Chanho, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/