IPBUF安全漏洞报告
English
CVE-2023-53558 CVSS 5.5 中危

CVE-2023-53558 Linux内核rcu-tasks自旋锁上下文睡眠漏洞

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

漏洞信息

漏洞编号
CVE-2023-53558
漏洞类型
死锁/锁上下文错误
CVSS评分
5.5 中危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
Linux Kernel

相关标签

Linux Kernelrcu-tasks自旋锁锁上下文错误内核漏洞本地提权拒绝服务可用性影响内核初始化printk

漏洞概述

CVE-2023-53558是Linux内核rcu-tasks子系统中存在的一个锁上下文错误漏洞。该漏洞位于cblist_init_generic()函数中,在调用pr_info()打印日志信息时持有rtp->cbs_gbl_lock自旋锁。由于pr_info()底层调用printk()函数,而printk()在串行控制台输出过程中可能会获取其他锁并导致睡眠操作,这违反了自旋锁不能在持有期间睡眠的内核规则,从而触发"BUG: Invalid wait context"错误。

该漏洞在系统启动早期(内核初始化阶段)就会被触发,具体发生在rcu_init_tasks_generic()调用cblist_init_generic()的过程中。当swapper/0进程尝试获取port_lock_key(串行端口锁)时,系统检测到非法等待上下文,导致内核警告和潜在的系统挂起或崩溃。此漏洞影响系统的可用性,可能导致内核启动失败或系统不稳定,特别是在使用串行控制台的环境中。

根据CVSS 3.1评分,该漏洞评分为5.5分,属于中危级别。攻击向量为本地攻击(AV:L),需要低权限(PR:L),无需用户交互(UI:N),对机密性影响低(C:L),对完整性无影响(I:N),对可用性影响高(A:H)。这表明该漏洞虽然需要本地访问权限,但一旦触发可能导致系统完全不可用。

技术细节

该漏洞的根本原因是Linux内核rcu-tasks子系统中cblist_init_generic()函数的不当锁使用。具体技术细节如下:

1. **漏洞位置**:kernel/rcu/tasks.h中的cblist_init_generic()函数

2. **触发原理**:在cblist_init_generic()函数中,pr_info()调用在持有rtp->cbs_gbl_lock自旋锁的情况下执行。pr_info()最终调用printk(),而printk()在串行控制台环境下会调用console_unlock(),进而调用console_emit_next_record()和serial8250_console_write(),这些函数会尝试获取port_lock_key自旋锁。

3. **锁依赖冲突**:形成了以下锁依赖链:
- swapper/0/1持有rcu_tasks.cbs_gbl_lock(等级2:2)
- _printk()持有console_lock(等级0:0)
- console_emit_next_record()持有console_owner(等级0:0)
- 尝试获取port_lock_key(等级3:3)

4. **错误检测**:内核的锁调试子系统(lockdep)检测到在原子上下文(自旋锁持有期间)尝试获取可能睡眠的锁,因此触发"Invalid wait context" BUG。

5. **修复方案**:将pr_info()调用移出持有cbs_gbl_lock的临界区,使其在锁释放后执行,避免在自旋锁上下文中调用可能睡眠的printk函数。

利用方式:由于该漏洞在内核初始化早期自动触发,攻击者无需特殊利用代码。任何使用受影响内核版本的系统在启动时(特别是配置了串行控制台的环境)都可能遇到此问题。

攻击链分析

STEP 1
步骤1:系统启动
Linux内核启动过程中,kernel_init()调用kernel_init_freeable(),进而调用rcu_init_tasks_generic()进行RCU Tasks子系统的初始化。
STEP 2
步骤2:触发漏洞函数
rcu_init_tasks_generic()调用cblist_init_generic()函数,该函数获取rtp->cbs_gbl_lock自旋锁。
STEP 3
步骤3:调用pr_info()
在持有自旋锁的情况下,调用pr_info()打印'Setting adjustable number of callback queues'日志信息。
STEP 4
步骤4:printk触发锁冲突
pr_info()调用printk(),printk()通过console_unlock()尝试输出到串行控制台,需要获取port_lock_key。
STEP 5
步骤5:内核BUG触发
lockdep检测到在原子上下文(自旋锁持有)中尝试获取可能睡眠的锁,触发'BUG: Invalid wait context'错误,可能导致系统挂起或内核panic。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// CVE-2023-53558 PoC - Triggering the lock context bug // This vulnerability is automatically triggered during kernel boot // when the serial console is enabled. // Reproduction steps: // 1. Build a Linux kernel with CONFIG_DEBUG_LOCK_ALLOC=y // 2. Enable serial console (e.g., console=ttyS0) // 3. Boot the system - the BUG will appear during rcu_init_tasks_generic() // Kernel boot log showing the vulnerability: /* [ 0.206455] cblist_init_generic: Setting adjustable number of callback queues. [ 0.206463] [ 0.206464] ============================= [ 0.206464] [ BUG: Invalid wait context ] [ 0.206465] 5.19.0-00428-g9de1f9c8ca51 #5 Not tainted [ 0.206466] ----------------------------- [ 0.206466] swapper/0/1 is trying to lock: [ 0.206467] ffffffffa0167a58 (&port_lock_key){....}-{3:3}, at: serial8250_console_write+0x327/0x4a0 [ 0.206473] other info that might help us debug this: [ 0.206473] context-{5:5} [ 0.206474] 3 locks held by swapper/0/1: [ 0.206474] #0: ffffffff9eb597e0 (rcu_tasks.cbs_gbl_lock){....}-{2:2}, at: cblist_init_generic.constprop.0+0x14/0x1f0 [ 0.206478] #1: ffffffff9eb579c0 (console_lock){+.+.}-{0:0}, at: _printk+0x63/0x7e [ 0.206482] #2: ffffffff9ea77780 (console_owner){....}-{0:0}, at: console_emit_next_record.constprop.0+0x111/0x330 */ // The fix involves moving pr_info() outside the spin lock critical section: // Before (vulnerable): // spin_lock(&rtp->cbs_gbl_lock); // pr_info("Setting adjustable number of callback queues.\n"); // // ... other operations ... // spin_unlock(&rtp->cbs_gbl_lock); // // After (fixed): // spin_lock(&rtp->cbs_gbl_lock); // // ... other operations ... // spin_unlock(&rtp->cbs_gbl_lock); // pr_info("Setting adjustable number of callback queues.\n");

影响范围

Linux Kernel < 5fc8cbe4cf0fd34ded8045c385790c3bf04f6785
Linux Kernel < 9027d69221ff96e1356f070f7feb2ff989ae7388
Linux Kernel < ea9b81c7d9104040b46a84d2303045de267f5557
Linux Kernel 5.19.0-00428-g9de1f9c8ca51

防御指南

临时缓解措施
在无法立即升级内核的情况下,可以采取以下临时缓解措施:1)禁用串行控制台输出,使用其他控制台方式(如VGA);2)禁用CONFIG_DEBUG_LOCK_ALLOC配置项以避免lockdep检测;3)在内核启动参数中添加'no_console_suspend'或调整console相关参数;4)监控系统日志,及时发现并处理相关错误信息。建议尽快升级到修复版本以彻底解决该漏洞。

参考链接

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