🇰🇷 한글 설명
Linux 커널의 Ceph 파일시스템에서 fscrypt 암호화 활성화 시 bounce buffer 할당 실패로 인한 에러가 메인 writeback 루프로 전파되는 문제. rc 변수 리셋 실패로 메모리 누수와 BUG_ON() 호출 발생 가능.
💡 쉬운 설명
Linux 커널의 파일 시스템에서 암호화된 파일을 저장할 때 메모리 할당이 실패하면 프로그램이 정상적으로 처리하지 못한다. 이로 인해 메모리가 새거나 시스템이 죽을 수 있다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ceph: do not propagate page array emplacement errors as batch errors
When fscrypt is enabled, move_dirty_folio_in_page_array() may fail
because it needs to allocate bounce buffers to store the encrypted
versions of each folio. Each folio beyond the first allocates its bounce
buffer with GFP_NOWAIT. Failures are common (and expected) under this
allocation mode; they should flush (not abort) the batch.
However, ceph_process_folio_batch() uses the same `rc` variable for its
own return code and for capturing the return codes of its routine calls;
failing to reset `rc` back to 0 results in the error being propagated
out to the main writeback loop, which cannot actually tolerate any
errors here: once `ceph_wbc.pages` is allocated, it must be passed to
ceph_submit_write() to be freed. If it survives until the next iteration
(e.g. due to the goto being followed), ceph_allocate_page_array()'s
BUG_ON() will oops the worker.
Note that this failure mode is currently masked due to another bug
(addressed next in this series) that prevents multiple encrypted folios
from being selected for the same write.
For now, just reset `rc` when redirtying the folio to prevent errors in
move_dirty_folio_in_page_array() from propagating. Note that
move_dirty_folio_in_page_array() is careful never to return errors on
the first folio, so there is no need to check for that. After this
change, ceph_process_folio_batch() no longer returns errors; its only
remaining failure indicator is `locked_pages == 0`, which the caller
already handles correctly.
📍 영향받는 시스템
Ceph 파일시스템이 활성화되고 fscrypt 암호화가 사용되는 Linux 커널 (5.x ~ 6.x)
⚔️ 공격 벡터
암호화된 파일에 대한 대량 쓰기 작업을 통해 bounce buffer 할당 실패 유발 가능 (로컬)
🛡️ 대응 방법
Linux 커널을 최신 버전으로 업그레이드하거나 Ceph 쓰기 배치 처리 함수의 에러 처리 로직 패치 적용
🔧 검증 코드
커널 버전이 5.x 또는 6.x이면서 Ceph 파일시스템이 마운트되어 있으면 위험; 커널 패치 확인을 위해서는 kernel version과 ceph module commit hash 비교 필요
uname -r | grep -E '(5\.[0-9]+|6\.[0-9]+)' && grep -q 'ceph' /etc/fstab 2>/dev/null && echo 'Ceph+fscrypt 위험' || echo 'Not vulnerable'