Reset crypto session pointers on RemoveKeys.

[ Merge of http://go/wvgerrit/189590 ]
[ Cherry-pick of http://ag/26541307 ]

The CDM session shares its CryptoSession instance with a few additional
member objects (CdmLicense and PolicyEngine).  When the CDM session's
crypto session is reset, it must also reset the CdmLicense and
PolicyEngine otherwise, a potential stale pointer reference may occur.

Test: request_license_test on Oriole
Test: run_x86_64_tests
Bug: 311239278
Change-Id: Ie175513ae652dcd96e12e5e1def574a8a56d5863
This commit is contained in:
Alex Dale
2024-03-11 15:19:21 -07:00
parent 5c175ad151
commit b1fad7f4cb
11 changed files with 182 additions and 75 deletions

View File

@@ -265,6 +265,8 @@ class CdmSession {
bool HasRootOfTrustBeenRenewed();
CdmResponseType ResetCryptoSession();
// These setters are for testing only. Takes ownership of the pointers.
void set_license_parser(CdmLicense* license_parser);
void set_crypto_session(CryptoSession* crypto_session);
@@ -340,8 +342,9 @@ class CdmSession {
bool has_license_been_loaded_ = false;
bool has_license_been_restored_ = false;
bool mock_license_parser_in_use_;
bool mock_policy_engine_in_use_;
bool mock_crypto_session_in_use_ = false;
bool mock_license_parser_in_use_ = false;
bool mock_policy_engine_in_use_ = false;
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
};

View File

@@ -90,6 +90,15 @@ class CdmLicense {
const CdmKeyResponse& license_response,
std::string* provider_session_token);
// Testing only. Caller retains ownership of pointers.
void set_crypto_session(CryptoSession* crypto_session) {
crypto_session_ = crypto_session;
}
void set_policy_engine(PolicyEngine* policy_engine) {
policy_engine_ = policy_engine;
}
private:
CdmResponseType HandleKeyErrorResponse(
const video_widevine::SignedMessage& signed_message);
@@ -131,8 +140,8 @@ class CdmLicense {
bool SetTypeAndId(CdmLicenseType license_type, const std::string& request_id,
T* content_id);
CryptoSession* crypto_session_;
PolicyEngine* policy_engine_;
CryptoSession* crypto_session_ = nullptr;
PolicyEngine* policy_engine_ = nullptr;
std::string server_url_;
std::string client_token_;
const CdmSessionId session_id_;

View File

@@ -106,6 +106,8 @@ class PolicyEngine {
virtual const LicenseIdentification& license_id() { return license_id_; }
WvCdmEventListener* event_listener() { return event_listener_; }
bool GetSecondsSinceStarted(int64_t* seconds_since_started);
bool GetSecondsSinceLastPlayed(int64_t* seconds_since_started);
@@ -131,6 +133,11 @@ class PolicyEngine {
return license_keys_->MeetsConstraints(key_id);
}
// Testing only. Caller retains ownership.
void set_crypto_session(CryptoSession* crypto_session) {
crypto_session_ = crypto_session;
}
private:
friend class PolicyEngineTest;
friend class PolicyEngineConstraintsTest;

View File

@@ -945,6 +945,8 @@ const char* IdToString(const std::string& id);
// provided as string pointers.
const char* IdPtrToString(const std::string* id);
const char* BoolToString(bool value);
// Logging utilities for OEMCrypto types.
const char* OemCryptoResultToString(OEMCryptoResult result);
} // namespace wvcdm