Commit Graph

1140 Commits

Author SHA1 Message Date
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
Xin Li
47beb1e8a3 Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from
oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.

Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7
Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
2017-11-14 12:31:11 -08:00
Ricky Wai
3e97a6fc40 Hide NetworkStatsFactory class
Test: Able to compile
Change-Id: I37f385c773120405c437643b5de406772a684dcd
2017-11-09 15:22:59 +00:00
nharold
2fd8e1a9e6 Merge "Fix signature for finalize() to resolve API Lint error" am: 28dc8a29a1
am: c09d405e1d

Change-Id: I1f8915547876e0e0045724eb9a1e29123ab4edda
2017-11-08 18:20:06 +00:00
Benedict Wong
d12ea7c331 Merge "Update documentation for AES-GCM-ESP keymat length" am: f27dc03921
am: 6491b03410

Change-Id: I5e61a9c28dac49f2dca554ce2fdf755ab7be0dab
2017-11-08 18:12:25 +00:00
nharold
28dc8a29a1 Merge "Fix signature for finalize() to resolve API Lint error" 2017-11-08 17:56:43 +00:00
Benedict Wong
f27dc03921 Merge "Update documentation for AES-GCM-ESP keymat length" 2017-11-08 17:47:40 +00:00
Nathan Harold
2a30daf3f7 Fix signature for finalize() to resolve API Lint error
The API linter on goog/master noticed that this method is
listed in the public API even though it's protected. The
change is probably related to a signature change from the
internal finalize method which throws a Throwable. Fix the
method in IpSecManager to throw Throwable, which should
fix the current.txt and resolve the lint error.

Bug: 69006767
Test: compilation, make update-api
Change-Id: I173d014baaa505c365b7916fcb52f2a8b4af9373
2017-11-07 17:46:12 -08:00
Benedict Wong
01b1ab4034 Update documentation for AES-GCM-ESP keymat length
Added notes that keymat length must include 32 bits of salt.

Bug: 68672051
Test: Frameworks-net unit tests & IpSecManager CTS tests run
Change-Id: I0ae0c5be8a45b2374783b3bd1fa8bf930f15e687
2017-11-07 17:39:35 -08:00
Jeff Sharkey
0a2582193e Merge "Define NOT_ROAMING network capability." am: 8f380ab29c
am: 3fe1ae29cd

Change-Id: Ib511f7af82c80fd4e95f4da9de1fdce200deb987
2017-11-03 23:07:03 +00:00
Jeff Sharkey
7c19a1abd6 Define NOT_ROAMING network capability.
The "roaming" state of a network really belongs on NetworkCapabilities
instead of being published through NetworkInfo.isRoaming().  One major
reason is to support developers creating NetworkRequests for a
non-roaming network.

Watch for any capability changes that network statistics are
interested in (either metered or roaming) and notify it to perform
an update pass; fixes bug where we previously only triggered on
roaming changes.

Fix bug in VPNs where metered/roaming capabilities of underlying
networks weren't being propagated; this was probably preventing
some jobs from running over unmetered networks, and causing other
jobs to run over roaming networks!  Also passes along link bandwidth
information from underlying networks, and propegates any changes
to underlying networks.

Fix race condition by reading prevNc inside lock.  Utility methods
correctly calculate min/max link bandwidth values.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.,com.android.server.ConnectivityServiceTest
Bug: 68397798, 16207332
Change-Id: I3e1a6544c902bf3a79356b72d3616af1fd2b0f49
2017-11-01 19:05:42 -06:00
Manoj Boopathi Raj
3794b5692e Merge "Fixed NullPointerException in IpSecService-Netd binder layer" am: bf74a93eb2
am: a096e8d177

Change-Id: I23ea94140ac3e34fc92fdc6a2c0d694396489e03
2017-10-27 18:06:09 +00:00
Manoj Boopathi Raj
8c302f08a9 Fixed NullPointerException in IpSecService-Netd binder layer
Replaced null with empty byte array in createTransportModeTransform
for null auth.getKey, crypt.getKey() and authCrypt.getKey()

Test: Ran CTS test
Bug: 68052730
Change-Id: I5110b1297b4bfbb5766e8ecfd3d64f8110b52945
2017-10-26 13:10:22 -07:00
Benedict Wong
26719cddc7 Merge "Return a port from bindToPort() in IpSecService" am: 1ce430a022
am: da8815017b

Change-Id: Ie59d496a38bf9775c1f40a543a24cb3fec5719bf
2017-10-24 16:54:57 +00:00
Benedict Wong
da8815017b Merge "Return a port from bindToPort() in IpSecService"
am: 1ce430a022

Change-Id: I51705d5db6af560f2423ef7861bfde6734632ec9
2017-10-24 16:44:59 +00:00
Benedict Wong
1ce430a022 Merge "Return a port from bindToPort() in IpSecService" 2017-10-24 16:31:21 +00:00
Benedict Wong
982cb0db7f Merge "Add support for AES-GCM-ESP as an IPSec algorithm" am: b6df7f0d35 am: cb2c14fc55
am: f92bfc3b77

Change-Id: I49932a5fc048b4a60512fac45a3537f050397168
2017-10-19 17:37:22 +00:00
Benedict Wong
cb2c14fc55 Merge "Add support for AES-GCM-ESP as an IPSec algorithm"
am: b6df7f0d35

Change-Id: Ic099206a28c4f21fa796969c953a8d4e81e8495b
2017-10-19 17:14:53 +00:00
Benedict Wong
c423cc8311 Return a port from bindToPort() in IpSecService
When binding to a random port, the port number was not being
returned, so the user is incorrectly receiving a port of zero.
Return the port number that was ultimately bound.

Bug: 67662580
Test: Ran CTS test on aosp_angler-eng
Change-Id: I22f4e5cdc83d43dc453788889990feb34e451bd3
2017-10-18 11:43:43 -07:00
Benedict Wong
53d60a2d24 Add support for AES-GCM-ESP as an IPSec algorithm
Allows native AES-GCM-ESP to be used as an IPSec transport/tunnel mode
algorithm with kernel support

Bug: 63589918
Test: IPsecService tests added, existing ones pass
Change-Id: Ie1a9a902be205f269aa37bf956198f2e5b177c21
2017-10-18 11:22:24 -07:00
nharold
2b71ef1fe2 Merge "Cosmetic Cleanups for IpSecService" am: 87d6fc04b2 am: ffb9ae2323
am: cc51ef0a47

Change-Id: I0a9c52ca26ad1b7e4505f7c9dc32ad9550b62afc
2017-10-05 01:07:53 +00:00
nharold
ffb9ae2323 Merge "Cosmetic Cleanups for IpSecService"
am: 87d6fc04b2

Change-Id: If47968dbd55f8f38f9e8dda4d78a0e2e41827da8
2017-10-05 00:44:37 +00:00
nharold
87d6fc04b2 Merge "Cosmetic Cleanups for IpSecService" 2017-10-05 00:14:16 +00:00
nharold
14f0da3e06 Merge changes from topic "ipsec-svc-cleanup" am: 9778c7884f am: 328365b5ed
am: 4e793fd0b5

Change-Id: Ib7eae5c9e223493281524e862979e16d25984dde
2017-10-04 20:53:04 +00:00
nharold
328365b5ed Merge changes from topic "ipsec-svc-cleanup"
am: 9778c7884f

Change-Id: Ide81ae76bd05ba3a2cc7c06c072306d30a489057
2017-10-04 20:24:10 +00:00
Nathan Harold
37b4cf3ecb Cosmetic Cleanups for IpSecService
This is a follow-up CL to address comments
on aosp/466677
-Rename ManagedResourceArray.get()
-Comment cleanup

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I6fbdd89c4a864fe1d8a19c68947f582d7b1f0f21
2017-10-04 13:04:55 -07:00
Nathan Harold
727fe3e941 Add equals() for IpSecAlgorithm and IpSecConfig
Add equality testing methods to support tests
for parceling and un-parceling IpSecConfig.

Bug: 38397094
Test: runtest -x IpSecConfigTest.java
Change-Id: I31e318334d39ed6e9daf5ec8f3be7dcec75e12ad
2017-10-03 19:45:58 -07:00
Nathan Harold
19b99d998a Input Validation for IpSecService
All of the input to IpSecService over the Binder
interface needs to be validated both for sanity
and for safety.

-Sanity check all the parameters coming from binder.
-Added setters for IpSecConfig to decouple the test
 from the IpSecManager. This was needed because the
 input validation caused the tests to fail due to a
 null parameter that was previously un-tested.
-Added the mode flag to the IpSecConfig bundle this
 oversight was found during testing.
-Expose the getResourceId() methods for testing in
 UdpEncapsulationSocket, SecurityParameterIndex, and
 IpSecTransform classes.
-Remove the unneeded getIpSecConfig() from
 IpSecTransform: unneeded now that we can synthesize
 configs.

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4
2017-10-03 19:45:55 -07:00
nharold
59872858db Merge changes from topic "re-enable-ipsec" am: 61cf7b284e am: 5a77657433
am: 80107540bb

Change-Id: I13a7134864a648aff9338fda044b3bffd653119e
2017-09-26 22:39:01 +00:00