🇰🇷 한글 설명
Linux 커널의 TPM 캐릭터 디바이스에서 pread 및 pwrite 핸들러가 활성화되어 있어 발생하는 취약점입니다. 공격자가 임의의 오프셋을 사용하여 pread를 호출할 경우, 체크되지 않은 오프셋으로 인해 힙 영역의 경계 외 읽기(Out-of-bounds read) 및 제로 쓰기(Zero-write)가 발생할 수 있습니다.
💡 쉬운 설명
컴퓨터의 보안 칩(TPM)을 다루는 과정에서 데이터의 위치를 임의로 지정해 읽거나 쓸 수 있는 허점이 발견되었습니다. 이를 악용하면 시스템 메모리의 민감한 정보를 훔쳐보거나 메모리 데이터를 손상시킬 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
tpm: Make the TPM character devices non-seekable
The TPM character devices expose a sequential command/response
interface, but their open handlers leave FMODE_PREAD and FMODE_PWRITE
enabled.
After a command leaves a response pending, pread(fd, buf, 16, 0x1400)
passes 0x1400 as *off to tpm_common_read(). The transfer length is
bounded by response_length, but the offset is used unchecked when
forming data_buffer + *off. A sufficiently large offset therefore causes
an out-of-bounds heap read through copy_to_user() and, if the copy
succeeds, an out-of-bounds zero-write through the following memset().
Positional I/O does not provide coherent semantics for this interface.
An arbitrary pread offset cannot represent how much of a response has
been consumed sequentially. The write callback always stores a command
at the start of data_buffer, while pwrite() does not update file->f_pos
and can leave the sequential read cursor stale.
Call nonseekable_open() from both open handlers. This removes
FMODE_PREAD and FMODE_PWRITE, causing positional reads and writes to
fail with -ESPIPE before reaching the TPM callbacks, and explicitly
marks the files non-seekable. Normal read() and write() continue to use
the existing sequential f_pos cursor, leaving the response state machine
unchanged.
Tested on Linux 6.12 with KASAN and a swtpm TPM2 device:
- sequential partial reads returned the complete response
- pread() and preadv() with offset 0x1400 returned -ESPIPE
- pwrite() and pwritev() with offset zero returned -ESPIPE
- the pending response remained intact after the rejected operations
- a subsequent normal command/response cycle completed normally
- no KASAN report was produced.
📍 영향받는 시스템
Linux kernel (fix applied in 6.12 and later versions)
⚔️ 공격 벡터
임의의 오프셋을 포함한 pread/pwrite 시스템 호출을 통한 메모리 경계 외 접근
🛡️ 대응 방법
Linux 커널을 최신 버전(6.12 이상 또는 해당 패치가 적용된 버전)으로 업데이트하여 TPM 디바이스를 non-seekable 모드로 설정하십시오.
🔧 검증 코드
출력된 커널 버전이 취약점이 해결된 6.12 버전 이상인지 확인하십시오.