From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.244 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796480368; b=P/A9MesbXqUnK9EUdzta5wTgo50u940I6bc2DXaH/s0uIJolfrnMZXWEwyhJhFskKo4Y MpH2i4qzIycJcYiMDqexObcf8VLe0UYnwks42DnEIxcH7sy2kJ2FxC4UMGkzxnZugrdCp i5W70r/I7rtty4dnPZQVPdNnEM6jNmUpmMcow8vce/VTpgwac2MnqAwIdys1juEy8u/mT FmPTcxMfW1+NGmNwO5qXDYWMitcCZY61nxGw5osRa68JjfJ1RUjTCR05/bK4POkzK/Mqr iuIH11DlyZKVpIVH2rDklTLpsvCmgDYI4gwC3VKPWO2KfgdN7+30B7CYq564x9+llDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796480368; 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=FZ/LHJ7yBFROSh/UG6OlJ5ofOCZce+HY3nMDwUws8OIIq81EETZwPVgWpz3F4hSFIGq0 jkhYwPTb/684yODx23D3IFClqFiFI5UTjiV23tOrOrnv5MC0XKt+v3VsZGT7h+vFiAezu eq2aVQmtdMBh3OmvxBO14RoQcbhF9pUgz8xiHFWra/fOZyOhtZJHnnjzrDFMPIxHG3twP 0a2NFQZ68jughnwKZ5Ff8mW4onkk9IFDb34Y7XB3a8SLgP8Lpw5NnO7RfID52kn9PaRef I41vtA99I/ktGcmxsLNvG3i2OhOQxAb04wdrVXHFV+P0AXnkPT6qzM1bHupqGf8jdqQ== 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=AYp6McQV; arc=none smtp.remote-ip=95.215.58.244 Received: from mta1.migadu.com (out-244.mta1.migadu.com [95.215.58.244]) (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 16956606A699 for ; Sat, 5 Dec 2026 14:19:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 16956606A699 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=AYp6McQV X-Envelope-To: linux-block@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=1796480366; v=1; x=1797085166; b=AYp6McQVxzP5KaVnxDxWKhEjDlQzLb4zFwJqI0wL73jkPQNC8KglGpnVdD7mJD8fP9NeY7WR 2KUjdVqsXok88EjHRhtfi5WXsHVsywCtaZ1GpbUX6npZzlaNrkjGecJIi48LUSey9/pH3uJC299 7PWZdigOOcLzQLJLukizdDqU= X-Envelope-To: linux-block@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id d908ec47e445ffab; Sat, 05 Dec 2026 14:19:26 +0000 X-Mizu-Trace-ID: d908ec47e445ffab 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 15:19:10 +0100 Message-ID: <20261205141912.37608-2-haris.iqbal@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261205141912.37608-1-haris.iqbal@linux.dev> References: <20261205141912.37608-1-haris.iqbal@linux.dev> X-Mailing-List: linux-block@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