From c4abbe64271bb1b4181fe057d9d6032d594d8917 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Wed, 20 Jan 2021 13:19:13 -0800 Subject: [PATCH] trusty: keymaster-hal: Reconnect on failed VERSION Trusty Keymaster will currently disconnect the client on an invalid message. This includes the newly introduced GET_VERSION2 message. While in the future we could change this behavior, this is a backcompat path and so we can't assume a changed Trusty. Reconnect on failed GET_VERSION2 before attempting version negotiation. Bug: 177843218 Test: Set PIN on device using older Trusty Change-Id: Ie60e4aaafa43e375797e6288b97834cac42413f4 --- trusty/keymaster/TrustyKeymaster.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trusty/keymaster/TrustyKeymaster.cpp b/trusty/keymaster/TrustyKeymaster.cpp index 569003129..23e04334c 100644 --- a/trusty/keymaster/TrustyKeymaster.cpp +++ b/trusty/keymaster/TrustyKeymaster.cpp @@ -37,6 +37,12 @@ int TrustyKeymaster::Initialize() { if (versionRsp.error != KM_ERROR_OK) { ALOGW("TA appears not to support GetVersion2, falling back (err = %d)", versionRsp.error); + err = trusty_keymaster_connect(); + if (err) { + ALOGE("Failed to connect to trusty keymaster %d", err); + return err; + } + GetVersionRequest versionReq; GetVersionResponse versionRsp; GetVersion(versionReq, &versionRsp);