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 CC731153518 for ; Wed, 3 Apr 2024 17:33:53 +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=1712165633; cv=none; b=e6k/rfqWDt0gTLlTDH9wqrvh1Lek6BQ0XEERr9OtxF06bbf+cAfLnOZtf0fcVEADah5ibpsF637pB6ah3nGIsdboidfDbs/JWyHnYUOkooaMsop9sn52XxRmsTiMLR8cjX8CBWOvb0IvmVTddLZwPmmYP9AAImziK0xxPxhGHKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712165633; c=relaxed/simple; bh=6uoTuGjxhaJV2FRhH+z5MLDWHbhG8qHGQkpuj2pYW78=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=T2SAFM5xz0UIJgWY1d/0BYHteglG3x08Hy5Wmzh65KzupFhrjBH2pkBCxfQ/+yywTsC++4G9G4pBMzqtkWI1e+TX4xz9eC3pZz89C99FP8ndcssz3TbzUkg6HuRu2ZGVZDueZ4ys4QzH+BAlOKkLGIin7XI4fQRi8aN/pU+bD/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uB9EnsHb; 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="uB9EnsHb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B63FC433F1; Wed, 3 Apr 2024 17:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712165633; bh=6uoTuGjxhaJV2FRhH+z5MLDWHbhG8qHGQkpuj2pYW78=; h=From:To:Cc:Subject:Date:Reply-to:From; b=uB9EnsHbw+J6NTVnvxo819LFRv+A8E35A0Whqh6nXxDil0Ur/n0pQsDdPxfYKSkOj BmHpr15yorqQ2d2PIsHjT3zGBIqyl36KvNL72fx/0cV7PHu1fGQC0Q8ikJPP99IEi9 vPax1fAFL39bKfJkFrm1mNGnxpBMPgpjzpQAyi9I= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26757: md: Don't ignore read-only array in md_check_recovery() Date: Wed, 3 Apr 2024 19:31:24 +0200 Message-ID: <2024040304-CVE-2024-26757-7f96@gregkh> X-Mailer: git-send-email 2.44.0 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=3272; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=6uoTuGjxhaJV2FRhH+z5MLDWHbhG8qHGQkpuj2pYW78=; b=owGbwMvMwCRo6H6F97bub03G02pJDGm8kyK+xy6c0Pji+ZL320v8rT4GMB1RKfn4cdnGb8u5f ql16uz93xHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQAT0XVmmCv6bEWVtdvm/6dv iFdNv7nWMYS7249hwVHpN5aC/x5XLdDfd4h3UsfEZ8tvnAAA 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: md: Don't ignore read-only array in md_check_recovery() Usually if the array is not read-write, md_check_recovery() won't register new sync_thread in the first place. And if the array is read-write and sync_thread is registered, md_set_readonly() will unregister sync_thread before setting the array read-only. md/raid follow this behavior hence there is no problem. After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following hang can be triggered by test shell/integrity-caching.sh: 1) array is read-only. dm-raid update super block: rs_update_sbs ro = mddev->ro mddev->ro = 0 -> set array read-write md_update_sb 2) register new sync thread concurrently. 3) dm-raid set array back to read-only: rs_update_sbs mddev->ro = ro 4) stop the array: raid_dtr md_stop stop_sync_thread set_bit(MD_RECOVERY_INTR, &mddev->recovery); md_wakeup_thread_directly(mddev->sync_thread); wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 5) sync thread done: md_do_sync set_bit(MD_RECOVERY_DONE, &mddev->recovery); md_wakeup_thread(mddev->thread); 6) daemon thread can't unregister sync thread: md_check_recovery if (!md_is_rdwr(mddev) && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) return; -> -> MD_RECOVERY_RUNNING can't be cleared, hence step 4 hang; The root cause is that dm-raid manipulate 'mddev->ro' by itself, however, dm-raid really should stop sync thread before setting the array read-only. Unfortunately, I need to read more code before I can refacter the handler of 'mddev->ro' in dm-raid, hence let's fix the problem the easy way for now to prevent dm-raid regression. The Linux kernel CVE team has assigned CVE-2024-26757 to this issue. Affected and fixed versions =========================== Issue introduced in 4.8 with commit ecbfb9f118bc and fixed in 6.7.7 with commit 2ea169c5a0b1 Issue introduced in 4.8 with commit ecbfb9f118bc and fixed in 6.8 with commit 55a48ad2db64 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-26757 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: drivers/md/md.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/2ea169c5a0b1134d573d07fc27a16f327ad0e7d3 https://git.kernel.org/stable/c/55a48ad2db64737f7ffc0407634218cc6e4c513b