TCP : race condition on socket ownership in tcp_close()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned | ||
Cosmic |
Invalid
|
Undecided
|
Unassigned |
Bug Description
SRU Justification
Impact: WARN_ON messages casued by race condition between the close of
a TCP socket and another process inspecting the same socket.
The code of interest is the following; in tcp_close function :
...
release_sock(sk);
...
WARN_ON(
...
While in release_sock(sk), sock_release_owner function is called which sets the
sk->sk_
When WARN_ON(
owned by anyone.
According to upstream commit 8873c064d1de579
while a socket is being closed is possible that other threads find it in rtnetlink dump.
tcp_get_info() function acquires the socket lock ( and sets sk_lock.owned=1 ) for
a short amount of time, however long enough to trigger this warning.
Fix:
Fixed by upstream commit in v4.20:
Commit: 8873c064d1de579
"tcp: do not release socket ownership in tcp_close()"
Commit 8873c064d1de579
(calling release_sock(sk)) to later; just before exiting tcp_close function.
Testcase:
Reporter has tested and verified test 4.15 test kernel for Bionic.
This bug is difficult to be reproduced locally because the race condition cannot
be triggered in a deterministic way.
To hit this bug we need the following :
a) a process closing a socket and while the execution is between release_sock(s)
and WARN_ON(
b) another process inspecting the same socket to get into tcp_get_info(), acquire
ownership of the socket and not release it until the first process reaches the
WARN_ON(
This scenario is difficult to be achieved in a testing environment.
Regression Potential:
As far as Bionic (4.15 kernel) is concerned the reporter of the bug has tested and
verified a test kernel with the fix.
Concerning Cosmic (4.18 kernel) the fix has not been tested.
However, given that
a) this fix essentially removes the WARN_ON(
and delegates the release of the ownership to later in the tcp_close function, and
b) the relevant code paths in 4.15 and 4.18 are largely the same
the regression potential should be minimal.
CVE References
tags: | added: sts |
Changed in linux (Ubuntu Bionic): | |
status: | Incomplete → Confirmed |
Changed in linux (Ubuntu Cosmic): | |
status: | Incomplete → Confirmed |
Changed in linux (Ubuntu): | |
status: | Incomplete → Confirmed |
Changed in linux (Ubuntu Bionic): | |
status: | Confirmed → Fix Committed |
Changed in linux (Ubuntu Cosmic): | |
status: | Confirmed → Fix Committed |
Changed in linux (Ubuntu Cosmic): | |
status: | Fix Committed → Invalid |
Changed in linux (Ubuntu): | |
status: | Confirmed → Fix Released |
This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:
apport-collect 1830813
and then change the status of the bug to 'Confirmed'.
If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.
This change has been made by an automated script, maintained by the Ubuntu Kernel Team.