From 2c56d5414b33665fa6036725ac82e985a96f2518 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 27 Jul 2022 17:46:59 +0000 Subject: [PATCH] Destroy old LSKF-based protector in setLockCredentialWithSpLocked() Destroying the old LSKF-based protector is a core part of changing the LSKF, so do it directly in setLockCredentialWithSpLocked() rather than duplicating it in both callers. No change in behavior. Change-Id: Ie4f893f2e9aacf3d3c17dd615929ad6dded8db21 --- .../android/server/locksettings/LockSettingsService.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index 884ae171ba5f2..804315cddabd3 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -1626,7 +1626,6 @@ public class LockSettingsService extends ILockSettings.Stub { onSyntheticPasswordKnown(userId, sp); setLockCredentialWithSpLocked(credential, sp, userId); - mSpManager.destroyLskfBasedProtector(oldProtectorId, userId); sendCredentialsOnChangeIfRequired(credential, userId, isLockTiedToParent); return true; } @@ -2642,8 +2641,7 @@ public class LockSettingsService extends ILockSettings.Stub { /** * Changes the user's LSKF by creating an LSKF-based protector that uses the new LSKF (which may - * be empty) and setting the new protector as the user's current LSKF-based protector. The old - * LSKF-based protector is not destroyed, and the SP itself is not changed. + * be empty) and replacing the old LSKF-based protector with it. The SP itself is not changed. * * Also maintains the invariants described in {@link SyntheticPasswordManager} by * setting/clearing the protection (by the SP) on the user's file-based encryption key and @@ -2655,6 +2653,7 @@ public class LockSettingsService extends ILockSettings.Stub { SyntheticPassword sp, int userId) { if (DEBUG) Slog.d(TAG, "setLockCredentialWithSpLocked: user=" + userId); final int savedCredentialType = getCredentialTypeInternal(userId); + final long oldProtectorId = getCurrentLskfBasedProtectorId(userId); final long newProtectorId = mSpManager.createLskfBasedProtector(getGateKeeperService(), credential, sp, userId); final Map profilePasswords; @@ -2700,7 +2699,7 @@ public class LockSettingsService extends ILockSettings.Stub { entry.getValue().zeroize(); } } - + mSpManager.destroyLskfBasedProtector(oldProtectorId, userId); return newProtectorId; } @@ -2934,9 +2933,7 @@ public class LockSettingsService extends ILockSettings.Stub { return false; } onSyntheticPasswordKnown(userId, result.syntheticPassword); - final long oldProtectorId = getCurrentLskfBasedProtectorId(userId); setLockCredentialWithSpLocked(credential, result.syntheticPassword, userId); - mSpManager.destroyLskfBasedProtector(oldProtectorId, userId); return true; }