In the Linux kernel, the following vulnerability has been resolved:
md: Don't ignore read-only array in mdcheckrecovery()
Usually if the array is not read-write, mdcheckrecovery() won't register new syncthread in the first place. And if the array is read-write and syncthread is registered, mdsetreadonly() 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: rsupdatesbs ro = mddev->ro mddev->ro = 0 -> set array read-write mdupdatesb
2) register new sync thread concurrently.
3) dm-raid set array back to read-only: rsupdatesbs mddev->ro = ro
4) stop the array: raiddtr mdstop stopsyncthread setbit(MDRECOVERYINTR, &mddev->recovery); mdwakeupthreaddirectly(mddev->syncthread); waitevent(..., !testbit(MDRECOVERY_RUNNING, &mddev->recovery))
5) sync thread done: mddosync setbit(MDRECOVERYDONE, &mddev->recovery); mdwakeup_thread(mddev->thread);
6) daemon thread can't unregister sync thread: mdcheckrecovery if (!mdisrdwr(mddev) && !testbit(MDRECOVERYNEEDED, &mddev->recovery)) return; -> -> MDRECOVERY_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.
[ { "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@2ea169c5a0b1134d573d07fc27a16f327ad0e7d3", "target": { "file": "drivers/md/md.c" }, "signature_type": "Line", "deprecated": false, "digest": { "line_hashes": [ "51875062674802639080570421002082963039", "147455009612227496026495345361000513064", "55480160997835376006104180814619795462", "54429319178508415129169784273894243440", "292695598806442858279603530327060121534", "103655806225354460819757461454612397659", "121731383947216411940526209643721882787", "305370741200640733564105121776174256721", "3655471596903549166711772230272375140", "99173623455851864578781785359200165655", "100370895212316450994542936397033578767", "251439056819072176145933305309328076004", "205900849428195336889892884369371200053", "115073152923557056178636903805526942931", "243498305889229961142404203537846717663", "166354700164272485453831897349571417315", "249615055233655078594258931477727507667", "336175119148437467853156373827887432988", "11814822628225411001378232750110566339", "329862472169024019918216111133601653124", "162337090225286619361869858817377940323" ], "threshold": 0.9 }, "signature_version": "v1", "id": "CVE-2024-26757-4e606d85" }, { "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@55a48ad2db64737f7ffc0407634218cc6e4c513b", "target": { "function": "md_check_recovery", "file": "drivers/md/md.c" }, "signature_type": "Function", "deprecated": false, "digest": { "function_hash": "147946770650260144420238322102292393165", "length": 2836.0 }, "signature_version": "v1", "id": "CVE-2024-26757-89e5d037" }, { "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@55a48ad2db64737f7ffc0407634218cc6e4c513b", "target": { "file": "drivers/md/md.c" }, "signature_type": "Line", "deprecated": false, "digest": { "line_hashes": [ "51875062674802639080570421002082963039", "147455009612227496026495345361000513064", "55480160997835376006104180814619795462", "54429319178508415129169784273894243440", "292695598806442858279603530327060121534", "103655806225354460819757461454612397659", "121731383947216411940526209643721882787", "305370741200640733564105121776174256721", "3655471596903549166711772230272375140", "99173623455851864578781785359200165655", "100370895212316450994542936397033578767", "251439056819072176145933305309328076004", "205900849428195336889892884369371200053", "115073152923557056178636903805526942931", "243498305889229961142404203537846717663", "166354700164272485453831897349571417315", "249615055233655078594258931477727507667", "336175119148437467853156373827887432988", "11814822628225411001378232750110566339", "329862472169024019918216111133601653124", "162337090225286619361869858817377940323" ], "threshold": 0.9 }, "signature_version": "v1", "id": "CVE-2024-26757-8cfd1a52" }, { "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@2ea169c5a0b1134d573d07fc27a16f327ad0e7d3", "target": { "function": "md_check_recovery", "file": "drivers/md/md.c" }, "signature_type": "Function", "deprecated": false, "digest": { "function_hash": "147946770650260144420238322102292393165", "length": 2836.0 }, "signature_version": "v1", "id": "CVE-2024-26757-c6199722" } ]