Commit 8f133afd authored by Victor Chang's avatar Victor Chang
Browse files

Revert "FileDispatcherImpl: Untag sockets before preClose."

This reverts commit 9666717e.

Previously, xt_qtaguid never freed tags when the socket was closed, so
if we didn't untag sockets in userspace it would leak memory. See for
example b/5274621. That was fixed by the change in b/36374484, so this
code is no longer necessary.

Behavior change
- Automatically untagging sockets on close() is incorrect, because
close() does not close the socket, only the filedescriptor, which might
be only one of the references to the socket. Thus, socket(); dup();
close results in the socket being untagged, even if the dupd socket is
still open.
- Additionally, untagging sockets automatically has undesirable
side-effects. For example, it makes it very difficult for a process to
create and tag a socket, and pass that socket to an app, without losing the tag.

Workaround to keep old behavior
If an app needs to keep old behavior, the app should call
TrafficStats.untagSocket to remove the tag before sending it to another
process.

Test: CtsLibcoreTestCases
Bug: 67425668
Change-Id: I0b0101b5ebc241741d6da707e67cae3f1d5805e8
parent 46f94252
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment