From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796233301; b=aOASPgoe7abpgD6Udnn75rGrGbXcbW78cD2EbRsUyY3t/TmlSqJeXJVtbTZFCx7mr4p4 khOaS1yivlMI4n6QQawQYsOOhvbFMnOlGgzfaVPSzF1AqlUXg6FlwohLYH2jvAxigdwB7 kC4mElHmIcPmNbeO13LCALWeAkdw36o+VUvvz57+Wa5yjF/Y9XJhEipl46oNkj7uDdFLq QqzLMcL++vPI1HfugTKwVeMJWXjSa3TDJgEPDD8MCBBNAi65c3tScC4CisdQv77ksbOX6 GrdyU4Cev8FwQ1NbtXXQ3QbgXoufZTRRlMMyf+e6KcXqrn+urMz0ZAfmM/MUzzF4drw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796233301; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=zr4o1bSJOKo8ZgfgUX5BbEeJzk/+brjDaLIGIHPmDag=; b=Y4EgTY6F+/o5tfdRXtDxFVyxhS+upb4wacotds30gdHG/KNHlAprldLe/XXAfoe7cM2O tjmYItvY6dQaLprsqk1YkRgHfH5gOfH3uH0IK+il5FhkhbkthTYPT3Q4uiVbTBftCL64Z +eB7uGz3Ja6MmsjScHBW4z23ywASTbw7rm/z/C0s+2O3/ZTRYO3Yz+lNjQqTWBcDbXKdB AZ+oKPDHqzjQgoApEnRmXNCYf2R+ud1+JPSI9kL4+RHdVt9nR3F/APBpH5xsC/uB1WfnO /xJsPVlmSdTQU+Ub6L6M/Yw6HS0G4c3DdXfx0s+/7GaCodHYXq8BojPaGz2lXoWbNXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b="VENAL/n0"; arc=none smtp.remote-ip=199.89.1.16 Received: from 013.lax.mailroute.net (013.lax.mailroute.net [199.89.1.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 158C3606A322; Wed, 2 Dec 2026 17:41:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 158C3606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=VENAL/n0 Received: from localhost (localhost [127.0.0.1]) by 013.lax.mailroute.net (Postfix) with ESMTP id 4jflS43z4Hzlfvpq; Wed, 2 Dec 2026 17:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :user-agent:mime-version:date:date:message-id:received:received; s=mr01; t=1796233298; x=1798825299; bh=zr4o1bSJOKo8ZgfgUX5BbEeJ zk/+brjDaLIGIHPmDag=; b=VENAL/n0bwgaj8WG0z0OjTpmyzEbqW+nRh4jDPSR iEfYvTmr9qFKaprKcbyjJspE9qsPYM5GH5jZm42BWqmWdFWCJjyDa0kZPFhMHdPX ytRcQI8NSoUzxKtIpUnEvPRSIILPHSgM53mjagZOtv+a/dPNgjNey7v7UlmpQaCo 7TpdhbNY7n3H7TudMju6yaQ1UyppIP0jE5wazJY18ADMuY77j9f9mKeLQiU8c30U CPCtsLkI6uLPtzTsF/YA8iLCQCKWvDDcHKgBq7wLXrRvWjwiOWOnXhcHx9veAiCJ Fx3lvxyFgcaqlj0chIoApoMiqpu9NvULSg2qiDWrU0SRcw== X-Virus-Scanned: by MailRoute Received: from 013.lax.mailroute.net ([127.0.0.1]) by localhost (013.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 1hTzqBhd2mQC; Wed, 2 Dec 2026 17:41:38 +0000 (UTC) Received: from [IPV6:2a00:79e0:2ed2:d:91f4:1fe5:5a00:2922] (unknown [104.135.182.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 013.lax.mailroute.net (Postfix) with ESMTPSA id 4jflS23VBTzlfvpx; Wed, 2 Dec 2026 17:41:38 +0000 (UTC) Message-ID: <480b7ac5-5a48-43f5-8ce3-1edf4289758f@acm.org> Date: Wed, 2 Dec 2026 09:41:37 -0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] blk-mq: fix null-ptr-deref in blk_mq_run_hw_queues To: Peiyang He , axboe@kernel.dk Cc: ming.lei@redhat.com, fengnanchang@gmail.com, linux-block@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org References: Content-Language: en-US From: Bart Van Assche In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/2/26 7:13 AM, Peiyang He wrote: > A concurrent caller such as blk_mq_unquiesce_queue() can then get a > NULL hctx from queue_hctx() and dereference hctx->state in > blk_mq_hctx_stopped(), causing a NULL pointer dereference. Please make it clear that this is a block layer bug and that the NBD driver is only one way to trigger it. > Fixes: d0c98769ee7d ("blk-mq: use array manage hctx map instead of xarray") This race is much older than commit d0c98769ee7d. I think this is the proper Fixes tag: Fixes: 868f2f0b7206 ("blk-mq: dynamic h/w context count") > + /* > + * __blk_mq_update_nr_hw_queues() updates nr_hw_queues and queue_hw_ctx > + * while the queue is frozen. So we can use q_usage_counter to avoid > + * racing with it. > + */ > + if (!percpu_ref_tryget(&q->q_usage_counter)) > + return; The approach looks good to me but please make the comment more explicit, e.g. as follows: /* * Holding a q_usage_counter reference prevents queue freezing from * completion and hence serializes the loop below against * __blk_mq_update_nr_hw_queues(). */ Thanks, Bart.