🇰🇷 한글 설명
Linux 커널 NFS 읽기 경로의 nfs_return_empty_folio() 함수에서 이중 unlock 버그가 수정되었습니다. 다른 NFS 클라이언트가 파일을 truncate하는 동시에 읽기가 발생하면 folio_unlock()이 두 번 호출되어 PG_locked 플래그가 뒤집히고, 이로 인해 커널 경고 또는 프로세스 무한 대기(교착)가 발생할 수 있었습니다.
💡 쉬운 설명
여러 컴퓨터가 같은 파일을 공유할 때, 한 쪽이 파일을 줄이는 동안 다른 쪽이 읽으면 잠금 처리가 잘못되어 프로세스가 멈출 수 있었습니다. 이 문제는 커널 패치로 해결되었습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
fs/nfs/read: fix double-unlock bug in nfs_return_empty_folio()
Sometimes, when a file was read while it was being truncated by
another NFS client, the kernel could deadlock because folio_unlock()
was called twice, and the second call would XOR back the `PG_locked`
flag.
Most of the time (depending on the timing of the truncation), nobody
notices the problem because folio_unlock() gets called three times,
which flips `PG_locked` back off:
1. vfs_read, nfs_read_folio, ... nfs_read_add_folio,
nfs_return_empty_folio
2. vfs_read, nfs_read_folio, ... netfs_read_collection,
netfs_unlock_abandoned_read_pages
3. vfs_read, ... nfs_do_read_folio, nfs_read_add_folio,
nfs_return_empty_folio
The problem is that nfs_read_add_folio() is not supposed to unlock the
folio if fscache is enabled, and a nfs_netfs_folio_unlock() check is
missing in nfs_return_empty_folio().
Rarely this leads to a warning in netfs_read_collection():
------------[ cut here ]------------
R=0000031c: folio 10 is not locked
WARNING: CPU: 0 PID: 29 at fs/netfs/read_collect.c:133 netfs_read_collection+0x7c0/0xf00
[...]
Workqueue: events_unbound netfs_read_collection_worker
RIP: 0010:netfs_read_collection+0x7c0/0xf00
[...]
Call Trace:
<TASK>
netfs_read_collection_worker+0x67/0x80
process_one_work+0x12e/0x2c0
worker_thread+0x295/0x3a0
Most of the time, however, processes just get stuck forever in
folio_wait_bit_common(), waiting for `PG_locked` to disappear, which
never happens because nobody is really holding the folio lock.
📍 영향받는 시스템
NFS 클라이언트 기능을 사용하며 fscache가 활성화된 Linux 커널 (수정 커밋 적용 전 버전)
⚔️ 공격 벡터
네트워크로 NFS 공유 파일을 truncate하는 다른 클라이언트와 읽기 작업이 경합(race)할 때 발생하는 서비스 거부(교착/경고) 조건이며, 원격 코드 실행이나 권한 상승은 확인되지 않았습니다.
🛡️ 대응 방법
배포판이 제공하는 CVE-2025-38338 수정이 포함된 최신 Linux 커널로 업데이트 후 재부팅하세요.
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지와 대조하고, changelog에 CVE-2025-38338이 나타나면 패치가 포함된 것이며 결과가 비어 있으면 배포판 공지에서 해당 커널 버전의 수정 여부를 직접 확인해야 합니다.
uname -r && (command -v rpm >/dev/null && rpm -q --changelog kernel 2>/dev/null | grep -m3 -i 'CVE-2025-38338' || (command -v dpkg >/dev/null && dpkg -l 'linux-image*' 2>/dev/null | grep '^ii'))