🇰🇷 한글 설명
Linux 커널의 amd/display 드라이버에서 eng_id 값이 음수이거나 배열 크기를 초과할 경우 발생하는 Out-of-bounds 인덱스 접근 취약점입니다. 이로 인해 stream_enc_regs 배열의 범위를 벗어난 메모리에 접근할 수 있습니다.
💡 쉬운 설명
컴퓨터가 데이터를 저장하는 목록의 범위를 벗어나 잘못된 위치의 메모리를 읽거나 쓸 수 있는 오류입니다. 이로 인해 시스템이 불안정해지거나 보안 문제가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
drm/amd/display: Fix out-of-bounds stream encoder index v3
eng_id can be negative and that stream_enc_regs[]
can be indexed out of bounds.
eng_id is used directly as an index into stream_enc_regs[], which has
only 5 entries. When eng_id is 5 (ENGINE_ID_DIGF) or negative, this can
access memory past the end of the array.
Add a bounds check using ARRAY_SIZE() before using eng_id as an index.
The unsigned cast also rejects negative values.
This avoids out-of-bounds access.
Fixes the below smatch error:
dcn*_resource.c: stream_encoder_create() may index
stream_enc_regs[eng_id] out of bounds (size 5).
drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn351/dcn351_resource.c
1246 static struct stream_encoder *dcn35_stream_encoder_create(
1247 enum engine_id eng_id,
1248 struct dc_context *ctx)
1249 {
...
1255
1256 /* Mapping of VPG, AFMT, DME register blocks to DIO block instance */
1257 if (eng_id <= ENGINE_ID_DIGF) {
ENGINE_ID_DIGF is 5. should <= be <?
Unrelated but, ugh, why is Smatch saying that "eng_id" can be negative?
end_id is type signed long, but there are checks in the caller which prevent it from being negative.
1258 vpg_inst = eng_id;
1259 afmt_inst = eng_id;
1260 } else
1261 return NULL;
1262
...
1281
1282 dcn35_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios,
1283 eng_id, vpg, afmt,
--> 1284 &stream_enc_regs[eng_id],
^^^^^^^^^^^^^^^^^^^^^^^ This stream_enc_regs[] array has 5 elements so we are one element beyond the end of the array.
...
1287 return &enc1->base;
1288 }
v2: use explicit bounds check as suggested by Roman/Dan; avoid unsigned int cast
v3: The compiler already knows how to compare the two values, so the
cast (int) is not needed. (Roman)
📍 영향받는 시스템
Linux Kernel (AMD GPU DRM driver 관련 구성 요소)
⚔️ 공격 벡터
조작된 eng_id 값을 전달하여 커널 메모리의 범위를 벗어난 영역에 접근
🛡️ 대응 방법
ARRAY_SIZE()를 사용한 경계 검사 로직이 포함된 최신 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 패치된 최신 버전인지 확인합니다.