tcp: properly terminate timers for kernel sockets
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 26abe14379f8e2fa3fd1bcf97c9a7ad9364886fe · < c1ae4d1e76eacddaacb958b67cd942082f800c87| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
tcp: properly terminate timers for kernel sockets
We had various syzbot reports about tcp timers firing after the corresponding netns has been dismantled.
Fortunately Josef Bacik could trigger the issue more often, and could test a patch I wrote two years ago.
When TCP sockets are closed, we call inet_csk_clear_xmit_timers() to 'stop' the timers.
inet_csk_clear_xmit_timers() can be called from any context, including when socket lock is held. This is the reason it uses sk_stop_timer(), aka del_timer(). This means that ongoing timers might finish much later.
For user sockets, this is fine because each running timer holds a reference on the socket, and the user socket holds a reference on the netns.
For kernel sockets, we risk that the netns is freed before timer can complete, because kernel sockets do not hold reference on the netns.
From the CVE record · Linux
In the Linux kernel, TCP timers for kernel sockets may continue running after the socket's network namespace has been dismantled. This can happen when a kernel socket is closed during network namespace teardown; the input does not specify an attacker path, authentication requirement, or user interaction.
Engineers running the Linux kernel should check their versions against the vendor advisory; affected versions are not specified in the input.