Commit 420e9a82 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

Fix using |delayed_login_failure_| after free.

AuthFailure was remembered in OnAuthFailure() by a pointer and was
freed after that leading to strange failure reason on next read.
It was introduced 5 years ago in https://crrev.com/22900017

[719:719:0918/112724.240220:ERROR:auth_status_consumer.h(95)] NOTREACHED() hit.  [Reason: info:NOTREACHED()]
[719:719:0918/112724.240293:ERROR:device_event_log_impl.cc(159)] [11:27:24.240] Login: cryptohome_authenticator.cc:725 Login failed:
[719:719:0918/112724.240371:ERROR:login_performer.cc(63)] Login failure, reason=0, error.state=0
[719:719:0918/112724.240414:ERROR:kiosk_profile_loader.cc(202)] NOTREACHED() hit.  [Reason: info:NOTREACHED()]
[719:719:0918/112724.240458:ERROR:auth_status_consumer.h(95)] NOTREACHED() hit.  [Reason: info:NOTREACHED()]
[719:719:0918/112724.240445:ERROR:kiosk_profile_loader.cc(188)] Kiosk auth failure: error=
[719:719:0918/112724.240674:ERROR:kiosk_profile_loader.cc(50)] NOTREACHED() hit.  [Reason: info:NOTREACHED()]
[719:719:0918/112724.240732:ERROR:app_launch_controller.cc(526)] Kiosk launch failed, error=4

Bug: 885346
Change-Id: I46ca3b3630aa42e25a25d9cfecb3a16e3c361b9f
Reviewed-on: https://chromium-review.googlesource.com/1236265Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592830}
parent f9ca155c
......@@ -540,7 +540,7 @@ CryptohomeAuthenticator::CryptohomeAuthenticator(
owner_is_verified_(false),
user_can_login_(false),
remove_user_data_on_failure_(false),
delayed_login_failure_(NULL) {}
delayed_login_failure_(AuthFailure::NONE) {}
void CryptohomeAuthenticator::AuthenticateToLogin(
content::BrowserContext* context,
......@@ -737,7 +737,7 @@ void CryptohomeAuthenticator::OnAuthFailure(const AuthFailure& error) {
// OnAuthFailure will be called again with the same |error|
// after the cryptohome has been removed.
if (remove_user_data_on_failure_) {
delayed_login_failure_ = &error;
delayed_login_failure_ = error;
RemoveEncryptedData();
return;
}
......@@ -861,7 +861,7 @@ void CryptohomeAuthenticator::Resolve() {
remove_user_data_on_failure_ = false;
task_runner_->PostTask(
FROM_HERE, base::BindOnce(&CryptohomeAuthenticator::OnAuthFailure,
this, *delayed_login_failure_));
this, delayed_login_failure_));
break;
case CREATE_NEW:
create_if_nonexistent = true;
......
......@@ -274,7 +274,7 @@ class CHROMEOS_EXPORT CryptohomeAuthenticator
// When |remove_user_data_on_failure_| is set, we delay calling
// consumer_->OnAuthFailure() until we removed the user cryptohome.
const AuthFailure* delayed_login_failure_;
AuthFailure delayed_login_failure_;
DISALLOW_COPY_AND_ASSIGN(CryptohomeAuthenticator);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment