tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 83fccfc3940c4a2db90fd7e7079f5b465cd8c6af · < 51e34db64f4e43c7b055ccf881b7f3e0c31bb26d| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().
Martin KaFai Lau reported use-after-free [0] in reqsk_timer_handler().
""" We are seeing a use-after-free from a bpf prog attached to trace_tcp_retransmit_synack. The program passes the req->sk to the bpf_sk_storage_get_tracing kernel helper which does check for null before using it. """
The commit 83fccfc3940c ("inet: fix potential deadlock in reqsk_queue_unlink()") added timer_pending() in reqsk_queue_unlink() not to call del_timer_sync() from reqsk_timer_handler(), but it introduced a small race window.
Before the timer is called, expire_timers() calls detach_timer(timer, true) to clear timer->entry.pprev and marks it as not pending.
If reqsk_queue_unlink() checks timer_pending() just after expire_timers() calls detach_timer(), TCP will miss del_timer_sync(); the reqsk timer will continue running and send multiple SYN+ACKs until it expires.
The reported UAF could happen if req->sk is close()d earlier than the timer expiration, which is 63s by default.
From the CVE record · Linux
A race in Linux kernel request timer handling can leave a TCP request timer running after its socket is closed. A use-after-free was observed when a BPF program attached to trace_tcp_retransmit_synack accessed that socket during a later timer run. The input does not establish whether an unauthenticated network attacker can exploit the issue or whether user interaction is needed.
Engineers running the Linux kernel should check their deployments; affected versions are not specified in the input.