🇰🇷 한글 설명
Linux 커널의 cs40l50-vibra 드라이버에서 사용자 공간의 커스텀 데이터를 검증하지 않아 발생하는 취약점입니다. 공격자가 custom_len 값을 조작하여 메모리 할당 크기를 제어함으로써, 할당된 범위를 벗어난 메모리 읽기(Out-of-bounds Read)를 유발할 수 있습니다.
💡 쉬운 설명
진동을 조절하는 소프트웨어가 사용자가 입력한 데이터의 길이를 제대로 확인하지 않아 발생합니다. 이를 통해 해커가 컴퓨터의 허용되지 않은 메모리 영역을 훔쳐볼 수 있는 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
Input: cs40l50-vibra - validate custom data from user space
cs40l50_add() copies the custom data of an FF_PERIODIC/FF_CUSTOM effect
straight from the ff_effect the user passed to EVIOCSFF, without
requiring it to hold anything:
work_data.custom_data = memdup_array_user(periodic->custom_data,
periodic->custom_len,
sizeof(s16));
work_data.custom_len = periodic->custom_len;
The driver then reads two words out of that buffer: custom_data[0] as the
waveform bank in cs40l50_effect_bank_set(), and custom_data[1] as the
index within the bank in cs40l50_effect_index_set(). Neither read is
covered by a length check, and custom_len is fully user controlled:
- custom_len == 0 makes memdup_array_user() call memdup_user() with a
length of zero, which returns ZERO_SIZE_PTR rather than an error, so
custom_data[0] dereferences it.
- custom_len == 1 allocates two bytes. A bank of ROM or RAM keeps
effect->type out of the OWT case, and custom_data[1] is then read one
word past the allocation.
The bank value itself is also mishandled. It is masked with
CS40L50_CUSTOM_DATA_MASK (0xffff) but stored in an s16, so a
custom_data[0] of 0x8000 or above wraps to a negative value that passes
the "bank_type >= CS40L50_WVFRM_BANK_NUM" test.
cs40l50_effect_index_set() indexes vib->dsp.banks[] with it before the
switch statement's default case gets a chance to reject it:
base_index = vib->dsp.banks[effect->type].base_index;
max_index = vib->dsp.banks[effect->type].max_index;
Require the two words the driver reads to be present, and hold the masked
bank in a u32 so the existing upper-bound test covers the whole range.
The da7280 haptic driver already range checks custom_len this way.
📍 영향받는 시스템
Linux kernel (cs40l50-vibra driver 포함 버전)
⚔️ 공격 벡터
EVIOCSFF ioctl 호출을 통해 조작된 custom_len 및 custom_data 전달
🛡️ 대응 방법
커널 패치를 통해 custom_len에 대한 길이 검증을 수행하고, bank 값을 u32 타입으로 처리하여 범위 검사를 강화해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전인지 확인합니다.