From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796475327; b=Qe678uay4CoDN54esbSk7uXhpdGkEK4oC8hQ/jlA+qxCkHgnyApxmoT8CxeVUfltA7GH rB79ZpKwD7OOP0T27KGaq80OUhe1ZCit1qpmcPxbLwhjFFroC3kGhcZf6O/sk/kAnKJUY KMz81/Ks10i8+qZPOY7JGDa9Z1p66TB0IMSYunjMlZObUKd3ALvgUZa9cX9ipqqlxcNsQ uQcZtuUhsZrPVwTCu/x57KGRmKFlVK+1hbhrFmYy922xY8Tv4fQj0h2O8/BpR1sRIldim CBLqkErh724XAQp4EjarKUT2LYfD1/Yyg+RAkdJjOf2ZjKpW3yOtZP8AjMLnshuWLrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796475327; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=wtmmMVSp/EI11Kx+unyHfVx/qvmDe+TlvitHpac5bTk=; b=VSLNZOnGmZxzPcxnwQiM90GPw88xV+zCsegNi1XU4CXKEllaXne/4KMdreDrfj8zWEbT VtzzU40JUNao9i29Ftl9pKpLp0RuL/dhgMPSjvczf6t9M0O8T6K/KC5yCrJGtD8GuqzF+ mCUtTSD9j3ZLAreb2wHIXxzhwX9A79qbXYiBEw6xRgb/JlzIY5+RX4g1VX1KdGaBp77PN e6OMb62LcSfgsyj3gHErFWu/i1NQ4ZDB3MYG1xDDkcx9/Jmbnn3Zv1CwYNCdYJ47b+Yxf O3O9/UPvjdMiT8PIYvoliHsbFRQoBP3OuvJxJFELpkrPlzBffEZpw3vbXslW4CGrDmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ufT+5cIi; arc=none smtp.remote-ip=91.218.175.18 Received: from mta0.migadu.com (out-18.mta0.migadu.com [91.218.175.18]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A65EA606A33C for ; Sat, 5 Dec 2026 12:55:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A65EA606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ufT+5cIi X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=YQZ1X5AFnclstFKjro8x+QEl8rMBSCUbD51+UcudmoM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796475324; v=1; x=1797080124; b=ufT+5cIiu4AJIrKnQHrQSOwWI5ulIBRa2c+TmIKGAoTetElUetxEIXI1tCS7f2Mu3CMDp1sp ec0fVhk0vuUT1FBravT60+P2Dn85S3TlD49TLe24c1U6FO8sFcTR0A/qpShBtOYAGVrmasWNDj5 IPl3BnRqA9p+xdAWVQfARFO4= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id a090db2df11015e8; Sat, 05 Dec 2026 12:55:23 +0000 X-Mizu-Trace-ID: a090db2df11015e8 X-Migadu-Flow: FLOW_OUT From: Md Haris Iqbal To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Jonathan Corbet , linux-doc@vger.kernel.org, Md Haris Iqbal , Sashiko Subject: [PATCH for-rc 1/3] block: fail a delayed bio if its disk was removed Date: Sat, 5 Dec 2026 13:55:06 +0100 Message-ID: <20261205125510.29717-2-haris.iqbal@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261205125510.29717-1-haris.iqbal@linux.dev> References: <20261205125510.29717-1-haris.iqbal@linux.dev> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A bio delayed by an error injection rule is resubmitted from a workqueue with submit_bio_noacct_nocheck(), which skips bio_check_eod(). The delayed bio holds no queue usage counter, so del_gendisk() does not wait for it. For disks that don't own their queue, such as sd and sr, the queue is unfrozen again after del_gendisk(). When sd is unbound while a bio is delayed, the resubmitted bio reaches scsi_queue_rq() after the driver is gone: BUG: kernel NULL pointer dereference, address: 00000000000000c0 Workqueue: blk_error_inject blk_error_inject_delay_work RIP: 0010:scsi_queue_rq+0x5b2/0xb80 Call Trace: __blk_mq_issue_directly+0x3f/0xb0 blk_mq_try_issue_directly+0x8e/0x110 blk_mq_submit_bio+0x6b0/0x710 submit_bio_noacct_nocheck+0x2da/0x3c0 process_one_work+0x19b/0x370 Fail the bio instead of resubmitting it if the disk is dead. Rules that fail the bio after the delay then also end it with BLK_STS_IOERR. Fixes: 6bd856cc9996 ("block: allow error injection rules to delay bios") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20261111215838.103356-1-haris.iqbal%40linux.dev?part=2 Signed-off-by: Md Haris Iqbal --- block/error-injection.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/error-injection.c b/block/error-injection.c index a6de52229ef3..88544eb41c08 100644 --- a/block/error-injection.c +++ b/block/error-injection.c @@ -66,6 +66,12 @@ static void blk_error_inject_delay_work(struct work_struct *work) kfree(d); + /* the disk was removed while the bio was delayed */ + if (test_bit(GD_DEAD, &bio->bi_bdev->bd_disk->state)) { + bio_io_error(bio); + return; + } + if (status != BLK_STS_OK) { blk_error_inject_fail(bio, status); return; -- 2.53.0