🇰🇷 한글 설명
Linux 커널의 RedBoot partition table parser에서 CONFIG_FORTIFY_SOURCE 활성화 시 memcmp() 함수가 할당된 버퍼 크기를 초과하여 메모리를 읽으려고 시도하여 부팅 중 crash 발생. strcmp() 사용으로 버퍼 경계 문제를 해결.
💡 쉬운 설명
Linux 부팅 시 디스크 파티션 정보를 읽을 때 메모리 범위를 넘어서 읽으려고 해서 시스템이 크래시 됨. 안전한 문자열 비교 함수로 바꿔서 해결.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
mtd: Avoid boot crash in RedBoot partition table parser
Given CONFIG_FORTIFY_SOURCE=y and a recent compiler,
commit 439a1bcac648 ("fortify: Use __builtin_dynamic_object_size() when
available") produces the warning below and an oops.
Searching for RedBoot partition table in 50000000.flash at offset 0x7e0000
------------[ cut here ]------------
WARNING: lib/string_helpers.c:1035 at 0xc029e04c, CPU#0: swapper/0/1
memcmp: detected buffer overflow: 15 byte read of buffer size 14
Modules linked in:
CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.19.0 #1 NONE
As Kees said, "'names' is pointing to the final 'namelen' many bytes
of the allocation ... 'namelen' could be basically any length at all.
This fortify warning looks legit to me -- this code used to be reading
beyond the end of the allocation."
Since the size of the dynamic allocation is calculated with strlen()
we can use strcmp() instead of memcmp() and remain within bounds.
📍 영향받는 시스템
Linux kernel 6.19.0 및 이전 버전 (CONFIG_FORTIFY_SOURCE=y 활성화된 시스템)
⚔️ 공격 벡터
악성 RedBoot 파티션 테이블을 물리적 또는 가상 저장소에 작성하여 부팅 중 메모리 손상 유발
🛡️ 대응 방법
Linux 커널을 memcmp()를 strcmp()로 변경한 패치된 버전으로 업그레이드
🔧 검증 코드
커널 버전 확인 후 RedBoot 파서에서 strcmp()가 사용되는지 확인하여 패치 적용 여부 판단
uname -r | grep -oE '^[0-9]+\.[0-9]+' && grep -r 'strcmp.*namelen' /lib/modules/$(uname -r)/source 2>/dev/null | head -1