🇰🇷 한글 설명
Linux 커널의 net/sched: act_pedit 모듈에서 tc 오프로드 시 TOCTOU(Time-of-Check to Time-of-Use) 레이스 컨디션으로 인한 힙 영역의 Out-of-Bounds(OOB) 쓰기 취약점이 발견되었습니다. 이 취약점은 flow_rule 버퍼의 크기를 결정하는 시점과 데이터를 채우는 시점 사이의 잠금 메커니즘 차이로 인해 발생하며, 공격자가 인접한 슬랩 객체에 제어 가능한 데이터를 쓸 수 있게 합니다.
💡 쉬운 설명
데이터를 저장할 공간의 크기를 확인한 직후, 실제 데이터를 넣기 전에 공간 크기가 변해버리는 틈을 타서 정해진 범위를 벗어나 메모리를 덮어쓰는 문제입니다. 이를 통해 해커가 시스템의 중요한 메모리 영역을 조작할 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
net/sched: act_pedit: fix TOCTOU heap OOB write in tc offload
There is a TOCTOU race condition in flower lockless approach between sizing
a flow_rule buffer and filling it.
[email protected] reports:
The cls_flower classifier operates with TCF_PROTO_OPS_DOIT_UNLOCKED
(fl_change runs without RTNL), while RTM_NEWACTION holds RTNL, so the
independent locking domains make the race reachable in practice. KASAN
confirms:
BUG: KASAN: slab-out-of-bounds in tcf_pedit_offload_act_setup+0x81b/0x930
Write of size 4 at addr ffff888001f27520 by task poc-toctou/312
The buggy address is located 0 bytes to the right of
allocated 288-byte region [ffff888001f27400, ffff888001f27520)
(cache kmalloc-512)
Note: The result is a heap OOB write attacker-controlled content into the
adjacent slab object (requires CAP_NET_ADMIN).
The fix introduces reading tcfp_nkeys under act->tcfa_lock in all places
using a new tcf_pedit_nkeys_locked() which replaces the old tcf_pedit_nkeys().
Additionally we close the remaining TOCTOU window between the sizing read and
the fill reads by more careful accounting.
Rather than silently truncating the key count, which leads to incorrect
action semantics offloaded to hardware and secondary OOB writes if
the remaining capacity is zero or consumed by prior actions, we enforce
remaining capacity checks and return -ENOSPC if the required space exceeds
the remaining capacity.
📍 영향받는 시스템
Linux Kernel (act_pedit/tc offload 기능 사용 시)
⚔️ 공격 벡터
CAP_NET_ADMIN 권한을 가진 사용자가 레이스 컨디션을 유발하여 힙 메모리 경계를 넘어서는 쓰기 공격 수행
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 tcf_pedit_nkeys_locked() 함수 및 용량 검증 로직 적용
🔧 검증 코드
출력된 커널 버전이 취약점이 수정된 최신 패치 버전인지 확인합니다.