Skip to content

Commit 04a4e03

Browse files
haggertkvarund7726
authored andcommitted
Merge tag 'android-10.0.0_r37' into staging/lineage-17.1_merge-android-10.0.0_r37
Android 10.0.0 Release 37 (QQ3A.200605.001) * tag 'android-10.0.0_r37': (47 commits) RESTRICT AUTOMERGE: Camera: fix use after free in sensor timestamp keep tx3g{Buffer,Size,Filled} in sync Fix race condition in AudioTrack::releaseBuffer() Fix race condition in AudioRecord::releaseBuffer() rtsp: fix integer overflow caused by malformed packets IDrm: fix uninitialized variable in GET_OFFLINE_LICENSE_STATE audio policy: fix disordered sequence while changing device RESTRICT AUTOMERGE: Camera: fix use after free in sensor timestamp RESTRICT AUTOMERGE: Camera: fix use after free in sensor timestamp BnCrypto: fix use-before-init in CREATE_PLUGIN Camera: Add onCameraOpened/onCameraClosed callbacks [DO NOT MERGE] Fix Heap use after free in clearkey getSecureStops Check if calling uid is system uid for setAllowedPolicyCapture. clearkey default: parsePssh securely RESTRICT AUTOMERGE CCodec: make config consistent before/after flush Reduce the latecy of encoding 1st frame [media][sfplugin] fix -Wdangling-gsl [DO NOT MERGE] Fix uninitialized data in IHDCP decrypt OpusHeader: Fix integer overflow in GetOpusHeaderBuffers MPEG4Extractor: check the default sample info before checking the validity of sample size. ... Change-Id: Ibb33de8b4828ed99095af7d629ffc290c188e10d Signed-off-by: Varun Date <[email protected]>
1 parent 1863aa9 commit 04a4e03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+769
-306
lines changed

camera/aidl/android/hardware/ICameraServiceListener.aidl

+8
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,12 @@ interface ICameraServiceListener
8383
* can retry after receiving this callback.
8484
*/
8585
oneway void onCameraAccessPrioritiesChanged();
86+
87+
/**
88+
* Notify registered clients about cameras being opened/closed.
89+
* Only clients with android.permission.CAMERA_OPEN_CLOSE_LISTENER permission
90+
* will receive such callbacks.
91+
*/
92+
oneway void onCameraOpened(String cameraId, String clientPackageId);
93+
oneway void onCameraClosed(String cameraId);
8694
}

camera/ndk/impl/ACameraManager.h

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ class CameraManagerGlobal final : public RefBase {
9292
}
9393

9494
virtual binder::Status onCameraAccessPrioritiesChanged();
95+
virtual binder::Status onCameraOpened(const String16&, const String16&) {
96+
return binder::Status::ok();
97+
}
98+
virtual binder::Status onCameraClosed(const String16&) {
99+
return binder::Status::ok();
100+
}
95101

96102
private:
97103
const wp<CameraManagerGlobal> mCameraManager;

camera/tests/CameraBinderTests.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ class TestCameraServiceListener : public hardware::BnCameraServiceListener {
9595
return binder::Status::ok();
9696
}
9797

98+
virtual binder::Status onCameraOpened(const String16& /*cameraId*/,
99+
const String16& /*clientPackageName*/) {
100+
// No op
101+
return binder::Status::ok();
102+
}
103+
104+
virtual binder::Status onCameraClosed(const String16& /*cameraId*/) {
105+
// No op
106+
return binder::Status::ok();
107+
}
108+
98109
bool waitForNumCameras(size_t num) const {
99110
Mutex::Autolock l(mLock);
100111

drm/libmediadrm/IDrm.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ status_t BnDrm::onTransact(
10711071
Vector<uint8_t> keySetId;
10721072
readVector(data, keySetId);
10731073
DrmPlugin::OfflineLicenseState state;
1074+
state = DrmPlugin::OfflineLicenseState::kOfflineLicenseStateUnknown;
10741075
status_t result = getOfflineLicenseState(keySetId, &state);
10751076
reply->writeInt32(static_cast<DrmPlugin::OfflineLicenseState>(state));
10761077
reply->writeInt32(result);

drm/mediadrm/plugins/clearkey/default/InitDataParser.cpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,21 @@ android::status_t InitDataParser::parse(const Vector<uint8_t>& initData,
7676

7777
android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
7878
Vector<const uint8_t*>* keyIds) {
79+
// Description of PSSH format:
80+
// https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html
7981
size_t readPosition = 0;
8082

81-
// Validate size field
8283
uint32_t expectedSize = initData.size();
84+
const char psshIdentifier[4] = {'p', 's', 's', 'h'};
85+
const uint8_t psshVersion1[4] = {1, 0, 0, 0};
86+
uint32_t keyIdCount = 0;
87+
size_t headerSize = sizeof(expectedSize) + sizeof(psshIdentifier) +
88+
sizeof(psshVersion1) + kSystemIdSize + sizeof(keyIdCount);
89+
if (initData.size() < headerSize) {
90+
return android::ERROR_DRM_CANNOT_HANDLE;
91+
}
92+
93+
// Validate size field
8394
expectedSize = htonl(expectedSize);
8495
if (memcmp(&initData[readPosition], &expectedSize,
8596
sizeof(expectedSize)) != 0) {
@@ -88,15 +99,13 @@ android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
8899
readPosition += sizeof(expectedSize);
89100

90101
// Validate PSSH box identifier
91-
const char psshIdentifier[4] = {'p', 's', 's', 'h'};
92102
if (memcmp(&initData[readPosition], psshIdentifier,
93103
sizeof(psshIdentifier)) != 0) {
94104
return android::ERROR_DRM_CANNOT_HANDLE;
95105
}
96106
readPosition += sizeof(psshIdentifier);
97107

98108
// Validate EME version number
99-
const uint8_t psshVersion1[4] = {1, 0, 0, 0};
100109
if (memcmp(&initData[readPosition], psshVersion1,
101110
sizeof(psshVersion1)) != 0) {
102111
return android::ERROR_DRM_CANNOT_HANDLE;
@@ -110,12 +119,14 @@ android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
110119
readPosition += kSystemIdSize;
111120

112121
// Read key ID count
113-
uint32_t keyIdCount;
114122
memcpy(&keyIdCount, &initData[readPosition], sizeof(keyIdCount));
115123
keyIdCount = ntohl(keyIdCount);
116124
readPosition += sizeof(keyIdCount);
117-
if (readPosition + ((uint64_t)keyIdCount * kKeyIdSize) !=
118-
initData.size() - sizeof(uint32_t)) {
125+
126+
uint64_t psshSize = 0;
127+
if (__builtin_mul_overflow(keyIdCount, kKeyIdSize, &psshSize) ||
128+
__builtin_add_overflow(readPosition, psshSize, &psshSize) ||
129+
psshSize != initData.size() - sizeof(uint32_t) /* DataSize(0) */) {
119130
return android::ERROR_DRM_CANNOT_HANDLE;
120131
}
121132

drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void DrmPlugin::initProperties() {
111111
// The content in this secure stop is implementation dependent, the clearkey
112112
// secureStop does not serve as a reference implementation.
113113
void DrmPlugin::installSecureStop(const hidl_vec<uint8_t>& sessionId) {
114+
Mutex::Autolock lock(mSecureStopLock);
115+
114116
ClearkeySecureStop clearkeySecureStop;
115117
clearkeySecureStop.id = uint32ToVector(++mNextSecureStopId);
116118
clearkeySecureStop.data.assign(sessionId.begin(), sessionId.end());
@@ -744,6 +746,7 @@ Return<void> DrmPlugin::getOfflineLicenseState(const KeySetId& keySetId,
744746
}
745747

746748
Return<void> DrmPlugin::getSecureStops(getSecureStops_cb _hidl_cb) {
749+
mSecureStopLock.lock();
747750
std::vector<SecureStop> stops;
748751
for (auto itr = mSecureStops.begin(); itr != mSecureStops.end(); ++itr) {
749752
ClearkeySecureStop clearkeyStop = itr->second;
@@ -755,26 +758,32 @@ Return<void> DrmPlugin::getSecureStops(getSecureStops_cb _hidl_cb) {
755758
stop.opaqueData = toHidlVec(stopVec);
756759
stops.push_back(stop);
757760
}
761+
mSecureStopLock.unlock();
762+
758763
_hidl_cb(Status::OK, stops);
759764
return Void();
760765
}
761766

762767
Return<void> DrmPlugin::getSecureStop(const hidl_vec<uint8_t>& secureStopId,
763768
getSecureStop_cb _hidl_cb) {
764-
SecureStop stop;
769+
std::vector<uint8_t> stopVec;
770+
771+
mSecureStopLock.lock();
765772
auto itr = mSecureStops.find(toVector(secureStopId));
766773
if (itr != mSecureStops.end()) {
767774
ClearkeySecureStop clearkeyStop = itr->second;
768-
std::vector<uint8_t> stopVec;
769775
stopVec.insert(stopVec.end(), clearkeyStop.id.begin(), clearkeyStop.id.end());
770776
stopVec.insert(stopVec.end(), clearkeyStop.data.begin(), clearkeyStop.data.end());
777+
}
778+
mSecureStopLock.unlock();
771779

780+
SecureStop stop;
781+
if (!stopVec.empty()) {
772782
stop.opaqueData = toHidlVec(stopVec);
773783
_hidl_cb(Status::OK, stop);
774784
} else {
775785
_hidl_cb(Status::BAD_VALUE, stop);
776786
}
777-
778787
return Void();
779788
}
780789

@@ -787,10 +796,12 @@ Return<Status> DrmPlugin::releaseAllSecureStops() {
787796
}
788797

789798
Return<void> DrmPlugin::getSecureStopIds(getSecureStopIds_cb _hidl_cb) {
799+
mSecureStopLock.lock();
790800
std::vector<SecureStopId> ids;
791801
for (auto itr = mSecureStops.begin(); itr != mSecureStops.end(); ++itr) {
792802
ids.push_back(itr->first);
793803
}
804+
mSecureStopLock.unlock();
794805

795806
_hidl_cb(Status::OK, toHidlVec(ids));
796807
return Void();
@@ -856,13 +867,17 @@ Return<Status> DrmPlugin::releaseSecureStops(const SecureStopRelease& ssRelease)
856867
}
857868

858869
Return<Status> DrmPlugin::removeSecureStop(const hidl_vec<uint8_t>& secureStopId) {
870+
Mutex::Autolock lock(mSecureStopLock);
871+
859872
if (1 != mSecureStops.erase(toVector(secureStopId))) {
860873
return Status::BAD_VALUE;
861874
}
862875
return Status::OK;
863876
}
864877

865878
Return<Status> DrmPlugin::removeAllSecureStops() {
879+
Mutex::Autolock lock(mSecureStopLock);
880+
866881
mSecureStops.clear();
867882
mNextSecureStopId = kSecureStopIdStart;
868883
return Status::OK;

drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h

+1
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ struct DrmPlugin : public IDrmPlugin {
416416
}
417417

418418
DeviceFiles mFileHandle;
419+
Mutex mSecureStopLock;
419420

420421
CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin);
421422
};

media/codec2/components/raw/C2SoftRawDec.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class C2SoftRawDec::IntfImpl : public SimpleInterface<void>::BaseParams {
5858
addParameter(
5959
DefineParam(mSampleRate, C2_PARAMKEY_SAMPLE_RATE)
6060
.withDefault(new C2StreamSampleRateInfo::output(0u, 44100))
61-
.withFields({C2F(mSampleRate, value).inRange(8000, 384000)})
61+
.withFields({C2F(mSampleRate, value).greaterThan(0)})
6262
.withSetter((Setter<decltype(*mSampleRate)>::StrictValueWithNoDeps))
6363
.build());
6464

0 commit comments

Comments
 (0)