🇰🇷 한글 설명
Linux 커널의 q54sj108a2 드라이버 debugfs_read 함수에서 bin2hex() 함수의 인자 순서가 잘못되어 스택 버퍼 오버플로우가 발생합니다. 32바이트 I2C 블록 읽기가 64바이트 hex 문자열로 변환되지만, 34바이트만 할당된 버퍼에 쓰여 스택을 30바이트 초과하며, 동시에 인자 순서 오류로 all-zero 데이터를 반환합니다.
💡 쉬운 설명
Linux 커널의 전원 관리 모니터링 드라이버에서 메모리 크기 계산 오류로 버퍼 범위를 벗어나 데이터를 기록하는 문제입니다. 이를 통해 시스템 충돌이나 권한 상승 공격이 가능합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
hwmon: (pmbus/q54sj108a2) fix stack overflow in debugfs read
The q54sj108a2_debugfs_read function suffers from a stack buffer overflow
due to incorrect arguments passed to bin2hex(). The function currently
passes 'data' as the destination and 'data_char' as the source.
Because bin2hex() converts each input byte into two hex characters, a
32-byte block read results in 64 bytes of output. Since 'data' is only
34 bytes (I2C_SMBUS_BLOCK_MAX + 2), this writes 30 bytes past the end
of the buffer onto the stack.
Additionally, the arguments were swapped: it was reading from the
zero-initialized 'data_char' and writing to 'data', resulting in
all-zero output regardless of the actual I2C read.
Fix this by:
1. Expanding 'data_char' to 66 bytes to safely hold the hex output.
2. Correcting the bin2hex() argument order and using the actual read count.
3. Using a pointer to select the correct output buffer for the final
simple_read_from_buffer call.
📍 영향받는 시스템
Linux kernel hwmon/pmbus q54sj108a2 드라이버 - 패치 이전의 모든 버전 (5.10 이전 버전 및 장기 지원 버전들)
⚔️ 공격 벡터
로컬 사용자 접근 권한이 있는 공격자가 debugfs를 통해 I2C 읽기를 반복적으로 트리거하여 스택 오버플로우 유발
🛡️ 대응 방법
Linux 커널을 패치된 버전으로 업데이트하거나, data_char 버퍼를 66바이트로 확대하고 bin2hex() 인자 순서를 수정한 패치 적용
🔧 검증 코드
Module loaded 출력 시 커널 버전 확인 필요 (uname -r). 해당 드라이버가 빌드된 커널의 출시 날짜와 패치 적용 여부를 배포판 보안 공지를 통해 확인
modinfo q54sj108a2 2>/dev/null | grep -q 'filename' && echo 'Module loaded - check kernel version' || echo 'Module not loaded'