Commit Graph

2046 Commits

Author SHA1 Message Date
Chalard Jean
a69a73ece7 Restrict access to dangerous methods to <= P
Test: make
Fixes: 130143562
Change-Id: I1a6a472f83cf00a1ab174a9c5e67d3e9357a0c45
Merged-In: I95107f7b628eecb54e9f4411785186b668e9f3d8
Merged-In: I890030580fdad45c3f8589bf6adbe5798d578cfe
(cherry picked from commit 0bb53dbb64bbc937a23e1dc7641c8988a6d11d64)
2019-04-16 06:13:09 +00:00
Chalard Jean
ea057ac6a7 Merge "Restrict access to dangerous methods to <= P" am: a1c9270562 am: af8f384985
am: b3dbc3f845

Change-Id: I890030580fdad45c3f8589bf6adbe5798d578cfe
2019-04-15 23:08:09 -07:00
Chalard Jean
b3dbc3f845 Merge "Restrict access to dangerous methods to <= P" am: a1c9270562
am: af8f384985

Change-Id: I95107f7b628eecb54e9f4411785186b668e9f3d8
2019-04-15 22:39:08 -07:00
Chalard Jean
af8f384985 Merge "Restrict access to dangerous methods to <= P"
am: a1c9270562

Change-Id: I3c1271e00e026518e9c4ddafc931a2cac87dcee0
2019-04-15 22:29:28 -07:00
Chalard Jean
a1c9270562 Merge "Restrict access to dangerous methods to <= P" 2019-04-16 05:17:20 +00:00
Chalard Jean
65081e4cf6 Move TrafficStats tags for the network stack constants
As per API council feedback, these constants should live in
a place that is private to the network stack, only with a
range defined in system API.

Bug: 129433383
Test: m
Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086
(cherry picked from commit 79a6330650ca04bd7a08afbd63f8016a3b30bc72)
2019-04-16 00:41:54 +09:00
Chenbo Feng
d9e86cc9bd Merge "Ask netd to swap stats map before reading" am: f8b251fd28 am: 3878f31aff
am: 273e13711d

Change-Id: I4ac7af7b290f4f9cfeaef31e3acfc1c1e0458c3c
2019-04-12 18:30:36 -07:00
Chenbo Feng
273e13711d Merge "Ask netd to swap stats map before reading" am: f8b251fd28
am: 3878f31aff

Change-Id: I333e4cdc807da0dd1e2ca118f9ebcf2d94c683de
2019-04-12 16:39:07 -07:00
Chenbo Feng
3878f31aff Merge "Ask netd to swap stats map before reading"
am: f8b251fd28

Change-Id: I7a683e479fe7631a167138314bcf5948e72386ec
2019-04-12 16:06:30 -07:00
Treehugger Robot
f8b251fd28 Merge "Ask netd to swap stats map before reading" 2019-04-12 22:35:52 +00:00
Chenbo Feng
300b6a3b73 Merge "Add a lock to protect persistent stats snapshot" am: f31face531 am: 57f207b1c7
am: 24e9a313cd

Change-Id: I20ba17b211657542c0bfde6acd4299d9ae6b169b
2019-04-12 06:39:02 -07:00
Chenbo Feng
24e9a313cd Merge "Add a lock to protect persistent stats snapshot" am: f31face531
am: 57f207b1c7

Change-Id: Ia91b71536447e65725a85ebf2ac4f411aebe86c8
2019-04-12 05:59:36 -07:00
Chenbo Feng
57f207b1c7 Merge "Add a lock to protect persistent stats snapshot"
am: f31face531

Change-Id: I73851336452110afb74d6dd1ca5e50047d5b3d4a
2019-04-11 18:44:45 -07:00
Treehugger Robot
f31face531 Merge "Add a lock to protect persistent stats snapshot" 2019-04-12 01:33:00 +00:00
Chenbo Feng
876218abcb Ask netd to swap stats map before reading
To avoid protentail race problem between netd and system_server when
reading the network stats map. Always inform netd before reading the
stats and let netd to do a swap between active stats map and inactive
stats map. So the system_server can safely remove the stats after
reading.

Bug: 126620214
Test: android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: I8fa37c26bec23ffca0b29b679e72ba1189f557f1
2019-04-10 12:59:38 -07:00
Chenbo Feng
0c419ca9eb Add a lock to protect persistent stats snapshot
Since the network stats could be polled from multiple services at
runtime, it is not thread safe for networkStatsFactory to hold a
persistent stats snapshot without any protection. Use a internal lock to
prevent concurrent modification on mPersistentSnapshot to fix the
problem.

Bug: 124764595
Test: android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: I22afb46f17697e8b6359d4f593802e0f4b95db8b
2019-04-10 12:59:18 -07:00
Benedict Wong
5eda9257d9 [automerger skipped] Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev am: 21dbd30681 -s ours
am: 80e078d789 -s ours
am skip reason: change_id I6db75853da9f29e1573512e26351623f22770c5d with SHA1 04738f5b07 is in history

Change-Id: Ibecfa12754acbdce0eb3369d1577eedea91ecaa4
2019-04-10 12:14:07 -07:00
Benedict Wong
80e078d789 [automerger skipped] Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev
am: 21dbd30681 -s ours
am skip reason: change_id I6db75853da9f29e1573512e26351623f22770c5d with SHA1 04738f5b07 is in history

Change-Id: I3e0bd244d8a2ddf86cf4dab99d4a563ea1e2b01e
2019-04-10 11:14:47 -07:00
Benedict Wong
21dbd30681 Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev 2019-04-10 17:07:02 +00:00
Chiachang Wang
92625dde9a [automerger skipped] Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" into qt-dev am: 60cc2ab6e7 -s ours
am: dee0e3d241 -s ours
am skip reason: change_id I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60 with SHA1 e3f8027e89 is in history

Change-Id: I20681ad9cedf6beddf3fdf528e6a514694839258
2019-04-10 04:40:37 -07:00
Chiachang Wang
dee0e3d241 [automerger skipped] Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" into qt-dev
am: 60cc2ab6e7 -s ours
am skip reason: change_id I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60 with SHA1 e3f8027e89 is in history

Change-Id: I23657309145be45306d2df70dcc517e4c36a82a1
2019-04-10 04:14:11 -07:00
Chiachang Wang
8757df33e4 Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces
ConnectivityManager and its usages are removed from
NetworkStatsService. After that, forceUpdateIfaces requires
information that only ConnectivityService has, hence
restricting the calling permission to NETWORK_STACK or
MAINLINE_NETWORK_STACK permission. The required permission
will be changed from READ_NETWORK_USAGE_HISTORY to
NETWORK_STACK or MAINLINE_NETWORK_STACK. This change would make
it impossible to call outside the system.

Bug: 126830974
Test: atest FrameworksNetTests
Merged-In: I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60
Change-Id: I4ea421e4126a45f65d25fe0bec74243a3b20aeab
(cherry picked from commit 6b895dea25b4fca87d275bb78367411623ded1d4)
2019-04-10 06:36:55 +00:00
Chiachang Wang
851b15c72a Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" am: 41c49d1a8e am: a1a994c7eb
am: e3f8027e89

Change-Id: I4ea421e4126a45f65d25fe0bec74243a3b20aeab
2019-04-09 23:24:41 -07:00
Chiachang Wang
e3f8027e89 Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" am: 41c49d1a8e
am: a1a994c7eb

Change-Id: I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60
2019-04-09 20:14:44 -07:00
Chiachang Wang
a1a994c7eb Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces"
am: 41c49d1a8e

Change-Id: Id5922a41d07c95958090f88a65d22ef5883aefff
2019-04-09 19:37:20 -07:00
Chiachang Wang
41c49d1a8e Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" 2019-04-10 02:27:30 +00:00
Benedict Wong
098b1e8ab0 Fix remove-before-add for IpSecService RefcountedResource
This patch fixes a bug where if a binder dies before the linkToDeath
call, the cleanup will be performed before the entry is added to the
array. While it is safe in that quotas and tracking performs as per
normal, the RefcountedRecord may not be cleaned up.

Rethrowing this exception is safe, since the only paths that would hit
this are all on binder threads coming from applications. Further, it
seems there is only one real way of this getting hit - if the app that
called the creation died during the binder call.

Bug: 126802451
Test: Compiled, CTS tests passing
Change-Id: Ib955acaa5e498c0e977cb5f2e48cffbc9fea8c7c
Merged-In: I6db75853da9f29e1573512e26351623f22770c5d
Merged-In: I416c2e43961ec0e1cc6b2fbcef970fbce858603b
Merged-In: Ib955acaa5e498c0e977cb5f2e48cffbc9fea8c7c
(cherry picked from commit 6c089d90bfa728e9842de0f5947f0c557c62dea0)
2019-04-09 21:37:26 +00:00
Benedict Wong
24b1bcb245 Merge "Fix remove-before-add for IpSecService RefcountedResource" am: dcd06394d4 am: 47fa5b0f7f
am: 70c844d317

Change-Id: Ib955acaa5e498c0e977cb5f2e48cffbc9fea8c7c
2019-04-09 11:31:46 -07:00
Benedict Wong
70c844d317 Merge "Fix remove-before-add for IpSecService RefcountedResource" am: dcd06394d4
am: 47fa5b0f7f

Change-Id: I416c2e43961ec0e1cc6b2fbcef970fbce858603b
2019-04-09 10:56:30 -07:00
Benedict Wong
47fa5b0f7f Merge "Fix remove-before-add for IpSecService RefcountedResource"
am: dcd06394d4

Change-Id: Ief286a54a93efd731deeff9fc32815663ab7695d
2019-04-09 10:39:16 -07:00
Benedict Wong
dcd06394d4 Merge "Fix remove-before-add for IpSecService RefcountedResource" 2019-04-09 17:22:56 +00:00
Chiachang Wang
f04137e99e Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces
ConnectivityManager and its usages are removed from
NetworkStatsService. After that, forceUpdateIfaces requires
information that only ConnectivityService has, hence
restricting the calling permission to NETWORK_STACK or
MAINLINE_NETWORK_STACK permission. The required permission
will be changed from READ_NETWORK_USAGE_HISTORY to
NETWORK_STACK or MAINLINE_NETWORK_STACK. This change would make
it impossible to call outside the system.

Bug: 126830974
Test: atest FrameworksNetTests
Change-Id: I776484921b2dbb6735d7940c558fb5e4baed6d1e
2019-04-09 19:42:52 +08:00
Lorenzo Colitti
9dee45962a [automerger skipped] Merge "Fix flaky UdpEncapsulationSocket test" into qt-dev am: 634dff01cb -s ours
am: 8c9e2b7871 -s ours
am skip reason: change_id Idf040a67e53d9b9ec6e6c647ce24f8ada501d355 with SHA1 4be55d08d9 is in history

Change-Id: Ic488c621c0ebe04c6298d7d2a06201abcbb61a37
2019-04-09 04:33:08 -07:00
Lorenzo Colitti
8c9e2b7871 [automerger skipped] Merge "Fix flaky UdpEncapsulationSocket test" into qt-dev
am: 634dff01cb -s ours
am skip reason: change_id Idf040a67e53d9b9ec6e6c647ce24f8ada501d355 with SHA1 4be55d08d9 is in history

Change-Id: Ic9b6b8c2ca4aabd3ed18291a94992a2b67286064
2019-04-09 02:31:35 -07:00
Chalard Jean
3cfb4991eb Restrict access to dangerous methods to <= P
Test: make
Fixes: 130143562
Change-Id: I1a6a472f83cf00a1ab174a9c5e67d3e9357a0c45
2019-04-09 15:47:25 +09:00
Lorenzo Colitti
b2dc0fca0b Fix flaky UdpEncapsulationSocket test
This commit reduces the flakiness of the
testOpenAndCloseUdpEncapsulationSocket by retrying up to three times.
Unfortunately, testing port-selected socket creation is racy against
other applications. This helps to handle the same race condition as done
in IpSecService#bindToRandomPort

Bug: 128024100
Test: 200x runs of testOpenAndCloseUdpEncapsulationSocket
Change-Id: I7e036ce821019dbac6c50899bd0894e89d2fe82a
Merged-In: Idf040a67e53d9b9ec6e6c647ce24f8ada501d355
Merged-In: Iad9aea4b42cd8b31a5a2659bb9cb54dd1c64e8b7
(cherry picked from commit 614ab3dd4e49e9b664f5065983fb9067148fef12)
2019-04-09 06:44:32 +00:00
Benedict Wong
04738f5b07 Fix remove-before-add for IpSecService RefcountedResource
This patch fixes a bug where if a binder dies before the linkToDeath
call, the cleanup will be performed before the entry is added to the
array. While it is safe in that quotas and tracking performs as per
normal, the RefcountedRecord may not be cleaned up.

Rethrowing this exception is safe, since the only paths that would hit
this are all on binder threads coming from applications. Further, it
seems there is only one real way of this getting hit - if the app that
called the creation died during the binder call.

Bug: 126802451
Test: Compiled, CTS tests passing
Change-Id: I6db75853da9f29e1573512e26351623f22770c5d
2019-04-08 18:51:50 -07:00
Chenbo Feng
a5666f4854 Merge "[automerger skipped] Merge "Move NetworkStatsFactory into service directory" am: c452cbf496 am: 1c3e46628c -s ours
am: 3427f091e0 -s ours
am skip reason: change_id Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8 with SHA1 c1b3fc8712 is in history

Change-Id: Ica19aba40268a7e4facbc35cb108ab9fdc1c1ada
2019-04-08 14:11:16 -07:00
Chenbo Feng
1577bee1c0 [automerger skipped] Merge "Move NetworkStatsFactory into service directory" am: c452cbf496
am: 1c3e46628c -s ours
am skip reason: change_id Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8 with SHA1 c1b3fc8712 is in history

Change-Id: I419ae9923a510c9691c8c88911ac45fe76846166
2019-04-08 12:06:35 -07:00
Chenbo Feng
1c3e46628c Merge "Move NetworkStatsFactory into service directory"
am: c452cbf496

Change-Id: If92f556cbf3badcb057a3b6e43bb3ef74d0c9ac0
2019-04-05 13:26:28 -07:00
Treehugger Robot
c452cbf496 Merge "Move NetworkStatsFactory into service directory" 2019-04-05 19:27:22 +00:00
Lorenzo Colitti
a4b7e088c1 Merge "Fix flaky UdpEncapsulationSocket test" am: 066b321400 am: 53e2f98e65
am: 4be55d08d9

Change-Id: Iad9aea4b42cd8b31a5a2659bb9cb54dd1c64e8b7
2019-04-04 09:29:35 -07:00
Lorenzo Colitti
4be55d08d9 Merge "Fix flaky UdpEncapsulationSocket test" am: 066b321400
am: 53e2f98e65

Change-Id: Idf040a67e53d9b9ec6e6c647ce24f8ada501d355
2019-04-04 09:18:29 -07:00
Lorenzo Colitti
53e2f98e65 Merge "Fix flaky UdpEncapsulationSocket test"
am: 066b321400

Change-Id: I4d6cc85fcd539a38674fc3daff1af57fa1bdd2f7
2019-04-04 01:38:02 -07:00
Lorenzo Colitti
066b321400 Merge "Fix flaky UdpEncapsulationSocket test" 2019-04-04 08:09:06 +00:00
Benedict Wong
29c3077ce0 Fix flaky UdpEncapsulationSocket test
This commit reduces the flakiness of the
testOpenAndCloseUdpEncapsulationSocket by retrying up to three times.
Unfortunately, testing port-selected socket creation is racy against
other applications. This helps to handle the same race condition as done
in IpSecService#bindToRandomPort

Bug: 128024100
Test: 200x runs of testOpenAndCloseUdpEncapsulationSocket
Change-Id: I7e036ce821019dbac6c50899bd0894e89d2fe82a
2019-04-03 17:52:03 -07:00
Bill Rassieur
284fac581d Merge master@5428150 into git_qt-dev-plus-aosp.
am: 893ed76cea

Change-Id: I49b4a82ccabbcdd0b2b2be3abf95d796414666c6
2019-04-03 17:50:35 -07:00
TreeHugger Robot
db81a2a52e Merge "Move NetworkStatsFactory into service directory" 2019-04-03 23:44:26 +00:00
Bill Rassieur
ce7f239c76 Merge master@5406228 into git_qt-dev-plus-aosp.
am: 79e158a59b

Change-Id: I684e995988f5a8ef330fbbf55da7ae9230f0cfc2
2019-04-03 16:41:27 -07:00
Chenbo Feng
c1b3fc8712 Move NetworkStatsFactory into service directory
In order to notify netd to swap eBPF maps before pulling the
networkStats from eBPF maps, NetworkStatsFactory need to use the
NetdServices to issue binder calls. So it need to be moved from
framework/base/core to framework/base/service since object in
framework/base/core cannot get any system services. This change is also
necessary for setting up a lock inside NetworkStatsFactory to prevent
racing between two netstats caller since the lock need to be hold before
netd trigger the map swap.

Also fix the compile problem caused by moving the NetworkStatsFactory
and the related tests. Rename the packages and the jni functions to a
more proper name.

Bug: 124764595
Bug: 128900919
Test: NetworkStatsFactoryTest
      android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
2019-04-03 14:28:41 -07:00