🔍 CVE-2025-39759

7.0
CVSS Score
HIGH
2025-09-11
2026-10-19 21:10
✅ 완료

🇰🇷 한글 설명

Linux kernel의 btrfs 파일시스템에서 quota 비활성화와 rescan ioctl 사이의 race condition으로 인해 qgroup 레코드가 해제된 후 사용되는 use-after-free 취약점입니다. Task A가 rescan을 시작하기 전에 Task B가 락 없이 qgroup을 해제하면서 메모리 안전 위반이 발생합니다.

💡 쉬운 설명

리눅스 파일시스템에서 두 개의 작업이 동시에 실행될 때 하나가 메모리를 해제하는 동안 다른 하나가 그 메모리를 접근하는 문제입니다. 로컬 공격자가 이를 악용하면 시스템 충돌이나 권한 상승을 유발할 수 있습니다.

🇺🇸 원문 (English)

In the Linux kernel, the following vulnerability has been resolved: btrfs: qgroup: fix race between quota disable and quota rescan ioctl There's a race between a task disabling quotas and another running the rescan ioctl that can result in a use-after-free of qgroup records from the fs_info->qgroup_tree rbtree. This happens as follows: 1) Task A enters btrfs_ioctl_quota_rescan() -> btrfs_qgroup_rescan(); 2) Task B enters btrfs_quota_disable() and calls btrfs_qgroup_wait_for_completion(), which does nothing because at that point fs_info->qgroup_rescan_running is false (it wasn't set yet by task A); 3) Task B calls btrfs_free_qgroup_config() which starts freeing qgroups from fs_info->qgroup_tree without taking the lock fs_info->qgroup_lock; 4) Task A enters qgroup_rescan_zero_tracking() which starts iterating the fs_info->qgroup_tree tree while holding fs_info->qgroup_lock, but task B is freeing qgroup records from that tree without holding the lock, resulting in a use-after-free. Fix this by taking fs_info->qgroup_lock at btrfs_free_qgroup_config(). Also at btrfs_qgroup_rescan() don't start the rescan worker if quotas were already disabled.

📍 영향받는 시스템

Linux kernel의 btrfs 파일시스템을 사용하는 모든 커널 버전 (패치 전)

⚔️ 공격 벡터

로컬 공격자가 quota disable과 quota rescan ioctl을 동시에 실행하여 race condition을 의도적으로 유발

🛡️ 대응 방법

Linux kernel 패치 적용: btrfs_free_qgroup_config()에서 qgroup_lock을 획득하고 btrfs_qgroup_rescan()에서 quota 비활성화 여부 확인

🔧 검증 코드

커널 버전과 btrfs 장착 여부를 확인하고 패치 적용 후 qgroup 정보가 정상적으로 관리되는지 검증합니다.

Shell / Script
uname -r && grep -E 'quota|btrfs' /proc/filesystems && cat /sys/kernel/debug/btrfs/*/qgroups 2>/dev/null | 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