🇰🇷 한글 설명
Linux 커널의 net/sched: cls_bpf 구성 요소에서 오프로드 롤백 시 무한 재귀가 발생하여 스택 오버플로를 유발하는 취약점입니다. 특정 드라이버에서 tc_setup_cb_replace() 호출이 연속으로 실패할 경우, 롤백 과정이 반복되며 시스템 스택을 고갈시킵니다.
💡 쉬운 설명
네트워크 설정을 변경하다가 오류가 발생했을 때, 시스템이 원래 상태로 되돌리려다 계속해서 같은 작업을 반복하며 스스로 멈춰버리는 문제입니다. 이 과정이 반복되면 컴퓨터의 메모리 공간이 가득 차서 시스템이 다운될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
net/sched: cls_bpf: prevent unbounded recursion in offload rollback
Quan Sun reported [1] a stack overflow in cls_bpf_offload_cmd().
Reproducer on netdevsim: add a skip_sw cls_bpf filter, set the
bpf_tc_accept debugfs knob to 0, then `tc filter replace`. The replace
calls tc_setup_cb_replace() which fails. cls_bpf_offload_cmd() then
swaps prog/oldprog and recursively calls itself to roll back. But
bpf_tc_accept=0 makes the rollback fail too, which triggers yet another
rollback frame with the same arguments, and so on until the stack is
exhausted.
bpf_tc_accept is just a convenient knob for the reproducer. Any driver
whose tc_setup_cb_replace() fails twice in a row can hit the same loop,
so this is not a netdevsim-only issue.
Two ways to fix it:
1) Have the rollback call tc_setup_cb_add() on oldprog instead of
re-entering cls_bpf_offload_cmd().
2) Mark the rollback frame with a flag and skip a second-level
rollback from inside it.
Go with (2). It is the smaller change and keeps the original behaviour:
the rollback still goes through tc_setup_cb_replace(), so the driver
gets one real chance to restore its state. If that attempt also fails,
we just return the original error instead of recursing.
[1]: https://lore.kernel.org/bpf/
[email protected]/T/#u
📍 영향받는 시스템
Linux Kernel (cls_bpf 관련 모듈을 사용하는 시스템)
⚔️ 공격 벡터
특정 네트워크 드라이버 환경에서 tc filter replace 명령을 통해 의도적으로 롤백 실패를 유도하여 스택 오버플로 발생
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 롤백 시 재귀 호출을 방지하도록 수정
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인