Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5157D16DED9 for ; Fri, 12 Jul 2024 12:27:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720787258; cv=none; b=ASqcfgSa/om+uGptQ8ZoqB1VIUQEfMITeL6NRtxh/U+SqkxLaiCSjarnoXQai5FkW/1Pl3d2PxqrlCa7kcOFVSnL4nXSsA7pnga/Uv4UtHZ5cVaRKsuf9KBsgz+fQXnT6RKMtG+rorsXgk3QJoxa/boIA9fRUtunKPcfhFAnG4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720787258; c=relaxed/simple; bh=jq/fOJld8ub+TDQgMzgFMa5WZxwugncxKs/ePevP0i0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dyGXV0VMnBCCusunEHxkCckfCG1iL18GXI7swSl4F3pQwsm5CYFAa36YMdlaTevCIN/Fne7lwteKkhMbutl6CA0IlnPkeyEWLpkCfaB8hejTu+dSGSxYVrCq7FbYI1OQHj+vF6sw/9AwxUwhFsnaPwvNlNMn//GtXWt33tRPe+I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TnP23SMK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TnP23SMK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB537C32782; Fri, 12 Jul 2024 12:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720787258; bh=jq/fOJld8ub+TDQgMzgFMa5WZxwugncxKs/ePevP0i0=; h=From:To:Cc:Subject:Date:Reply-to:From; b=TnP23SMKAoGdFHHcnXli2hz7J744V433nUnKcneLQY1e3sUjGT1OqF5Zw1fq3GaJt 9ZheZ7EciRMQm6803Sv2uV3E9LbVMIGmlJzj/6IwriBLajBdIx8IofAKSLW0R4i4KR DIIB+z8tTx93m/9qyvcmYyLIn1DFeh6B512TGYQQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-40925: block: fix request.queuelist usage in flush Date: Fri, 12 Jul 2024 14:27:23 +0200 Message-ID: <2024071214-CVE-2024-40925-d411@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3194; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=jq/fOJld8ub+TDQgMzgFMa5WZxwugncxKs/ePevP0i0=; b=owGbwMvMwCRo6H6F97bub03G02pJDGkTFZWmL99xdhJ7X8vT8wt/Nb9QNfdp3ZZosd5ytvMXV lde5l3TOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiE9YwzPedcsiI7dRN6SV9 lp9eyGT6vpvG/pRhwVR3xcxDfZ8KP83u2LhbPZS7gu+LCQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: block: fix request.queuelist usage in flush Friedrich Weber reported a kernel crash problem and bisected to commit 81ada09cc25e ("blk-flush: reuse rq queuelist in flush state machine"). The root cause is that we use "list_move_tail(&rq->queuelist, pending)" in the PREFLUSH/POSTFLUSH sequences. But rq->queuelist.next == xxx since it's popped out from plug->cached_rq in __blk_mq_alloc_requests_batch(). We don't initialize its queuelist just for this first request, although the queuelist of all later popped requests will be initialized. Fix it by changing to use "list_add_tail(&rq->queuelist, pending)" so rq->queuelist doesn't need to be initialized. It should be ok since rq can't be on any list when PREFLUSH or POSTFLUSH, has no move actually. Please note the commit 81ada09cc25e ("blk-flush: reuse rq queuelist in flush state machine") also has another requirement that no drivers would touch rq->queuelist after blk_mq_end_request() since we will reuse it to add rq to the post-flush pending list in POSTFLUSH. If this is not true, we will have to revert that commit IMHO. This updated version adds "list_del_init(&rq->queuelist)" in flush rq callback since the dm layer may submit request of a weird invalid format (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH), which causes double list_add if without this "list_del_init(&rq->queuelist)". The weird invalid format problem should be fixed in dm layer. The Linux kernel CVE team has assigned CVE-2024-40925 to this issue. Affected and fixed versions =========================== Issue introduced in 6.6 with commit 81ada09cc25e and fixed in 6.6.35 with commit fe1e395563cc Issue introduced in 6.6 with commit 81ada09cc25e and fixed in 6.9.6 with commit 87907bd69721 Issue introduced in 6.6 with commit 81ada09cc25e and fixed in 6.10-rc4 with commit d0321c812d89 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-40925 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: block/blk-flush.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/fe1e395563ccb051e9dbd8fa99859f5caaad2e71 https://git.kernel.org/stable/c/87907bd69721a8506618a954d41a1de3040e88aa https://git.kernel.org/stable/c/d0321c812d89c5910d8da8e4b10c891c6b96ff70