Commit graph

57 commits

Author SHA1 Message Date
Subrahmanya Manikanta Venkateswarlu Bhamidipati Kameswara Sri
32e1c70f27 Check AServiceManager_isDeclared before AServiceManager_getService
Call AServiceManager_isDeclared before calling AServiceManager_getService
to avoid the waiting time when aidl service is not available.

Bug: 286969060
Test: run VtsHalGatekeeperTarget
Change-Id: I7d652a546cb810a601338a68950f01d065aea7a5
2023-06-14 02:43:54 +00:00
Pawan Wagh
d2d320ab0b Return error from gatekeeperd
Instead of crashing the gatekeeperd on incorrect
inputs to AIDL interface, return errors from the
service.

Test: m gatekeeperd, booted device
Bug: 279970163
Change-Id: Ifd3330e749f4ce147db5886f1f2dbb00c322bed2
2023-05-15 22:29:58 +00:00
Pawan Wagh
c5c0c3024c Separating GateKeeperProxy declaration in header
Adding gatekeeperd.h and moving declarations for GateKeeperProxy into
header. Adding separate main.cpp for entry point.
Adding cc_default to be used by binary and fuzzer.
This is needed in order to fuzz gatekeeperd AIDL service

Test: m gatekeeperd
Bug: N/A
Change-Id: Ifb2082f68bb200e4ed83608a6def8e45032753de
2023-04-25 23:27:00 +00:00
Eric Biggers
b4738b9e5d Avoid odd behavior when clearing nonexistent SID
It's expected that clearSecureUserId is sometimes called with a userId
that doesn't currently have a Gatekeeper enrollment.  For example, this
happens whenever a user with no LSKF is removed.  gatekeeperd currently
has two odd behaviors when it's asked to do this.  First, it logs the
following message at ERROR level, which is not appropriate:

    E gatekeeperd: clear_sid: could not remove file [No such file or directory], attempting 0 write

Second, it writes 0 to the file /data/misc/gatekeeper/$userId.  This
makes this file exist even after the user has been removed, which
doesn't cause a real problem but is unexpected.

Fix both of these issues by making clear_sid() check for ENOENT.

Bug: 188702845
Bug: 268526331
Change-Id: Ib1b110f2502267004f5c945c28c98ae926b2a794
2023-03-03 23:18:15 +00:00
Subrahmanyaman
355e97773a hidl2aidl: conversion of gatekeeper hidl to aidl
Conversion of the gatekeeper hidl interface to stable aidl interface.

Bug: 205760843
Test: run vts -m VtsHalGatekeeperTarget
Change-Id: I7ca82780b1f834f00c3708dea55ac6500cd08c9c
2022-09-19 16:39:27 +00:00
Janis Danisevskis
36ac55fef9 Keystore 2.0: Remove references to Keystore 1.0
Bug: 171305684
Test: N/A
Change-Id: I295728dba0a1dab2f8fd0e3c46cb0e239d1c72d7
2021-03-18 15:32:19 -07:00
Janis Danisevskis
8e0035c0cc Gatekeeper: Add missing user_id.
Auth tokens sent to keystore2 where missing the user id.

Test: Timeout bound keys can be authorized.
Change-Id: Ifd27d2d8c4e153d2e21460574a073516e276aae0
2021-02-11 23:16:58 -08:00
Janis Danisevskis
0357239d2f Fix Keystore 2.0 related bug in gatekeeperd.
Test: atest android.keystore.cts.CipherTest#testEmptyPlaintextEncryptsAndDecryptsWhenUnlockedRequired
Change-Id: Iec3d8aa34db040d5d4a418307020019ca32b0ffb
2021-01-29 23:47:18 -08:00
Hasini Gunasinghe
6fd560377f Integrate IKeystoreAuthorization aidl's addAuthToken with gatekeeperd.
Bug: 166672367
Bug: 177830239
Bug: 177791435
Bug: 177787061
Bug: 177787180
Test: VTS test
Change-Id: I15b751ec993a240756e58c2df3352c544bced517
2021-01-19 14:42:33 +00:00
Louis Chang
4c66b8a35c Revert "Integrate IKeystoreAuthorization aidl's addAuthToken wit..."
Revert "Implement addAuthToken method of IKeystoreAuthorization ..."

Revert "Integrate IKeystoreAuthorization aidl's addAuthToken wit..."

Revert submission 1519257-rename_auth_service

Reason for revert: breaking WM presubmit, b/177787180
Reverted Changes:
Ib847b68d4:Integrate IKeystoreAuthorization aidl's addAuthTok...
I7893ab452:Integrate IKeystoreAuthorization aidl's addAuthTok...
I4a092119c:Implement addAuthToken method of IKeystoreAuthoriz...

Change-Id: Icc48050a127fa3a931cb0b591db8165384e2fe25
2021-01-18 10:01:12 +00:00
Hasini Gunasinghe
701fbca843 Integrate IKeystoreAuthorization aidl's addAuthToken with gatekeeperd.
Bug: 166672367
Test: VTS test

Change-Id: Ib847b68d4ab6fe4265c8b8aa5268db7c058b3629
2021-01-07 10:51:30 -08:00
Janis Danisevskis
0a738d9504 Chanage uid to userId where it denotes an Android user id.
This patch changes the variable name `uid` to `userId` where it
denotes an Android user id. This makes it harder to mistake the user id
for an actual UID.

Test: Trivial refactoring no logical changes.
Bug: 163636858
Change-Id: I9e240367bcd30bbfa1816014a7f44bbcb58ede4b
2020-09-23 18:01:37 -07:00
Jooyung Han
57110a4752 Use optional for nullable types
AIDL generates optional<T> for nullable T types for C++, which is more
efficient and idomatic and easy to use.

Bug: 144773267
Test: build/flash/boot
Merged-In: I6bf4c2017f113f4d326fddb1d76163c2fed34d50
Change-Id: I6bf4c2017f113f4d326fddb1d76163c2fed34d50
(cherry picked from commit 5f7f450fa38e752ae49ae91b1bdaf267ec9deea5)
2020-02-24 09:31:47 +09:00
Janis Danisevskis
3a1eb672c5 Gatekeeperd maintenance
* Move gatekeeper aidl definition to system/core/gatekeeperd
  * Retire hand written IGateKeeperService and use generated instead
  * Adjust gatekeeperd to use the generated aidl stubs.
  * Annotated enroll parameters with @nullable to match the
    documentation and the way it was used. (The hand written
    code was tolerant to null parameters, but it was undefined behavior.)
* Removed Software implementation from gatekeeperd.
  * Also removed the upgrade path.
  * Software implementation including test moved to
    hardware/interfaces/gatekeeper/1.0/software

Change-Id: I72b734db6f67b79b29c2629764490d75d179908a
Merged-In: I72b734db6f67b79b29c2629764490d75d179908a
Test: Manually tested setting pin and login.
2019-06-23 11:09:30 -07:00
David Anderson
97400bd865 Use distinct GateKeeper userids when running a GSI.
GateKeeper uses userids to key authentication data. This poses a problem
for GSIs, since both the GSI and the host image will be storing separate
authentication data for the same userids.

To account for this, we add a large offset (1000000) to GSI userids
before handing them off to the GateKeeper HAL. Note that
SyntheticPasswordManager uses a similar trick to store Weaver data in
GateKeeper (when a Weaver HAL is not available).

Bug: 123716647
Test: PIN authentication works after booting into a GSI
Change-Id: I714368919f8e46ff1931f350342f09fa09225a35
2019-02-28 08:56:30 -08:00
Janis Danisevskis
ea893985be Multi-threaded Keystore
Reflect that IKeystoreInterface was moved to keystore namespace.

Bug: 111443219
Change-Id: Idfc4d584686aa50853ef6f6effcdd670d7e818a5
2018-11-07 11:39:23 -08:00
Elliott Hughes
643268f325 Move system/core/ off NO_ERROR.
It causes trouble for Windows, and OK already exists.

Bug: N/A
Test: builds
Change-Id: Ida22fd658b0ebb259c710ba39049b07c9e495d9c
2018-10-08 11:15:52 -07:00
Kihyung Lee
1729875503 Merge "Fix memory leak when GateKeeperProxy.verify() returns"
am: 855a643d3a

Change-Id: Ic6f852f970b60bc5b86da19ae050c78893fa8f94
2018-06-26 08:31:27 -07:00
Kihyung Lee
d9ad02e3e0 Fix memory leak when GateKeeperProxy.verify() returns
After verify() calls verifyChallenge(), the caller acquires the ownership of
returned memory block pointed by *auth_token.
However, the current implementation directly returns and lost the reference
of auth_token without freeing it from heap memory.

This patch solves this problem by explicitly deleting the auth_token array.

Change-Id: I6cfe8427174aa36fbb208e2fff8904095f468ec6
2018-06-18 11:05:42 +09:00
Brian Young
388ff6bb7b Revert "Restore "Add UID parameter to authentication token""
This reverts commit 9e62f3ee11.

Reason for revert: Regression in creating auth-bound keys

Bug: 73773914

Bug: 67752510

Change-Id: Ibde9aefffbaab9b85deb95ae2fdf9e0db6d1e992
2018-02-23 01:31:12 +00:00
Brian C. Young
9e62f3ee11 Restore "Add UID parameter to authentication token"
The keystore/keymaster changes to prevent some keys from being used
while the screen is locked require passing Android user IDs as well as
keymaster secure IDs.

This reverts commit 16b8434935.

Test: CTS tests in I8a5affd1eaed176756175158e3057e44934fffed

Bug: 67752510

Change-Id: Ie09855813092a38fff80c913c9c8f8228aa4c95b
2018-02-15 11:28:59 -08:00
Brian Young
16b8434935 Revert "Add UID parameter to authentication token"
This reverts commit 58ce81349a.

Reason for revert: Build breakages on elfin, gce_x86_phone.

Bug: 72679761
Bug: 67752510
Change-Id: Ia27d6a7aa0195e49d0f132e7b77c81d780248a4c
2018-01-30 15:31:32 +00:00
Brian C. Young
58ce81349a Add UID parameter to authentication token
The keystore/keymaster changes to prevent some keys from being used
while the screen is locked require passing Android user IDs as well as
keymaster secure IDs.

Test: go/asym-write-test-plan

Bug: 67752510

Change-Id: I07bfad82775025f8cf66004e46387d1354ef6575
2018-01-25 10:33:42 -08:00
Dmitry Dementyev
0dd259cf78 Get rid of manually created IKeystoreService in gatekeeper.cpp
Bug:68389643
Test: manual
Change-Id: I2c1404f4c6597e63bc0a360a7bf598e35585b30e
2017-11-14 16:15:44 -08:00
Justin Yun
68b0ec6487 gatekeeperd: use std::unique_ptr
std::unique_ptr is available in this scope. Substitue the UniquePtr to
std::unique_ptr.

Bug: 63686260
Test: build and boot
Change-Id: Ib8ea3fb5c49c0e92d962f65f1139b073168f8698
2017-08-17 14:58:23 +09:00
Pavel Grafov
9890f89ca2 Don't look up parent user SID.
This is a revert of http://ag/741442

Every user now has their own SID, so there is no need to look up
profile parent anymore.

Bug: 38259874
Test: manual, using ConfirmCredential sample app in work profile.
Test: manual, making sure keys survive N->O-MR1 upgrade.
Change-Id: Ib2f52baeb7c5bfeec95431fccfd6ddd537019954
2017-06-28 20:38:33 +01:00
Adrian Roos
cb4ed1bdb9 Credential FRP: keep gatekeeperd credentials after reset
Gatekeeperd now delays clearing all user credentials
until the device setup is complete or we enroll a new
credential (whichever comes first).

Bug: 36814845
Test: Set lockscreen credential, "adb reboot-bootloader && fastboot -w", "adb shell am start -a android.app.action.CONFIRM_FRP_CREDENTIAL", verify that credential still works
Change-Id: If2ad78ff5b80a6ddffd997be0949b03ed11797f4
2017-04-18 20:50:52 +00:00
Chris Phoenix
a84ce0c581 gatekeeper HAL uses "default" service name
The getService() and registerAsService() methods of interface objects
now have default parameters of "default" for the service name. HALs
will not have to use any service name unless they want to register
more than one service.

Test: builds

Bug: 33844934
Change-Id: Ie49c8cea290d328b2160f6012e7c143c49d535cc
2017-02-23 19:31:59 +00:00
Janis Danisevskis
72030fb7bc Adjust for small changes in the native keystore interface
Test: compiled and run on bullhead device
Bug: 32020919
Change-Id: I8352b87be090ba756e3a6ea51cd691cd5594e8f7
2017-01-19 05:32:34 -07:00
Mark Salyzyn
271a1a7cda resolve merge conflicts of a45b1d6f3 to master
Test: compile
Bug: 30465923
Change-Id: I648855539df3cfa176c6ecac19b6a562ba6feaf7
2017-01-11 11:41:38 -08:00
Mark Salyzyn
a45b1d6f38 Merge "liblog: use log/log.h when utilizing ALOG macros" am: 01e12b4ee7 am: c3b346ea93
am: 5482cb01b2

Change-Id: Ifaf21912d44f6ee9fda06df255ba3f7a4ca26ed7
2017-01-11 19:26:19 +00:00
Mark Salyzyn
30f991f251 liblog: use log/log.h when utilizing ALOG macros
Test: compile
Bug: 30465923
Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
2017-01-11 09:31:15 -08:00
Steven Moreland
a1538906ac Merge "Return<*> getStatus().isOk() -> isOk()" 2017-01-04 23:46:52 +00:00
Alexey Polyudov
48e00f7470 gatekeeperd: protect from invalid data passed by HAL am: 8c63536ded
am: 563ed1672f

Change-Id: I524b468ef7d54444feaceacbcdc66861a1cada0c
2017-01-04 03:33:20 +00:00
Alexey Polyudov
563ed1672f gatekeeperd: protect from invalid data passed by HAL
am: 8c63536ded

Change-Id: Ie020281e63504ea0b9f27e9e36433d3e137ae018
2017-01-04 03:31:20 +00:00
Steven Moreland
813309326b Return<*> getStatus().isOk() -> isOk()
Bug: 31348667
Test: compiles
Change-Id: I44d89e45c8bf8bcd7a47dff1f5cd4d454c95a079
2017-01-03 17:05:26 -08:00
Alexey Polyudov
8c63536ded gatekeeperd: protect from invalid data passed by HAL
Bug: 31349112
Change-Id: I6c0656f85e44054147f8795c98baab7a98f575b9
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
2016-12-21 14:55:29 +00:00
Alexey Polyudov
275aece609 Use HIDL-generated HAL interworking code
Change-Id: Ide455f8e8bba8b7f403cc7a8971848c11d3b37a8
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
2016-11-21 14:05:04 -08:00
Mark Salyzyn
66ce3e08c5 system/core Replace cutils/log.h with android/log.h
Should use android/log.h instead of cutils/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I2c9cbbbd64d8dccf2d44356361d9742e4a9b9031
2016-09-30 12:47:05 -07:00
George Burgess IV
e7aa2b2c83 Cleanup uses of sprintf so we can deprecate it.
Also cleans up two instances of open() with useless mode params, and
changes a few uses of snprintf to use sizeof(buffer) instead of
hardcoded buffer sizes.

Change-Id: If11591003d910c995e72ad8f75afd072c255a3c5
2016-03-07 18:40:40 -08:00
Andres Morales
1cf7d259e8 [gatekeeperd] Check parent profile for SID lookups
Bug: 22257554
Change-Id: I1a363729b449a2bc8594b48dada719fd79da7036
2015-08-05 10:32:13 -07:00
Andres Morales
787c3764d3 Merge "[gatekeeperd] fix use of uninitialized memory" into mnc-dev 2015-07-10 17:20:31 +00:00
Andres Morales
0b0435ea87 [gatekeeperd] fix file descriptor leak
Bug: 22403703
Change-Id: I65da3b3b3f85db035d79277344beb5460cb025f2
2015-07-10 09:47:09 -07:00
Andres Morales
fef908e5a5 [gatekeeperd] fix use of uninitialized memory
Bug: 22319772
Change-Id: I3cb83389f11e54867aca132de48a3f6407b7eaf3
2015-07-08 20:33:36 +00:00
Andres Morales
7f6dcf6576 [gatekeeperd] fix issue with SW->HW upgrades
If the handle version is 0, there's no hardware_backed flag
meaning hardware backed handles will be attempted against
the soft impl. Ensure we don't try to read from hardware_backed
unless the version is > 0.

Bug: 21090356
Change-Id: I65f009c55538ea3c20eb486b580eb11ce93934fc
2015-06-24 18:40:24 -07:00
Andres Morales
3c2086dabd [gatekeeperd] clear state and mark on cold boot
required to initialize state by certain HAL impls

Bug: 22011857
Change-Id: Ibb01a799da983e1a930aae946c331b23f571861d
2015-06-24 10:22:45 -07:00
Andres Morales
835d96eae5 [gatekeeperd] handle upgrades from software version to HAL
Certain devices, like Shamu, are currently running an interim
software-only gatekeeper. When the HAL for those devices is merged,
we need to handle upgrading to the HAL smoothly.

Bug: 21090356
Change-Id: I5352bc547a43671a08249eae532e8b3ce6b90087
2015-06-22 13:12:41 -07:00
Andres Morales
531e3e83c2 [gatekeeperd] verify a password after enrolling successfully
Bug: 20918106
Change-Id: Ia3cb6d1375d9ee2a6e543ee97d37b7c4f0459447
2015-06-02 10:43:21 -07:00
Andres Morales
ae242929da [gatekeeperd] return brute-force throttling information
Bug: 21118563
Change-Id: I13c6a44f61668be8b4c1fde8c84dcfebab84517c
2015-05-27 07:45:22 -07:00
Andres Morales
33dfdc7bbc Move SoftGateKeeper into gatekeeperd
Allows for easy determination of whether there's a
hardware module in place. Permits tighter coupling of
software implementation with upper-level stack.

Bug:21090356
Change-Id: I275b57cd976c233c43c476c5869c5a4b29fbc175
2015-05-14 12:58:13 -07:00