From 39f690e459461b73b177853a1e36d2a7aef9581e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 1 Oct 2020 20:22:52 +0200 Subject: [PATCH] Revert "selftests/ptrace: add test cases for dead-locks" This reverts commit 2f7a0de4e5da7223902d48a30833bc67ef45a02b which is commit 2de4e82318c7f9d34f4b08599a612cd4cd10bf0b upstream. It breaks the API and we don't need it right now in the 5.4 tree. Bug: 161946584 Signed-off-by: Greg Kroah-Hartman Change-Id: Ic49ab9374cf94f4e091acc130f39c20c9542cf3b --- tools/testing/selftests/ptrace/Makefile | 4 +- tools/testing/selftests/ptrace/vmaccess.c | 86 ----------------------- 2 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 tools/testing/selftests/ptrace/vmaccess.c diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile index 2f1f532c39db..c0b7f89f0930 100644 --- a/tools/testing/selftests/ptrace/Makefile +++ b/tools/testing/selftests/ptrace/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall +CFLAGS += -iquote../../../../include/uapi -Wall -TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess +TEST_GEN_PROGS := get_syscall_info peeksiginfo include ../lib.mk diff --git a/tools/testing/selftests/ptrace/vmaccess.c b/tools/testing/selftests/ptrace/vmaccess.c deleted file mode 100644 index 4db327b44586..000000000000 --- a/tools/testing/selftests/ptrace/vmaccess.c +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (c) 2020 Bernd Edlinger - * All rights reserved. - * - * Check whether /proc/$pid/mem can be accessed without causing deadlocks - * when de_thread is blocked with ->cred_guard_mutex held. - */ - -#include "../kselftest_harness.h" -#include -#include -#include -#include -#include -#include - -static void *thread(void *arg) -{ - ptrace(PTRACE_TRACEME, 0, 0L, 0L); - return NULL; -} - -TEST(vmaccess) -{ - int f, pid = fork(); - char mm[64]; - - if (!pid) { - pthread_t pt; - - pthread_create(&pt, NULL, thread, NULL); - pthread_join(pt, NULL); - execlp("true", "true", NULL); - } - - sleep(1); - sprintf(mm, "/proc/%d/mem", pid); - f = open(mm, O_RDONLY); - ASSERT_GE(f, 0); - close(f); - f = kill(pid, SIGCONT); - ASSERT_EQ(f, 0); -} - -TEST(attach) -{ - int s, k, pid = fork(); - - if (!pid) { - pthread_t pt; - - pthread_create(&pt, NULL, thread, NULL); - pthread_join(pt, NULL); - execlp("sleep", "sleep", "2", NULL); - } - - sleep(1); - k = ptrace(PTRACE_ATTACH, pid, 0L, 0L); - ASSERT_EQ(errno, EAGAIN); - ASSERT_EQ(k, -1); - k = waitpid(-1, &s, WNOHANG); - ASSERT_NE(k, -1); - ASSERT_NE(k, 0); - ASSERT_NE(k, pid); - ASSERT_EQ(WIFEXITED(s), 1); - ASSERT_EQ(WEXITSTATUS(s), 0); - sleep(1); - k = ptrace(PTRACE_ATTACH, pid, 0L, 0L); - ASSERT_EQ(k, 0); - k = waitpid(-1, &s, 0); - ASSERT_EQ(k, pid); - ASSERT_EQ(WIFSTOPPED(s), 1); - ASSERT_EQ(WSTOPSIG(s), SIGSTOP); - k = ptrace(PTRACE_DETACH, pid, 0L, 0L); - ASSERT_EQ(k, 0); - k = waitpid(-1, &s, 0); - ASSERT_EQ(k, pid); - ASSERT_EQ(WIFEXITED(s), 1); - ASSERT_EQ(WEXITSTATUS(s), 0); - k = waitpid(-1, NULL, 0); - ASSERT_EQ(k, -1); - ASSERT_EQ(errno, ECHILD); -} - -TEST_HARNESS_MAIN