🇰🇷 한글 설명
Linux 커널의 ftrace 기능에서 페이지 할당 시 실제 용량을 정확히 계산하지 못해 메모리를 과다 할당하는 취약점이 발견되었습니다. ENTRIES_PER_PAGE 계산 방식의 오류로 인해 할당된 페이지 그룹의 실제 용량이 과소평가되어 경고(WARN)가 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터가 메모리를 빌려올 때 실제 쓸 수 있는 양보다 더 많이 빌려오는 계산 실수가 있었습니다. 이로 인해 시스템에 불필요한 경고 메시지가 뜨거나 메모리가 낭비될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ftrace: Do not over-allocate ftrace memory
The pg_remaining calculation in ftrace_process_locs() assumes that
ENTRIES_PER_PAGE multiplied by 2^order equals the actual capacity of the
allocated page group. However, ENTRIES_PER_PAGE is PAGE_SIZE / ENTRY_SIZE
(integer division). When PAGE_SIZE is not a multiple of ENTRY_SIZE (e.g.
4096 / 24 = 170 with remainder 16), high-order allocations (like 256 pages)
have significantly more capacity than 256 * 170. This leads to pg_remaining
being underestimated, which in turn makes skip (derived from skipped -
pg_remaining) larger than expected, causing the WARN(skip != remaining)
to trigger.
Extra allocated pages for ftrace: 2 with 654 skipped
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:7295 ftrace_process_locs+0x5bf/0x5e0
A similar problem in ftrace_allocate_records() can result in allocating
too many pages. This can trigger the second warning in
ftrace_process_locs().
Extra allocated pages for ftrace
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:7276 ftrace_process_locs+0x548/0x580
Use the actual capacity of a page group to determine the number of pages
to allocate. Have ftrace_allocate_pages() return the number of allocated
pages to avoid having to calculate it. Use the actual page group capacity
when validating the number of unused pages due to skipped entries.
Drop the definition of ENTRIES_PER_PAGE since it is no longer used.
📍 영향받는 시스템
Linux Kernel (ftrace 기능이 활성화된 버전)
⚔️ 공격 벡터
로컬 공격자가 ftrace 설정을 조작하여 메모리 과다 할당을 유도할 수 있음
🛡️ 대응 방법
커널 패치를 적용하여 ftrace_allocate_pages()가 실제 할당된 페이지 수를 반환하도록 수정된 최신 커널로 업데이트하십시오.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 보안 패치 버전인지 확인하십시오.