🇰🇷 한글 설명
32비트 리눅스 커널의 ocfs2 파일 시스템에서 디렉토리 읽기 위치 계산 시 데이터 타입 불일치로 인해 발생하는 취약점입니다. 디렉토리 크기가 4GiB를 초과할 경우 위치 값이 32비트로 잘리면서 이미 읽은 항목을 무한히 반복해서 읽게 되는 문제가 발생합니다.
💡 쉬운 설명
32비트 컴퓨터 환경에서 아주 큰 폴더를 읽을 때, 컴퓨터가 위치를 잘못 계산하여 이미 확인한 파일 목록을 계속해서 반복해서 보여주는 오류입니다. 이로 인해 시스템이 무한 루프에 빠지거나 비정상적인 동작을 할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ocfs2: fix readdir position truncation on 32-bit kernels
In ocfs2_dir_foreach_blk_el(), the directory cookie position is
rebuilt with
ctx->pos = (ctx->pos & ~(sb->s_blocksize - 1)) | offset;
`ctx->pos` is loff_t (signed 64-bit), while `sb->s_blocksize` is
unsigned long. On 32-bit kernels unsigned long is 32-bit, so the mask
~(sb->s_blocksize - 1)
is computed as a 32-bit unsigned value (e.g. 0xfffff000 for a 4 KiB
block size). In the AND expression with the 64-bit `ctx->pos`, that
unsigned operand is zero-extended to 64 bits per the usual arithmetic
conversions, yielding 0x00000000fffff000. The high 32 bits of
`ctx->pos` are silently cleared, even though directory size is
allowed to exceed 4 GiB.
When readdir() crosses the 4 GiB boundary on a 32-bit kernel the
position is reset back into the first 4 GiB block, making the
re-validation path re-enumerate already-returned dirents indefinitely.
This is ocfs2_dir_foreach_blk_el(), the extent-list readdir path taken
for all non-inline directories, so a directory large enough to cross
4 GiB reaches it.
This is the same class of bug that commit 3dce5bb82c97 ("exfat: Fix
bitwise operation having different size") fixed in exfat, and the
fix mirrors the equivalent ext4 fix in this series. Cast the operand
to loff_t so the mask is 64-bit before the AND:
ctx->pos = (ctx->pos & ~((loff_t)sb->s_blocksize - 1)) | offset;
64-bit kernels are unaffected.
📍 영향받는 시스템
32-bit Linux kernel using ocfs2 file system
⚔️ 공격 벡터
4GiB 이상의 대규모 디렉토리를 읽는 작업(readdir)을 수행하여 무한 루프 유도
🛡️ 대응 방법
커널 패치를 통해 sb->s_blocksize를 loff_t 타입으로 캐스팅하여 64비트 연산을 수행하도록 업데이트
🔧 검증 코드
시스템이 32비트 아키텍처이고 ocfs2 모듈이 로드되어 있다면 해당 취약점에 노출될 가능성이 있습니다.
uname -m | grep -i '32' && lsmod | grep ocfs2