🇰🇷 한글 설명
Linux 커널의 CephFS에서 암호화된 파일을 처리할 때, 메모리 부족으로 바운스 버퍼 할당에 실패할 경우 num_ops 변수가 실제 데이터 범위와 일치하지 않는 오프바이원(off-by-one) 오류가 발생합니다. 이로 인해 ceph_submit_write 함수에서 커널 패닉(Kernel Panic)이 발생하여 시스템이 중단될 수 있습니다.
💡 쉬운 설명
암호화된 파일을 저장하는 과정에서 메모리가 부족해지면, 컴퓨터가 계산을 잘못하여 시스템이 갑자기 멈추거나 꺼질 수 있는 문제입니다. 특정 패턴으로 파일을 쓰고 메모리를 압박하면 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ceph: fix num_ops off-by-one when crypto allocation fails
move_dirty_folio_in_page_array() may fail if the file is encrypted, the
dirty folio is not the first in the batch, and it fails to allocate a
bounce buffer to hold the ciphertext. When that happens,
ceph_process_folio_batch() simply redirties the folio and flushes the
current batch -- it can retry that folio in a future batch.
However, if this failed folio is not contiguous with the last folio that
did make it into the batch, then ceph_process_folio_batch() has already
incremented `ceph_wbc->num_ops`; because it doesn't follow through and
add the discontiguous folio to the array, ceph_submit_write() -- which
expects that `ceph_wbc->num_ops` accurately reflects the number of
contiguous ranges (and therefore the required number of "write extent"
ops) in the writeback -- will panic the kernel:
BUG_ON(ceph_wbc->op_idx + 1 != req->r_num_ops);
This issue can be reproduced on affected kernels by writing to
fscrypt-enabled CephFS file(s) with a 4KiB-written/4KiB-skipped/repeat
pattern (total filesize should not matter) and gradually increasing the
system's memory pressure until a bounce buffer allocation fails.
Fix this crash by decrementing `ceph_wbc->num_ops` back to the correct
value when move_dirty_folio_in_page_array() fails, but the folio already
started counting a new (i.e. still-empty) extent.
The defect corrected by this patch has existed since 2022 (see first
`Fixes:`), but another bug blocked multi-folio encrypted writeback until
recently (see second `Fixes:`). The second commit made it into 6.18.16,
6.19.6, and 7.0-rc1, unmasking the panic in those versions. This patch
therefore fixes a regression (panic) introduced by cac190c7674f.
📍 영향받는 시스템
Linux kernel (6.18.16, 6.19.6, 7.0-rc1 및 관련 CephFS 사용 버전)
⚔️ 공격 벡터
암호화된 CephFS 파일에 특정 패턴(4KiB 쓰기/4KiB 건너뛰기)으로 데이터를 쓰고 시스템 메모리 압박을 유도하여 커널 패닉 유발
🛡️ 대응 방법
최신 보안 패치가 적용된 Linux 커널로 업데이트하여 ceph_wbc->num_ops 감소 로직을 적용해야 함
🔧 검증 코드
출력된 커널 버전이 패치가 적용된 수정 버전(6.18.16 이상, 6.19.6 이상 또는 7.0-rc1 이후 버전 등)인지 확인