Merge "Return error from gatekeeperd" am: c51ed4c56e

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2590525

Change-Id: I02cd3ae596fce5a4d4e0f31e4cdafd4701c142ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Pawan Wagh 2023-05-16 23:57:50 +00:00 committed by Automerger Merge Worker
commit 2b26aadce6
2 changed files with 33 additions and 10 deletions

View file

@ -144,14 +144,22 @@ void GateKeeperProxy::clear_sid(uint32_t userId) {
}
}
uint32_t GateKeeperProxy::adjust_userId(uint32_t userId) {
Status GateKeeperProxy::adjust_userId(uint32_t userId, uint32_t* hw_userId) {
static constexpr uint32_t kGsiOffset = 1000000;
CHECK(userId < kGsiOffset);
CHECK((aidl_hw_device != nullptr) || (hw_device != nullptr));
if (is_running_gsi) {
return userId + kGsiOffset;
if (userId >= kGsiOffset) {
return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT);
}
return userId;
if ((aidl_hw_device == nullptr) && (hw_device == nullptr)) {
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
}
if (is_running_gsi) {
*hw_userId = userId + kGsiOffset;
return Status::ok();
}
*hw_userId = userId;
return Status::ok();
}
#define GK_ERROR *gkResponse = GKResponse::error(), Status::ok()
@ -201,7 +209,12 @@ Status GateKeeperProxy::enroll(int32_t userId,
android::hardware::hidl_vec<uint8_t> newPwd;
newPwd.setToExternal(const_cast<uint8_t*>(desiredPassword.data()), desiredPassword.size());
uint32_t hw_userId = adjust_userId(userId);
uint32_t hw_userId = 0;
Status result = adjust_userId(userId, &hw_userId);
if (!result.isOk()) {
return result;
}
uint64_t secureUserId = 0;
if (aidl_hw_device) {
// AIDL gatekeeper service
@ -300,7 +313,12 @@ Status GateKeeperProxy::verifyChallenge(int32_t userId, int64_t challenge,
}
}
uint32_t hw_userId = adjust_userId(userId);
uint32_t hw_userId = 0;
Status result = adjust_userId(userId, &hw_userId);
if (!result.isOk()) {
return result;
}
android::hardware::hidl_vec<uint8_t> curPwdHandle;
curPwdHandle.setToExternal(const_cast<uint8_t*>(enrolledPasswordHandle.data()),
enrolledPasswordHandle.size());
@ -410,7 +428,12 @@ Status GateKeeperProxy::clearSecureUserId(int32_t userId) {
}
clear_sid(userId);
uint32_t hw_userId = adjust_userId(userId);
uint32_t hw_userId = 0;
Status result = adjust_userId(userId, &hw_userId);
if (!result.isOk()) {
return result;
}
if (aidl_hw_device) {
aidl_hw_device->deleteUser(hw_userId);
} else if (hw_device) {

View file

@ -47,7 +47,7 @@ class GateKeeperProxy : public BnGateKeeperService {
// This should only be called on userIds being passed to the GateKeeper HAL. It ensures that
// secure storage shared across a GSI image and a host image will not overlap.
uint32_t adjust_userId(uint32_t userId);
Status adjust_userId(uint32_t userId, uint32_t* hw_userId);
#define GK_ERROR *gkResponse = GKResponse::error(), Status::ok()