🔍 CVE-2025-40209

0.0
CVSS Score
UNKNOWN
2025-11-21
2026-10-19 19:10
✅ 완료

🇰🇷 한글 설명

Linux 커널의 btrfs 파일 시스템에서 qgroup 레벨이 유효하지 않을 경우 메모리 누수가 발생하는 취약점입니다. btrfs_add_qgroup_relation 함수가 오류를 반환할 때 미리 할당된 메모리를 해제하지 않아 커널 메모리가 소모됩니다.

💡 쉬운 설명

특정 작업을 반복적으로 실패하게 만들어 컴퓨터의 중요한 메모리를 조금씩 계속 갉아먹는 버그입니다. 이 현상이 계속되면 결국 시스템 메모리가 부족해져 컴퓨터가 느려지거나 멈출 수 있습니다.

🇺🇸 원문 (English)

In the Linux kernel, the following vulnerability has been resolved: btrfs: fix memory leak of qgroup_list in btrfs_add_qgroup_relation When btrfs_add_qgroup_relation() is called with invalid qgroup levels (src >= dst), the function returns -EINVAL directly without freeing the preallocated qgroup_list structure passed by the caller. This causes a memory leak because the caller unconditionally sets the pointer to NULL after the call, preventing any cleanup. The issue occurs because the level validation check happens before the mutex is acquired and before any error handling path that would free the prealloc pointer. On this early return, the cleanup code at the 'out' label (which includes kfree(prealloc)) is never reached. In btrfs_ioctl_qgroup_assign(), the code pattern is: prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL); ret = btrfs_add_qgroup_relation(trans, sa->src, sa->dst, prealloc); prealloc = NULL; // Always set to NULL regardless of return value ... kfree(prealloc); // This becomes kfree(NULL), does nothing When the level check fails, 'prealloc' is never freed by either the callee or the caller, resulting in a 64-byte memory leak per failed operation. This can be triggered repeatedly by an unprivileged user with access to a writable btrfs mount, potentially exhausting kernel memory. Fix this by freeing prealloc before the early return, ensuring prealloc is always freed on all error paths.

📍 영향받는 시스템

Linux kernel (btrfs module 사용 환경)

⚔️ 공격 벡터

쓰기 권한이 있는 btrfs 마운트 지점에 접근 가능한 로컬 사용자가 잘못된 qgroup 레벨을 반복적으로 요청

🛡️ 대응 방법

Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트

🔧 검증 코드

출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인

Shell / Script
uname -r

💻 영향받는 소프트웨어

Linux Kernel