🇰🇷 한글 설명
Linux 커널의 io_uring/rsrc 구성 요소에서 folio 크기를 계산할 때 정수 오버플로가 발생하는 취약점입니다. 64비트 커널에서 매우 큰 folio(예: 16GB)를 사용할 경우, 잘못된 크기 계산으로 인해 할당된 배열의 범위를 벗어나 메모리에 쓰는 버퍼 오버플로가 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터가 아주 큰 메모리 덩어리의 크기를 계산할 때 숫자를 잘못 계산하여, 정해진 공간보다 훨씬 더 많은 데이터를 저장하려고 시도하는 문제입니다. 이 과정에서 허용되지 않은 메모리 영역을 건드려 시스템 오류나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
io_uring/rsrc: fix folio size overflow in io_vec_fill_bvec()
io_vec_fill_bvec() computes the folio size with a plain int 1:
unsigned long folio_size = 1 << imu->folio_shift;
imu->folio_shift is unsigned int and comes from folio_shift() of the
folio backing the registered buffer, so it can be 32 or more on a 64 bit
kernel. Shifting int 1 that far is undefined, and on x86 and arm64 the
count is taken modulo 32, so a shift of 34 yields 4 rather than 16G.
Every other folio_shift shift in this file already uses 1UL.
The result is that the segment estimate and the fill loop disagree.
io_estimate_bvec_size() sizes the bvec array with the real shift:
max_segs += (iov[i].iov_len >> shift) + 2;
so a 1M iovec on a 16G folio is charged 2 segments, while
io_vec_fill_bvec() then walks the same iovec in folio_size chunks of 4
bytes and writes res_bvec[bvec_idx] a quarter of a million times, past
the end of the array it was given. src_bvec is advanced once per
iteration as well, so imu->bvec is read past its end at the same time.
validate_fixed_range() only checks that the range is inside the
registered buffer and does not bound the segment count.
Reaching it needs a folio with a shift of at least 32, which means a
gigantic hugetlb page: 16G on arm64 with 64K pages, where
CONT_PMD_SHIFT is 34 and hugetlb_add_hstate(CONT_PMD_SHIFT - PAGE_SHIFT)
registers that size, and likewise on powerpc. x86_64 tops out at 1G, so
a shift of 30, which still fits in int and is unaffected.
Use 1UL, as the rest of the file does.
📍 영향받는 시스템
Linux kernel (io_uring 사용 및 대용량 hugetlb 페이지를 사용하는 시스템)
⚔️ 공격 벡터
특수하게 구성된 대용량 folio를 사용하는 io_uring 요청을 통해 메모리 범위를 벗어난 쓰기 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 io_vec_fill_bvec() 내의 계산 방식을 1UL로 수정
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인