🇰🇷 한글 설명
Linux 커널의 SCSI generic 드라이버에서 def_reserved_size 모듈 파라미터의 유효성 검사를 우회할 수 있는 취약점이 발견되었습니다. 공격자가 이 파라미터를 음수 값으로 직접 수정하고 /dev/sgX 장치를 열면 CPU가 응답하지 않는 소프트 락업(soft lockup) 현상이 발생합니다.
💡 쉬운 설명
시스템 설정값을 비정상적인 값으로 조작하여 컴퓨터의 두뇌 역할을 하는 CPU를 멈추게 만드는 버그입니다. 이로 인해 시스템이 먹통이 되거나 재부팅이 필요할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
scsi: sg: Resolve soft lockup issue when opening /dev/sgX
The parameter def_reserved_size defines the default buffer size reserved
for each Sg_fd and should be restricted to a range between 0 and 1,048,576
(see https://tldp.org/HOWTO/SCSI-Generic-HOWTO/proc.html). Although the
function sg_proc_write_dressz enforces this limit, it is possible to bypass
it by directly modifying the module parameter as shown below, which then
causes a soft lockup:
echo -1 > /sys/module/sg/parameters/def_reserved_size
exec 4<> /dev/sg0
watchdog: BUG: soft lockup - CPU#5 stuck for 26 seconds! [bash:537]
Modules loaded:
CPU: 5 UID: 0 PID: 537 Command: bash, kernel version 6.19.0-rc3+ #134,
PREEMPT disabled
Hardware: QEMU Standard PC (i440FX + PIIX, 1996), BIOS version
1.16.1-2.fc37 dated 04/01/2014
...
Call Trace:
sg_build_reserve+0x5c/0xa0
sg_add_sfp+0x168/0x270
sg_open+0x16e/0x340
chrdev_open+0xbe/0x230
do_dentry_open+0x175/0x480
vfs_open+0x34/0xf0
do_open+0x265/0x3d0
path_openat+0x110/0x290
do_filp_open+0xc3/0x170
do_sys_openat2+0x71/0xe0
__x64_sys_openat+0x6d/0xa0
do_syscall_64+0x62/0x310
entry_SYSCALL_64_after_hwframe+0x76/0x7e
The fix is to use module_param_cb to validate and reject invalid values
assigned to def_reserved_size.
📍 영향받는 시스템
Linux kernel (scsi: sg driver 사용 시스템, 예시 버전 6.19.0-rc3+ 포함)
⚔️ 공격 벡터
모듈 파라미터(/sys/module/sg/parameters/def_reserved_size)를 직접 수정하여 유효하지 않은 값을 주입
🛡️ 대응 방법
module_param_cb를 사용하여 def_reserved_size 파라미터에 대한 유효성 검사 로직을 적용한 최신 커널로 업데이트
🔧 검증 코드
출력된 값이 0과 1,048,576 사이의 정상 범위인지 확인하고, 음수 설정이 가능한지 테스트하여 취약 여부 판단
cat /sys/module/sg/parameters/def_reserved_size