🔍 CVE-2024-36899

7.0
CVSS Score
HIGH
2024-05-30
2026-10-15 01:18
✅ 완료

🇰🇷 한글 설명

Linux 커널의 gpiolib cdev 모듈에서 GPIO 칩 디바이스 파일 종료 시 발생하는 use-after-free 취약점. watched_lines 메모리가 해제되기 전에 notifier chain unregistration이 rwsem 대기로 인해 지연되어 race condition이 발생하며, 이로 인해 이미 해제된 메모리가 접근됨.

💡 쉬운 설명

리눅스 커널의 GPIO 제어 기능에서 메모리 정리 순서가 잘못되어 해제된 메모리를 계속 사용하는 문제입니다. 프로그램 종료 과정에서의 타이밍 충돌로 인해 발생합니다.

🇺🇸 원문 (English)

In the Linux kernel, the following vulnerability has been resolved: gpiolib: cdev: Fix use after free in lineinfo_changed_notify The use-after-free issue occurs as follows: when the GPIO chip device file is being closed by invoking gpio_chrdev_release(), watched_lines is freed by bitmap_free(), but the unregistration of lineinfo_changed_nb notifier chain failed due to waiting write rwsem. Additionally, one of the GPIO chip's lines is also in the release process and holds the notifier chain's read rwsem. Consequently, a race condition leads to the use-after-free of watched_lines. Here is the typical stack when issue happened: [free] gpio_chrdev_release() --> bitmap_free(cdev->watched_lines) <-- freed --> blocking_notifier_chain_unregister() --> down_write(&nh->rwsem) <-- waiting rwsem --> __down_write_common() --> rwsem_down_write_slowpath() --> schedule_preempt_disabled() --> schedule() [use] st54spi_gpio_dev_release() --> gpio_free() --> gpiod_free() --> gpiod_free_commit() --> gpiod_line_state_notify() --> blocking_notifier_call_chain() --> down_read(&nh->rwsem); <-- held rwsem --> notifier_call_chain() --> lineinfo_changed_notify() --> test_bit(xxxx, cdev->watched_lines) <-- use after free The side effect of the use-after-free issue is that a GPIO line event is being generated for userspace where it shouldn't. However, since the chrdev is being closed, userspace won't have the chance to read that event anyway. To fix the issue, call the bitmap_free() function after the unregistration of lineinfo_changed_nb notifier chain.

📍 영향받는 시스템

Linux kernel 전 버전 (gpio-characterdevice 사용 시스템)

⚔️ 공격 벡터

로컬 접근 필수. GPIO 디바이스 파일 조작을 통해 특정 타이밍에 race condition 유발 가능

🛡️ 대응 방법

Linux 커널을 CVE-2024-36899 패치가 포함된 버전으로 업데이트 (일반적으로 6.1.86, 6.6.26, 6.7.14 이상)

🔧 검증 코드

커널 버전 확인 후 GPIO cdev 기능이 활성화된 경우 배포판 보안 공지에서 패치 상태 확인 필요. 커널 재부팅 후 문제 해결됨.

Shell / Script
uname -r && grep -i 'gpio\|cdev' /proc/config.gz 2>/dev/null | zcat | head -5

📊 CVSS Vector String

CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H

💻 영향받는 소프트웨어

Linux Kernel