tcp: Don't call reqsk_fastopen_remove() in tcp_conn_request().
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ fa4749c065644af4db496b338452a69a3e5147d9 · < c11ace909e873118295e9eb22dc8c58b0b50eb32| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
tcp: Don't call reqsk_fastopen_remove() in tcp_conn_request().
syzbot reported the splat below in tcp_conn_request(). [0]
If a listener is close()d while a TFO socket is being processed in tcp_conn_request(), inet_csk_reqsk_queue_add() does not set reqsk->sk and calls inet_child_forget(), which calls tcp_disconnect() for the TFO socket.
After the cited commit, tcp_disconnect() calls reqsk_fastopen_remove(), where reqsk_put() is called due to !reqsk->sk.
Then, reqsk_fastopen_remove() in tcp_conn_request() decrements the last req->rsk_refcnt and frees reqsk, and __reqsk_free() at the drop_and_free label causes the refcount underflow for the listener and double-free of the reqsk.
Let's remove reqsk_fastopen_remove() in tcp_conn_request().
Note that other callers make sure tp->fastopen_rsk is not NULL.
From the CVE record · Linux
The Linux kernel's TCP Fast Open connection handling can double-free a request socket and underflow a listener reference count. This occurs if a listener is closed while a TCP Fast Open socket is being processed; the input does not establish whether an attacker can trigger it remotely or whether authentication or user interaction is required.
Engineers running the Linux kernel should check their versions; affected versions are not specified in the input.