Commit 00494db3 authored by Victor Chang's avatar Victor Chang
Browse files

Don't untag socket before preClose / close

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 fix 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.

Bug: 67425668
Test: CtsLibcoreTestCases
Test: CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests
Test: CtsIncidentHostTestCases -t
com.android.server.cts.NetstatsIncidentTest
Test: CtsOsTestCases -t android.os.cts.StrictModeTest
Test: CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Change-Id: Ic311e626a57dec5584c97c8899468a3c800e7ef0
parent 8f133afd
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment