🇰🇷 한글 설명
Linux 커널의 binder 구성 요소에서 보안 컨텍스트(secctx)를 해제하기 전에 크기 정보를 미리 저장하지 않아 발생하는 취약점입니다. 보안 컨텍스트가 해제되어 길이가 0으로 초기화된 후 계산에 사용됨으로써, 버퍼 경계 계산 오류가 발생하여 메모리 오버플로가 가능해집니다.
💡 쉬운 설명
컴퓨터가 데이터를 담는 그릇의 크기를 계산할 때, 이미 비워버린 정보를 다시 읽으려다 계산 실수를 하는 문제입니다. 이 실수 때문에 데이터가 정해진 범위를 넘어서 다른 중요한 정보가 담긴 영역까지 침범할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
binder: cache secctx size before release zeroes it
binder_transaction() bounds the scatter-gather buffer area with
sg_buf_end_offset and subtracts the aligned LSM context size because
the secctx is written at the tail of that area. The subtraction reads
lsmctx.len, but that field has already been cleared by the time the
line runs:
security_secid_to_secctx(secid, &lsmctx) /* lsmctx.len set */
lsmctx_aligned_size = ALIGN(lsmctx.len, sizeof(u64))
extra_buffers_size += lsmctx_aligned_size
...
security_release_secctx(&lsmctx) /* memset zeroes len */
...
sg_buf_end_offset = sg_buf_offset + extra_buffers_size
- ALIGN(lsmctx.len, sizeof(u64)) /* ALIGN(0,8) */
security_release_secctx() does memset(cp, 0, sizeof(*cp)), so lsmctx.len
reads back as 0 and the subtraction contributes nothing, leaving
sg_buf_end_offset too large by the aligned secctx size on every
transaction to a txn_security_ctx node.
Each BINDER_TYPE_PTR object then derives buf_left = sg_buf_end_offset -
sg_buf_offset as the sole upper bound on its copy, so the inflated end
offset lets the copy run into the bytes that already hold the secctx.
The aligned size must therefore be cached before release rather than
re-read from the now-cleared field. Fix by caching it in
lsmctx_aligned_size at function scope when it is first computed and
subtracting lsmctx_aligned_size instead of re-reading lsmctx.len after
release. Reuse the same value for the earlier buf_offset computation.
📍 영향받는 시스템
Linux Kernel (binder driver 사용 시스템)
⚔️ 공격 벡터
BINDER_TYPE_PTR 객체를 이용한 메모리 경계 초과 쓰기(Out-of-bounds write)
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 lsmctx_aligned_size 값을 캐싱하도록 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인합니다.