ANDROID: update patch stack

Two patches from the patch stack were accepted upstream and included in
4.15. Two new patches were required to get 4.15 to compile and run on
Android.

Change-Id: I1a81cf0c130818aaeced036311d3aaa9daf752eb
Signed-off-by: Steve Muckle <smuckle@google.com>
diff --git a/android/patches/0006-selftests-exec-include-cwd-in-long-path-calculation.patch b/android/patches/0006-selftests-exec-include-cwd-in-long-path-calculation.patch
deleted file mode 100644
index f43c46e..0000000
--- a/android/patches/0006-selftests-exec-include-cwd-in-long-path-calculation.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-From 95e8aad6260e79f8c8f6afc52c5b6b0bb447342f Mon Sep 17 00:00:00 2001
-From: Steve Muckle <smuckle@google.com>
-Date: Fri, 6 Oct 2017 15:18:31 -0700
-Subject: [PATCH] selftests/exec: include cwd in long path calculation
-
-When creating a pathname close to PATH_MAX to test execveat, factor in
-the current working directory path otherwise we end up with an absolute
-path that is longer than PATH_MAX. While execveat() may succeed, subsequent
-calls to the kernel from the runtime environment which are required to
-successfully execute the test binary/script may fail because of this.
-
-To keep the semantics of the test the same, rework the relative pathname
-part of the test to be relative to the root directory so it isn't
-decreased by the length of the current working directory path.
-
-Bug: 67016227
-Test: run vts-kernel -m VtsKernelLinuxKselftestStaging
-Change-Id: Ib407d1afc52de7e58cb208fd41ade6e8c38d8bfd
-Signed-off-by: Steve Muckle <smuckle@google.com>
----
- tools/testing/selftests/exec/execveat.c | 27 +++++++++++++++++++--------
- 1 file changed, 19 insertions(+), 8 deletions(-)
-
-diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c
-index 8d5d1d2ee7c1..67cd4597db2b 100644
---- a/tools/testing/selftests/exec/execveat.c
-+++ b/tools/testing/selftests/exec/execveat.c
-@@ -147,7 +147,7 @@ static void exe_cp(const char *src, const char *dest)
- }
- 
- #define XX_DIR_LEN 200
--static int check_execveat_pathmax(int dot_dfd, const char *src, int is_script)
-+static int check_execveat_pathmax(int root_dfd, const char *src, int is_script)
- {
- 	int fail = 0;
- 	int ii, count, len;
-@@ -156,20 +156,30 @@ static int check_execveat_pathmax(int dot_dfd, const char *src, int is_script)
- 
- 	if (*longpath == '\0') {
- 		/* Create a filename close to PATH_MAX in length */
-+		char *cwd = getcwd(NULL, 0);
-+
-+		if (!cwd) {
-+			printf("Failed to getcwd(), errno=%d (%s)\n",
-+			       errno, strerror(errno));
-+			return 2;
-+		}
-+		strcpy(longpath, cwd);
-+		strcat(longpath, "/");
- 		memset(longname, 'x', XX_DIR_LEN - 1);
- 		longname[XX_DIR_LEN - 1] = '/';
- 		longname[XX_DIR_LEN] = '\0';
--		count = (PATH_MAX - 3) / XX_DIR_LEN;
-+		count = (PATH_MAX - 3 - strlen(cwd)) / XX_DIR_LEN;
- 		for (ii = 0; ii < count; ii++) {
- 			strcat(longpath, longname);
- 			mkdir(longpath, 0755);
- 		}
--		len = (PATH_MAX - 3) - (count * XX_DIR_LEN);
-+		len = (PATH_MAX - 3 - strlen(cwd)) - (count * XX_DIR_LEN);
- 		if (len <= 0)
- 			len = 1;
- 		memset(longname, 'y', len);
- 		longname[len] = '\0';
- 		strcat(longpath, longname);
-+		free(cwd);
- 	}
- 	exe_cp(src, longpath);
- 
-@@ -190,7 +200,7 @@ static int check_execveat_pathmax(int dot_dfd, const char *src, int is_script)
- 	}
- 
- 	/*
--	 * Execute as a long pathname relative to ".".  If this is a script,
-+	 * Execute as a long pathname relative to "/".  If this is a script,
- 	 * the interpreter will launch but fail to open the script because its
- 	 * name ("/dev/fd/5/xxx....") is bigger than PATH_MAX.
- 	 *
-@@ -200,10 +210,10 @@ static int check_execveat_pathmax(int dot_dfd, const char *src, int is_script)
- 	 * the exit status shall be 126."), so allow either.
- 	 */
- 	if (is_script)
--		fail += check_execveat_invoked_rc(dot_dfd, longpath, 0,
-+		fail += check_execveat_invoked_rc(root_dfd, longpath + 1, 0,
- 						  127, 126);
- 	else
--		fail += check_execveat(dot_dfd, longpath, 0);
-+		fail += check_execveat(root_dfd, longpath + 1, 0);
- 
- 	return fail;
- }
-@@ -218,6 +228,7 @@ static int run_tests(void)
- 	int subdir_dfd_ephemeral = open_or_die("subdir.ephemeral",
- 					       O_DIRECTORY|O_RDONLY);
- 	int dot_dfd = open_or_die(".", O_DIRECTORY|O_RDONLY);
-+	int root_dfd = open_or_die("/", O_DIRECTORY|O_RDONLY);
- 	int dot_dfd_path = open_or_die(".", O_DIRECTORY|O_RDONLY|O_PATH);
- 	int dot_dfd_cloexec = open_or_die(".", O_DIRECTORY|O_RDONLY|O_CLOEXEC);
- 	int fd = open_or_die("execveat", O_RDONLY);
-@@ -353,8 +364,8 @@ static int run_tests(void)
- 	/* Attempt to execute relative to non-directory => ENOTDIR */
- 	fail += check_execveat_fail(fd, "execveat", 0, ENOTDIR);
- 
--	fail += check_execveat_pathmax(dot_dfd, "execveat", 0);
--	fail += check_execveat_pathmax(dot_dfd, "script", 1);
-+	fail += check_execveat_pathmax(root_dfd, "execveat", 0);
-+	fail += check_execveat_pathmax(root_dfd, "script", 1);
- 	return fail;
- }
- 
--- 
-2.16.0.rc1.238.g530d649a79-goog
-
diff --git a/android/patches/0014-selftests-vdso_test-support-ARM64-targets.patch b/android/patches/0014-selftests-vdso_test-support-ARM64-targets.patch
deleted file mode 100644
index 22a161c..0000000
--- a/android/patches/0014-selftests-vdso_test-support-ARM64-targets.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From ff03117f4a19cdf536f9bb7e28c9785c18616412 Mon Sep 17 00:00:00 2001
-From: Greg Hackmann <ghackmann@google.com>
-Date: Wed, 1 Nov 2017 14:34:26 -0700
-Subject: [PATCH] selftests: vdso_test: support ARM64 targets
-
-ARM64's vDSO exports its gettimeofday() implementation with a different
-name (__kernel_gettimeofday) and version (LINUX_2.6.39) from other
-architectures.  Add a corresponding special-case to vdso_test.
-
-Signed-off-by: Greg Hackmann <ghackmann@google.com>
-Bug: 67017029
-Test: make -j vts
-Change-Id: I54b2dfa99717da22b12783a98ef19291b5c581f5
-Signed-off-by: Steve Muckle <smuckle@google.com>
----
- tools/testing/selftests/vDSO/vdso_test.c | 19 ++++++++++++++++---
- 1 file changed, 16 insertions(+), 3 deletions(-)
-
-diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test.c
-index 8daeb7d7032c..2df26bd0099c 100644
---- a/tools/testing/selftests/vDSO/vdso_test.c
-+++ b/tools/testing/selftests/vDSO/vdso_test.c
-@@ -19,6 +19,19 @@ extern void *vdso_sym(const char *version, const char *name);
- extern void vdso_init_from_sysinfo_ehdr(uintptr_t base);
- extern void vdso_init_from_auxv(void *auxv);
- 
-+/*
-+ * ARM64's vDSO exports its gettimeofday() implementation with a different
-+ * name and version from other architectures, so we need to handle it as
-+ * a special case.
-+ */
-+#if defined(__aarch64__)
-+const char *version = "LINUX_2.6.39";
-+const char *name = "__kernel_gettimeofday";
-+#else
-+const char *version = "LINUX_2.6";
-+const char *name = "__vdso_gettimeofday";
-+#endif
-+
- int main(int argc, char **argv)
- {
- 	unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
-@@ -31,10 +44,10 @@ int main(int argc, char **argv)
- 
- 	/* Find gettimeofday. */
- 	typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
--	gtod_t gtod = (gtod_t)vdso_sym("LINUX_2.6", "__vdso_gettimeofday");
-+	gtod_t gtod = (gtod_t)vdso_sym(version, name);
- 
- 	if (!gtod) {
--		printf("Could not find __vdso_gettimeofday\n");
-+		printf("Could not find %s\n", name);
- 		return 1;
- 	}
- 
-@@ -45,7 +58,7 @@ int main(int argc, char **argv)
- 		printf("The time is %lld.%06lld\n",
- 		       (long long)tv.tv_sec, (long long)tv.tv_usec);
- 	} else {
--		printf("__vdso_gettimeofday failed\n");
-+		printf("%s failed\n", name);
- 	}
- 
- 	return 0;
--- 
-2.16.0.rc1.238.g530d649a79-goog
-
diff --git a/android/patches/0016-ksft_exit_skip_noreturn.patch b/android/patches/0016-ksft_exit_skip_noreturn.patch
new file mode 100644
index 0000000..9126d71
--- /dev/null
+++ b/android/patches/0016-ksft_exit_skip_noreturn.patch
@@ -0,0 +1,13 @@
+diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
+index 1ae565ed9bf0..05a4b9ad80c9 100644
+--- a/tools/testing/selftests/kselftest.h
++++ b/tools/testing/selftests/kselftest.h
+@@ -165,7 +165,7 @@ static inline int ksft_exit_xpass(void)
+ 	exit(KSFT_XPASS);
+ }
+ 
+-static inline int ksft_exit_skip(const char *msg, ...)
++static inline void __noreturn ksft_exit_skip(const char *msg, ...)
+ {
+ 	if (msg) {
+ 		va_list args;
diff --git a/android/patches/0017-seccomp_bpf_disable_tests.patch b/android/patches/0017-seccomp_bpf_disable_tests.patch
new file mode 100644
index 0000000..75b3593
--- /dev/null
+++ b/android/patches/0017-seccomp_bpf_disable_tests.patch
@@ -0,0 +1,126 @@
+diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
+index 34d9582aefb4..843ba80c401b 100644
+--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
++++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
+@@ -12,12 +12,14 @@
+  * we need to use the kernel's siginfo.h file and trick glibc
+  * into accepting it.
+  */
++#if defined(__GLIBC_PREREQ)
+ #if !__GLIBC_PREREQ(2, 26)
+ # include <asm/siginfo.h>
+ # define __have_siginfo_t 1
+ # define __have_sigval_t 1
+ # define __have_sigevent_t 1
+ #endif
++#endif
+ 
+ #include <errno.h>
+ #include <linux/filter.h>
+@@ -404,6 +406,7 @@ TEST(empty_prog)
+ 	EXPECT_EQ(EINVAL, errno);
+ }
+ 
++#if 0
+ TEST(log_all)
+ {
+ 	struct sock_filter filter[] = {
+@@ -425,6 +428,7 @@ TEST(log_all)
+ 	/* getppid() should succeed and be logged (no check for logging) */
+ 	EXPECT_EQ(parent, syscall(__NR_getppid));
+ }
++#endif
+ 
+ TEST_SIGNAL(unknown_ret_is_kill_inside, SIGSYS)
+ {
+@@ -677,6 +681,7 @@ void kill_thread_or_group(struct __test_metadata *_metadata, bool kill_process)
+ 	exit(42);
+ }
+ 
++#if 0
+ TEST(KILL_thread)
+ {
+ 	int status;
+@@ -695,6 +700,7 @@ TEST(KILL_thread)
+ 	ASSERT_TRUE(WIFEXITED(status));
+ 	ASSERT_EQ(42, WEXITSTATUS(status));
+ }
++#endif
+ 
+ TEST(KILL_process)
+ {
+@@ -1242,6 +1248,7 @@ TEST_F(precedence, trace_is_fourth_in_any_order)
+ 	EXPECT_EQ(-1, syscall(__NR_getpid));
+ }
+ 
++#if 0
+ TEST_F(precedence, log_is_fifth)
+ {
+ 	pid_t mypid, parent;
+@@ -1281,6 +1288,7 @@ TEST_F(precedence, log_is_fifth_in_any_order)
+ 	/* Should also work just fine */
+ 	EXPECT_EQ(mypid, syscall(__NR_getpid));
+ }
++#endif
+ 
+ #ifndef PTRACE_O_TRACESECCOMP
+ #define PTRACE_O_TRACESECCOMP	0x00000080
+@@ -1717,8 +1725,10 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
+ 
+ 	if (nr == __NR_getpid)
+ 		change_syscall(_metadata, tracee, __NR_getppid);
++#ifdef __NR_open
+ 	if (nr == __NR_open)
+ 		change_syscall(_metadata, tracee, -1);
++#endif
+ }
+ 
+ FIXTURE_DATA(TRACE_syscall) {
+@@ -1784,6 +1794,7 @@ TEST_F(TRACE_syscall, ptrace_syscall_redirected)
+ 	EXPECT_NE(self->mypid, syscall(__NR_getpid));
+ }
+ 
++#ifdef __NR_open
+ TEST_F(TRACE_syscall, ptrace_syscall_dropped)
+ {
+ 	/* Swap SECCOMP_RET_TRACE tracer for PTRACE_SYSCALL tracer. */
+@@ -1794,6 +1805,7 @@ TEST_F(TRACE_syscall, ptrace_syscall_dropped)
+ 	/* Tracer should skip the open syscall, resulting in EPERM. */
+ 	EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
+ }
++#endif
+ 
+ TEST_F(TRACE_syscall, syscall_allowed)
+ {
+@@ -2059,6 +2071,7 @@ TEST(seccomp_syscall_mode_lock)
+ 	}
+ }
+ 
++#if 0
+ /*
+  * Test detection of known and unknown filter flags. Userspace needs to be able
+  * to check if a filter flag is supported by the current kernel and a good way
+@@ -2119,6 +2132,7 @@ TEST(detect_seccomp_filter_flags)
+ 		       flag);
+ 	}
+ }
++#endif
+ 
+ TEST(TSYNC_first)
+ {
+@@ -2759,6 +2773,7 @@ TEST(syscall_restart)
+ 		_metadata->passed = 0;
+ }
+ 
++#if 0
+ TEST_SIGNAL(filter_flag_log, SIGSYS)
+ {
+ 	struct sock_filter allow_filter[] = {
+@@ -2851,6 +2866,7 @@ TEST(get_action_avail)
+ 	EXPECT_EQ(ret, -1);
+ 	EXPECT_EQ(errno, EOPNOTSUPP);
+ }
++#endif
+ 
+ /*
+  * TODO: