Commit Graph

1118 Commits

Author SHA1 Message Date
Benedict Wong
70867e55f7 Add validation to IpSecConfig algorithm setters
Adds checks to ensure that users can only set the correct types of
algorithms for the Authentication, Encryption and Authenticated
Encryption algorithms.

Bug: 65223935
Test: Added tests in IpSecConfigTest, and passed on aosp_marlin-eng
Change-Id: I462c77d9eb5710b8d03a48866453649d3b6fc6bf
2018-01-04 16:56:40 -08:00
Nathan Harold
fdafce24cf IpSecService - Convert mNextResourceId from AtomicInt to Int
The mNextResourceId variable is only accessed within synchronized
blocks, so there is no need to use an atomic integer to synchronize
it. This eliminates the misleading notion that the variable is
accessed outside of guarded blocks, which it is not.

Bug: 62279167
Test: cts
Change-Id: I815835622659f54d2d2d33b349b17c632ebced8d
2018-01-04 15:28:29 -08:00
Nathan Harold
5e8544685d IpSec Invalidate the Resource IDs on close()
To facilitate error checking we should invalidate
the resource IDs of all objects when we close() them.
Today, the resource ID is invalidated on the Transform
object but not on the SPI or Encap Socket. This CL
unifies the behavior.

Bug: 70641274
Test: cts - IpSecManagerTest
Change-Id: I28caec3e913902c748c6a50b4ef742ccef8b1b09
2018-01-04 15:28:29 -08:00
Manoj Boopathi Raj
c080279fe4 Merge "Fix CTS Test Dual Stack Test Passing Issue" am: ae81e15c9c am: a19acb6ac8
am: 3e4af1dfe7

Change-Id: I39839d144f75340c1b327ed0af180e66db770914
2018-01-04 19:07:19 +00:00
Manoj Boopathi Raj
3e4af1dfe7 Merge "Fix CTS Test Dual Stack Test Passing Issue" am: ae81e15c9c
am: a19acb6ac8

Change-Id: Ica9ded5c7bdbeb243c63a3ebb1ca273d4c8f4138
2018-01-04 18:59:41 +00:00
manojboopathi
ac927fe532 Fix CTS Test Dual Stack Test Passing Issue
CTS test should fail if IPV6 Sockets is used on IPV4 address.
Unfortunately its been passing fine due to unhandled catch
exception. This is fixed in this CL.

Bug: 64435904
Test: Ran CTS test to verify ./run_cts.sh
Change-Id: I369c1b5baaa64b64feaa3f298e61f46d1200ea17
2018-01-02 13:39:13 -08:00
Chenbo Feng
fa05f2bf30 Merge "Use NetworkStatsService to get stats for apps" am: 8469cd614d am: fa7f4015fc
am: 2e6aabced1

Change-Id: I90ce68a72afbf596e28d987e925795709d24dd52
2017-12-21 19:49:25 +00:00
Chenbo Feng
2e6aabced1 Merge "Use NetworkStatsService to get stats for apps" am: 8469cd614d
am: fa7f4015fc

Change-Id: I14f614a86214bd4f006415c48b9a8323e06c737f
2017-12-21 19:15:29 +00:00
Treehugger Robot
8469cd614d Merge "Use NetworkStatsService to get stats for apps" 2017-12-20 20:30:54 +00:00
Benedict Wong
7f98793aa7 Merge "[ipsec-doze] Add fchown to IpSecService to support doze" am: 4edb4c8ec4 am: 5949912523
am: ad2180c3ba

Change-Id: Id6a5ff71ead4566b9a91b9e9b6c78d81f1ac0f54
2017-12-20 18:58:30 +00:00
Benedict Wong
ad2180c3ba Merge "[ipsec-doze] Add fchown to IpSecService to support doze" am: 4edb4c8ec4
am: 5949912523

Change-Id: I9036fc2768dd9664ab7407b359f3c689c7ce700e
2017-12-20 18:42:26 +00:00
Chenbo Feng
aa7ba31c8e Use NetworkStatsService to get stats for apps
Move the native implementation of TrafficStats to NetworkStatsService
and apps need to get the NetworkStatsService binder interface from
system_server in order to get the network usage stats since boot. This
implementation can hide the detail of retrieving network traffic
information from apps and the NetworkStatsService can choose which
methoed it use to get the data depending on the kernel version of the
device.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I53bbefd19aa0b783b9b4b42ea4d76db3e9ec07a3
2017-12-19 19:57:44 -08:00
Benedict Wong
0ee0b691f7 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" am: cd534c6990 am: 8caa274ade
am: 073572a677

Change-Id: I4140f386687c579044f9b5fe59dd7e05f86000fe
2017-12-19 00:41:55 +00:00
Benedict Wong
073572a677 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" am: cd534c6990
am: 8caa274ade

Change-Id: I2f27c76a1f493ff4f0bd423c06f159e629866d4d
2017-12-19 00:27:57 +00:00
Benedict Wong
1768744a3d [ipsec-doze] Add fchown to IpSecService to support doze
Encap sockets are currently created as the system server, and should be
fchown'd to the user for whom it was created on behalf of.

Bug: 62994731
Test: New tests added and run to IpSecService
Change-Id: Icc49e709ae588981e69765fdb77537d7ffbac5fe
2017-12-18 16:01:58 -08:00
Benedict Wong
cd534c6990 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" 2017-12-18 23:50:52 +00:00
Android Build Merger (Role)
e3ccb35df6 Merge "Merge "[CHERRY-PICK] API for apps to tag sockets with their own UID." am: 476398c50d am: 826657a9c2" into oc-mr1-dev-plus-aosp
am: 11448df5a1  -s ours

Change-Id: I3289c409e2014c898cba8ba14768ea174937ffed
2017-12-18 22:14:52 +00:00
Benedict Wong
59dd893f9e Merge "[CHERRY-PICK] API for apps to tag sockets with their own UID." am: 476398c50d
am: 826657a9c2

Change-Id: Ia06653e6c1cccddcd2de17dd88a9ef47263f5c79
2017-12-18 21:56:41 +00:00
Benedict Wong
476398c50d Merge "[CHERRY-PICK] API for apps to tag sockets with their own UID." 2017-12-18 21:32:10 +00:00
Benedict Wong
083faee14a [ipsec-qtaguid] Tag sockets upon creation of encap sockets
Added calls to tag encap sockets to that of the UID for which the encap
socket is being created on behalf of. This ensures that all data
accounting generated for the UDP-encap-ESP socket is correctly billed to
the right UID.

Bug: 62994731
Test: New tests added to IpSecServiceTest.java, passing
Change-Id: I15365ea9c982fd7b4e3cdeff314ddfba2289c86e
2017-12-18 19:46:06 +00:00
Jeff Sharkey
1fb74318cf [CHERRY-PICK] API for apps to tag sockets with their own UID.
This enables app A to create a socket, pass it to app B, and have
app B accept blame for the traffic performed on that socket.

Also adds helpful public APIs for tagging raw FileDescriptor sockets
instead of making developers go through shady SocketImpl wrappers.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData
Bug: 63932076
Change-Id: I08925c843974675fc82e4080cec2eaab9ab7cd41
Merged-In: I08925c843974675fc82e4080cec2eaab9ab7cd41
(cherry picked from commit 4e164f9e94)
2017-12-18 19:44:40 +00:00
nharold
05e99ef743 Merge "Use consistent naming for allocating SPI." am: 816f0ebaab am: 4753ed4b1b
am: 63f6a5625f

Change-Id: Ib6845ab0d7f385fbd1d59c0179771542e12c8be0
2017-12-14 21:48:58 +00:00
nharold
63f6a5625f Merge "Use consistent naming for allocating SPI." am: 816f0ebaab
am: 4753ed4b1b

Change-Id: Ib5d89044313341790b1ee9271642072ddce181af
2017-12-14 21:36:32 +00:00
nharold
816f0ebaab Merge "Use consistent naming for allocating SPI." 2017-12-14 21:10:16 +00:00
TreeHugger Robot
4f47e565a9 Merge "Add more IntDef prefixes for auto-documenting." 2017-12-14 07:17:52 +00:00
Jeff Sharkey
f95fb35f01 Add more IntDef prefixes for auto-documenting.
Test: builds, boots
Bug: 70177949
Exempt-From-Owner-Approval: annotation-only changes
Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
2017-12-13 20:05:36 -07:00
Benedict Wong
d49373feb3 Merge "Convert IpSecService resources to use refcounting" am: 670db0329b am: 8698b33cc2
am: 8d32535eec

Change-Id: Ib18839d7dff8e25898f81e877337fbb8cb24cc7b
2017-12-14 02:41:28 +00:00
Benedict Wong
8d32535eec Merge "Convert IpSecService resources to use refcounting" am: 670db0329b
am: 8698b33cc2

Change-Id: I9645df5304d7f11068d190cbdaccfe83ca0580bc
2017-12-14 02:20:20 +00:00
Benedict Wong
670db0329b Merge "Convert IpSecService resources to use refcounting" 2017-12-14 01:45:15 +00:00
Benedict Wong
6855aeeea2 Convert IpSecService resources to use refcounting
This is part 2 of 2 of the refcounting refactor for IpSecService
resources.

Switched ManagedResources to use RefcountedResource structure for
managing reference counts and eventual cleanup. Further, resource arrays
and quota management have been aggregated into a UserRecord for better
isolation. UID access checking has been similarly moved into the
UserRecordTracker, and resourceId checking has been rolled into
RefcountedResourceArray's accessor methods.

Bug: 63409385
Test: CTS, all unit tests run on aosp_marlin-eng, new tests added
Change-Id: Iee52dd1c9d2583bb6bfaf65be87569e9d50a5b63
2017-12-13 23:28:41 +00:00
Benedict Wong
ea022aef1f Merge "Add reference counted resources to IpSecService" am: 20f80d2083 am: adb6437fea
am: dde203cc4d

Change-Id: Iae17a5d33d71e8abf24211cbf2b215520f45c619
2017-12-13 22:11:20 +00:00
Benedict Wong
dde203cc4d Merge "Add reference counted resources to IpSecService" am: 20f80d2083
am: adb6437fea

Change-Id: I927ac534570b3836510e0fb4feda8cf544f5a9e4
2017-12-13 22:00:26 +00:00
Benedict Wong
20f80d2083 Merge "Add reference counted resources to IpSecService" 2017-12-13 21:33:38 +00:00
Benedict Wong
023468286a Add reference counted resources to IpSecService
This patch adds (but does not enable the usage of) RefcountedResource
objects to IpSecService, with tests to ensure correct function. This is
patch 1 of a series of patches to refactor the resource management
systems in IpSecService.

RefcountedResource objects allow for management of acyclical dependency
trees, ensuring eventual cleanup when resources are no longer used. This
cleanup may be triggered by binder death or by explicit user action.

Bug: 63409385
Test: New tests written in IpSecServiceRefcountedResourceTest,
explicitly testing the RefcountedResource class

Change-Id: Ib5be7482b2ef5f1c8dec9be68f15e90d8b3aba6d
2017-12-12 23:40:52 -08:00
Jonathan Basseri
20e96c55d5 Use consistent naming for allocating SPI.
Throughout the IPsec code (API, system server, netd) we use "reserve"
SPI and "allocate" SPI interchangeably. This renames to use "allocate"
everywhere for self-consistency and consistency with the kernel
(ALLOCSPI).

In javadoc, I am leaving the word "reserve" in several places because it
is still an accurate description of how the method behaves.

Bug: 69128142
Test: TreeHugger should be enough
Change-Id: I8ea603b4612303b0393beef04032671fa53d2106
2017-12-12 13:50:35 -08:00
Xin Li
6d9c671952 Merge "DO NOT MERGE: Merge Oreo MR1 into master" am: b5b6726458 -s ours am: 3aafa4c9ce
am: eab0bd7d94  -s ours

Change-Id: Iba7fa3c7c0a70e34f97b408fe5b58187b1e433ac
2017-12-08 00:40:44 +00:00
Xin Li
eab0bd7d94 Merge "DO NOT MERGE: Merge Oreo MR1 into master" am: b5b6726458 -s ours
am: 3aafa4c9ce

Change-Id: I0e586f759df230aeff2dd045e5ff1d138d284ec3
2017-12-07 08:34:18 +00:00
Xin Li
b5b6726458 Merge "DO NOT MERGE: Merge Oreo MR1 into master" 2017-12-06 23:18:26 +00:00
Jeff Sharkey
c10b61fc54 Merge "API for apps to tag sockets with their own UID." 2017-12-05 05:00:46 +00:00
nharold
97e981cca3 Merge "Validate IpSecAlgorithm Length" am: 68b81299d2 am: f0dd03e114
am: c8347df907

Change-Id: I1a28d860ac7125afc1f82ac17d1834b0121c0e11
2017-12-05 02:46:06 +00:00
nharold
c8347df907 Merge "Validate IpSecAlgorithm Length" am: 68b81299d2
am: f0dd03e114

Change-Id: I1ffaa4de392777c5199a411aef9cd10f4e7c3666
2017-12-05 02:37:14 +00:00
nharold
f0dd03e114 Merge "Validate IpSecAlgorithm Length"
am: 68b81299d2

Change-Id: I23f7612c119e67f9a1647568aeefde38a365f8da
2017-12-05 02:28:10 +00:00
Jeff Sharkey
4e164f9e94 API for apps to tag sockets with their own UID.
This enables app A to create a socket, pass it to app B, and have
app B accept blame for the traffic performed on that socket.

Also adds helpful public APIs for tagging raw FileDescriptor sockets
instead of making developers go through shady SocketImpl wrappers.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData
Bug: 63932076
Change-Id: I08925c843974675fc82e4080cec2eaab9ab7cd41
2017-12-04 17:43:40 -07:00
Nathan Harold
eb1d489332 Validate IpSecAlgorithm Length
Improve the Validation of IpSecAlgorithm by
explicitly checking the length in addition to
the truncation length (previously an oversight).
In addition, we now check the lengths during
un-parceling, which will catch someone maliciously
manually building a parcel and passing it, bypassing
the checks in the constructor.

Bug: 68780091
Test: runtest -x IpSecAlgorithmTest.java
Change-Id: I8172762617264d34f47d5144336464510f07a701
2017-12-04 15:12:14 -08:00
Jonathan Basseri
b77b161454 Merge "Javadoc cleanup of IpSecManager API." am: d09d106ec0 am: f96bfee165
am: 3947cda36f

Change-Id: Id10e39da5495f9367332cbc5c754506fc64f3c75
2017-11-22 02:10:32 +00:00
Jonathan Basseri
3947cda36f Merge "Javadoc cleanup of IpSecManager API." am: d09d106ec0
am: f96bfee165

Change-Id: I53e9b3d18fda1122f6a8a6300185c743cc26dbf6
2017-11-22 02:00:53 +00:00
Jonathan Basseri
f96bfee165 Merge "Javadoc cleanup of IpSecManager API."
am: d09d106ec0

Change-Id: Iaf206b0980d3bed14fe6b8318d2073577212b460
2017-11-22 01:51:46 +00:00
Jonathan Basseri
2725a233c9 Javadoc cleanup of IpSecManager API.
This changes only comments and annotations, which results
in minor API changes.

Bug: 63777932
Test: `make update-api` and visually inspect generated HTML.
Change-Id: I7a7a9244eade6cc55aca17a47e0a838cd6f84cc9
2017-11-20 10:49:59 -08:00
Xin Li
5d3f7dcf9e Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master. am: 47beb1e8a3 -s ours
am: 1f3983785b  -s ours

Change-Id: Idfc0b2349f7475089373c8fdceebe7f166a5cd37
2017-11-15 02:39:52 +00:00
Xin Li
1f3983785b Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.
am: 47beb1e8a3  -s ours

Change-Id: I2d08ca9a952babfd1480278ca6331b697be2a32e
2017-11-15 01:30:08 +00:00