From daa95ee120926ced237c37a5deea6a994b1f62e2 Mon Sep 17 00:00:00 2001 From: Edwin Wong Date: Tue, 21 Jun 2022 01:36:43 +0000 Subject: [Fix vulnerability] setSecurityLevel in clearkey Potential race condition in clearkey setSecurityLevel. POC test in http://go/ag/19083795 Test: sts-tradefed run sts-dynamic-develop -m StsHostTestCases -t android.security.sts.CVE_2022_2209#testPocCVE_2022_2209 Bug: 235601882 Change-Id: I6447fb539ef0cb395772c61e6f3e1504ccde331b Merged-In: I2e2084e85fe45d7d7f958c59b0063a477c7d24bf (cherry picked from commit 9bfc2fbcc4be68bc8939a10dd7942845dc724f75) Merged-In: I6447fb539ef0cb395772c61e6f3e1504ccde331b --- drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp | 2 ++ drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp index 32d7723715..e04dd7ef44 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp +++ b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp @@ -619,6 +619,7 @@ Return DrmPlugin::getSecurityLevel(const hidl_vec& sessionId, return Void(); } + Mutex::Autolock lock(mSecurityLevelLock); std::map, SecurityLevel>::iterator itr = mSecurityLevel.find(sid); if (itr == mSecurityLevel.end()) { @@ -691,6 +692,7 @@ Return DrmPlugin::setSecurityLevel(const hidl_vec& sessionId, return Status::ERROR_DRM_SESSION_NOT_OPENED; } + Mutex::Autolock lock(mSecurityLevelLock); std::map, SecurityLevel>::iterator itr = mSecurityLevel.find(sid); if (itr != mSecurityLevel.end()) { diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h index cb5c9fe5c1..10195202aa 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h +++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h @@ -414,7 +414,8 @@ private: std::map > mByteArrayProperties; std::map > mReleaseKeysMap; std::map, std::string> mPlaybackId; - std::map, SecurityLevel> mSecurityLevel; + std::map, SecurityLevel> mSecurityLevel + GUARDED_BY(mSecurityLevelLock); sp mListener; sp mListenerV1_2; SessionLibrary *mSessionLibrary; @@ -434,6 +435,7 @@ private: DeviceFiles mFileHandle; Mutex mSecureStopLock; + Mutex mSecurityLevelLock; CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin); }; -- cgit v1.2.3 From 5db434f877c33c351aef1bd391210815628ba6fb Mon Sep 17 00:00:00 2001 From: Wonsik Kim Date: Fri, 16 Sep 2022 17:29:42 -0700 Subject: FrameDecoder: fix 180 rotation for HDR thumbnails HDR thumbnails go through rendering pipeline, from which rotations are already applied. Thus the frame should have the rotation degree cleared to zero. Bug: 237497501 Test: manual Change-Id: I6dd0d8bdd06fecb4808c789ae99a678c7ebfa8e8 (cherry picked from commit b618eab62d168cc35acdcaff758e182c9e6f9f9d) Merged-In: I6dd0d8bdd06fecb4808c789ae99a678c7ebfa8e8 --- media/libstagefright/FrameDecoder.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/media/libstagefright/FrameDecoder.cpp b/media/libstagefright/FrameDecoder.cpp index 3df8766cfb..344456c757 100644 --- a/media/libstagefright/FrameDecoder.cpp +++ b/media/libstagefright/FrameDecoder.cpp @@ -86,11 +86,14 @@ sp allocVideoFrame(const sp& trackMeta, displayHeight = height; } - if (allocRotated && (rotationAngle == 90 || rotationAngle == 270)) { - int32_t tmp; - tmp = width; width = height; height = tmp; - tmp = displayWidth; displayWidth = displayHeight; displayHeight = tmp; - tmp = tileWidth; tileWidth = tileHeight; tileHeight = tmp; + if (allocRotated) { + if (rotationAngle == 90 || rotationAngle == 270) { + // swap width and height for 90 & 270 degrees rotation + std::swap(width, height); + std::swap(displayWidth, displayHeight); + std::swap(tileWidth, tileHeight); + } + // Rotation is already applied. rotationAngle = 0; } -- cgit v1.2.3