637 lines
22 KiB
Diff
637 lines
22 KiB
Diff
From f5888ee34b2cca8562d2878dbc6b2db9b8256672 Mon Sep 17 00:00:00 2001
|
|
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
Date: Fri, 1 Feb 2019 11:04:51 +0100
|
|
Subject: [PATCH 22/27] tests: add kill_child test
|
|
|
|
This tests repeatedly creates and kills children, so some corner
|
|
cases in handling of not-quite-existing processes can be observed.
|
|
|
|
Previously, strace was crashing in the following situation:
|
|
|
|
13994 ????( <unfinished ...>
|
|
...
|
|
13994 <... ???? resumed>) = ?
|
|
|
|
as tcp->s_ent wasn't initialised on syscall entering and
|
|
strace.c:print_event_exit segfaulted when tried to access
|
|
tcp->s_ent->sys_name.
|
|
|
|
* tests/kill_child.c: New file.
|
|
* tests/kill_child.test: New test.
|
|
* tests/.gitignore: Add kill_child.
|
|
* tests/Makefile.am (check_PROGRAMS): Likewise.
|
|
(MISC_TESTS): Add kill_child.test.
|
|
|
|
Skipped files (not present in dist tarball):
|
|
tests/.gitignore
|
|
|
|
Additional changes:
|
|
tests/Makefile.in (auto-generated from tests/Makefile.am)
|
|
tests-m32/Makefile.in (auto-generated from tests-m32/Makefile.am)
|
|
tests-m32/kill_child.c (copy of tests/kill_child.c)
|
|
tests-m32/kill_child.test (copy of tests/kill_child.test)
|
|
tests-m32/Makefile.in (auto-generted from tests-mx32/Makefile.am)
|
|
tests-mx32/kill_child.c (copy of tests/kill_child.c)
|
|
tests-mx32/kill_child.test (copy of tests/kill_child.test)
|
|
|
|
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
|
|
---
|
|
tests/.gitignore | 1 +
|
|
tests/Makefile.am | 2 ++
|
|
tests/kill_child.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
tests/kill_child.test | 31 +++++++++++++++++++++++
|
|
4 files changed, 103 insertions(+)
|
|
create mode 100644 tests/kill_child.c
|
|
create mode 100755 tests/kill_child.test
|
|
|
|
Index: strace-4.24/tests/Makefile.am
|
|
===================================================================
|
|
--- strace-4.24.orig/tests/Makefile.am 2019-03-10 05:34:51.995141191 +0100
|
|
+++ strace-4.24/tests/Makefile.am 2019-03-10 05:40:37.969676713 +0100
|
|
@@ -104,6 +104,7 @@
|
|
ioctl_perf-success \
|
|
ioctl_rtc-v \
|
|
is_linux_mips_n64 \
|
|
+ kill_child \
|
|
ksysent \
|
|
list_sigaction_signum \
|
|
localtime \
|
|
@@ -299,6 +300,7 @@
|
|
get_regs.test \
|
|
inject-nf.test \
|
|
interactive_block.test \
|
|
+ kill_child.test \
|
|
ksysent.test \
|
|
localtime.test \
|
|
opipe.test \
|
|
Index: strace-4.24/tests/kill_child.c
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ strace-4.24/tests/kill_child.c 2019-03-10 05:40:37.970676703 +0100
|
|
@@ -0,0 +1,69 @@
|
|
+/*
|
|
+ * Check for the corner case that previously lead to segfault
|
|
+ * due to an attempt to access unitialised tcp->s_ent.
|
|
+ *
|
|
+ * 13994 ????( <unfinished ...>
|
|
+ * ...
|
|
+ * 13994 <... ???? resumed>) = ?
|
|
+ *
|
|
+ * Copyright (c) 2019 The strace developers.
|
|
+ * All rights reserved.
|
|
+ *
|
|
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
|
+ */
|
|
+
|
|
+#include "tests.h"
|
|
+
|
|
+#include <sched.h>
|
|
+#include <signal.h>
|
|
+#include <unistd.h>
|
|
+#include <sys/mman.h>
|
|
+#include <sys/wait.h>
|
|
+
|
|
+#define ITERS 10000
|
|
+#define SC_ITERS 10000
|
|
+
|
|
+int
|
|
+main(void)
|
|
+{
|
|
+ volatile sig_atomic_t *const mem =
|
|
+ mmap(NULL, get_page_size(), PROT_READ | PROT_WRITE,
|
|
+ MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
|
+ if (mem == MAP_FAILED)
|
|
+ perror_msg_and_fail("mmap");
|
|
+
|
|
+ for (unsigned int i = 0; i < ITERS; ++i) {
|
|
+ mem[0] = mem[1] = 0;
|
|
+
|
|
+ const pid_t pid = fork();
|
|
+ if (pid < 0)
|
|
+ perror_msg_and_fail("fork");
|
|
+
|
|
+ if (!pid) {
|
|
+ /* wait for the parent */
|
|
+ while (!mem[0])
|
|
+ ;
|
|
+ /* let the parent know we are running */
|
|
+ mem[1] = 1;
|
|
+
|
|
+ for (unsigned int j = 0; j < SC_ITERS; j++)
|
|
+ sched_yield();
|
|
+
|
|
+ pause();
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ /* let the child know we are running */
|
|
+ mem[0] = 1;
|
|
+ /* wait for the child */
|
|
+ while (!mem[1])
|
|
+ ;
|
|
+
|
|
+ if (kill(pid, SIGKILL))
|
|
+ perror_msg_and_fail("kill");
|
|
+ if (wait(NULL) != pid)
|
|
+ perror_msg_and_fail("wait");
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
Index: strace-4.24/tests/kill_child.test
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ strace-4.24/tests/kill_child.test 2019-03-10 05:40:37.970676703 +0100
|
|
@@ -0,0 +1,31 @@
|
|
+#!/bin/sh
|
|
+#
|
|
+# Check whether repeated killing of just forked processes crashes strace.
|
|
+#
|
|
+# Copyright (c) 2019 The strace developers.
|
|
+# All rights reserved.
|
|
+#
|
|
+# SPDX-License-Identifier: GPL-2.0-or-later
|
|
+
|
|
+. "${srcdir=.}/init.sh"
|
|
+
|
|
+run_prog_skip_if_failed date +%s > /dev/null
|
|
+s0="$(date +%s)"
|
|
+
|
|
+run_prog
|
|
+args="-f -qq -e signal=none -e trace=sched_yield,/kill $args"
|
|
+
|
|
+# Run strace until the known corner case is observed.
|
|
+while :; do
|
|
+ run_strace $args
|
|
+
|
|
+ # Printing of "<... SYSCALL resumed>" in strace.c:print_event_exit
|
|
+ # used to segfault when the syscall number had not been obtained
|
|
+ # on syscall entering.
|
|
+ grep -q '^[1-9][0-9]* <\.\.\. ???? resumed>) \+= ?$' "$LOG" && exit 0
|
|
+
|
|
+ s1="$(date +%s)"
|
|
+ if [ "$(($s1-$s0))" -gt "$(($TIMEOUT_DURATION/2))" ]; then
|
|
+ skip_ 'Unable to reproduce <... ???? resumed>'
|
|
+ fi
|
|
+done
|
|
Index: strace-4.24/tests/Makefile.in
|
|
===================================================================
|
|
--- strace-4.24.orig/tests/Makefile.in 2019-03-10 05:34:51.995141191 +0100
|
|
+++ strace-4.24/tests/Makefile.in 2019-03-10 05:40:37.973676673 +0100
|
|
@@ -153,8 +153,9 @@
|
|
ioctl_evdev-v$(EXEEXT) ioctl_loop-nv$(EXEEXT) \
|
|
ioctl_loop-v$(EXEEXT) ioctl_nsfs$(EXEEXT) \
|
|
ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
|
|
- is_linux_mips_n64$(EXEEXT) ksysent$(EXEEXT) \
|
|
- list_sigaction_signum$(EXEEXT) localtime$(EXEEXT) \
|
|
+ is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
|
|
+ ksysent$(EXEEXT) list_sigaction_signum$(EXEEXT) \
|
|
+ localtime$(EXEEXT) \
|
|
mmsg-silent$(EXEEXT) mmsg_name-v$(EXEEXT) \
|
|
msg_control-v$(EXEEXT) net-accept-connect$(EXEEXT) \
|
|
net-tpacket_stats-success$(EXEEXT) netlink_inet_diag$(EXEEXT) \
|
|
@@ -1186,6 +1187,10 @@
|
|
kill_OBJECTS = kill.$(OBJEXT)
|
|
kill_LDADD = $(LDADD)
|
|
kill_DEPENDENCIES = libtests.a
|
|
+kill_child_SOURCES = kill_child.c
|
|
+kill_child_OBJECTS = kill_child.$(OBJEXT)
|
|
+kill_child_LDADD = $(LDADD)
|
|
+kill_child_DEPENDENCIES = libtests.a
|
|
ksysent_SOURCES = ksysent.c
|
|
ksysent_OBJECTS = ksysent.$(OBJEXT)
|
|
ksysent_LDADD = $(LDADD)
|
|
@@ -2741,9 +2746,9 @@
|
|
ipc_shm.c ipc_shm-Xabbrev.c ipc_shm-Xraw.c ipc_shm-Xverbose.c \
|
|
is_linux_mips_n64.c kcmp.c kcmp-y.c kern_features.c \
|
|
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
|
|
- keyctl-Xraw.c keyctl-Xverbose.c kill.c ksysent.c lchown.c \
|
|
- lchown32.c link.c linkat.c list_sigaction_signum.c llseek.c \
|
|
- localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
+ keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
|
|
+ lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
|
|
+ llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
|
|
mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
|
|
mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
|
|
@@ -2886,9 +2891,9 @@
|
|
ipc_shm.c ipc_shm-Xabbrev.c ipc_shm-Xraw.c ipc_shm-Xverbose.c \
|
|
is_linux_mips_n64.c kcmp.c kcmp-y.c kern_features.c \
|
|
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
|
|
- keyctl-Xraw.c keyctl-Xverbose.c kill.c ksysent.c lchown.c \
|
|
- lchown32.c link.c linkat.c list_sigaction_signum.c llseek.c \
|
|
- localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
+ keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
|
|
+ lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
|
|
+ llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
|
|
mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
|
|
mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
|
|
@@ -4227,6 +4232,7 @@
|
|
get_regs.test \
|
|
inject-nf.test \
|
|
interactive_block.test \
|
|
+ kill_child.test \
|
|
ksysent.test \
|
|
localtime.test \
|
|
opipe.test \
|
|
@@ -5190,6 +5196,10 @@
|
|
@rm -f kill$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(kill_OBJECTS) $(kill_LDADD) $(LIBS)
|
|
|
|
+kill_child$(EXEEXT): $(kill_child_OBJECTS) $(kill_child_DEPENDENCIES) $(EXTRA_kill_child_DEPENDENCIES)
|
|
+ @rm -f kill_child$(EXEEXT)
|
|
+ $(AM_V_CCLD)$(LINK) $(kill_child_OBJECTS) $(kill_child_LDADD) $(LIBS)
|
|
+
|
|
ksysent$(EXEEXT): $(ksysent_OBJECTS) $(ksysent_DEPENDENCIES) $(EXTRA_ksysent_DEPENDENCIES)
|
|
@rm -f ksysent$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(ksysent_OBJECTS) $(ksysent_LDADD) $(LIBS)
|
|
@@ -6855,6 +6865,7 @@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyctl-Xverbose.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyctl.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill.Po@am__quote@
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill_child.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ksysent.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown32.Po@am__quote@
|
|
Index: strace-4.24/tests-m32/Makefile.in
|
|
===================================================================
|
|
--- strace-4.24.orig/tests-m32/Makefile.in 2018-08-14 02:44:38.000000000 +0200
|
|
+++ strace-4.24/tests-m32/Makefile.in 2019-03-10 05:44:56.112091757 +0100
|
|
@@ -153,8 +153,9 @@
|
|
ioctl_evdev-v$(EXEEXT) ioctl_loop-nv$(EXEEXT) \
|
|
ioctl_loop-v$(EXEEXT) ioctl_nsfs$(EXEEXT) \
|
|
ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
|
|
- is_linux_mips_n64$(EXEEXT) ksysent$(EXEEXT) \
|
|
- list_sigaction_signum$(EXEEXT) localtime$(EXEEXT) \
|
|
+ is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
|
|
+ ksysent$(EXEEXT) list_sigaction_signum$(EXEEXT) \
|
|
+ localtime$(EXEEXT) \
|
|
mmsg-silent$(EXEEXT) mmsg_name-v$(EXEEXT) \
|
|
msg_control-v$(EXEEXT) net-accept-connect$(EXEEXT) \
|
|
net-tpacket_stats-success$(EXEEXT) netlink_inet_diag$(EXEEXT) \
|
|
@@ -1186,6 +1187,10 @@
|
|
kill_OBJECTS = kill.$(OBJEXT)
|
|
kill_LDADD = $(LDADD)
|
|
kill_DEPENDENCIES = libtests.a
|
|
+kill_child_SOURCES = kill_child.c
|
|
+kill_child_OBJECTS = kill_child.$(OBJEXT)
|
|
+kill_child_LDADD = $(LDADD)
|
|
+kill_child_DEPENDENCIES = libtests.a
|
|
ksysent_SOURCES = ksysent.c
|
|
ksysent_OBJECTS = ksysent.$(OBJEXT)
|
|
ksysent_LDADD = $(LDADD)
|
|
@@ -2741,9 +2746,9 @@
|
|
ipc_shm.c ipc_shm-Xabbrev.c ipc_shm-Xraw.c ipc_shm-Xverbose.c \
|
|
is_linux_mips_n64.c kcmp.c kcmp-y.c kern_features.c \
|
|
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
|
|
- keyctl-Xraw.c keyctl-Xverbose.c kill.c ksysent.c lchown.c \
|
|
- lchown32.c link.c linkat.c list_sigaction_signum.c llseek.c \
|
|
- localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
+ keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
|
|
+ lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
|
|
+ llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
|
|
mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
|
|
mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
|
|
@@ -2886,9 +2891,9 @@
|
|
ipc_shm.c ipc_shm-Xabbrev.c ipc_shm-Xraw.c ipc_shm-Xverbose.c \
|
|
is_linux_mips_n64.c kcmp.c kcmp-y.c kern_features.c \
|
|
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
|
|
- keyctl-Xraw.c keyctl-Xverbose.c kill.c ksysent.c lchown.c \
|
|
- lchown32.c link.c linkat.c list_sigaction_signum.c llseek.c \
|
|
- localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
+ keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
|
|
+ lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
|
|
+ llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
|
|
mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
|
|
mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
|
|
@@ -4227,6 +4232,7 @@
|
|
get_regs.test \
|
|
inject-nf.test \
|
|
interactive_block.test \
|
|
+ kill_child.test \
|
|
ksysent.test \
|
|
localtime.test \
|
|
opipe.test \
|
|
@@ -5190,6 +5196,10 @@
|
|
@rm -f kill$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(kill_OBJECTS) $(kill_LDADD) $(LIBS)
|
|
|
|
+kill_child$(EXEEXT): $(kill_child_OBJECTS) $(kill_child_DEPENDENCIES) $(EXTRA_kill_child_DEPENDENCIES)
|
|
+ @rm -f kill_child$(EXEEXT)
|
|
+ $(AM_V_CCLD)$(LINK) $(kill_child_OBJECTS) $(kill_child_LDADD) $(LIBS)
|
|
+
|
|
ksysent$(EXEEXT): $(ksysent_OBJECTS) $(ksysent_DEPENDENCIES) $(EXTRA_ksysent_DEPENDENCIES)
|
|
@rm -f ksysent$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(ksysent_OBJECTS) $(ksysent_LDADD) $(LIBS)
|
|
@@ -6855,6 +6865,7 @@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyctl-Xverbose.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyctl.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill.Po@am__quote@
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill_child.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ksysent.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown32.Po@am__quote@
|
|
Index: strace-4.24/tests-m32/kill_child.c
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ strace-4.24/tests-m32/kill_child.c 2019-03-10 05:41:09.454361435 +0100
|
|
@@ -0,0 +1,69 @@
|
|
+/*
|
|
+ * Check for the corner case that previously lead to segfault
|
|
+ * due to an attempt to access unitialised tcp->s_ent.
|
|
+ *
|
|
+ * 13994 ????( <unfinished ...>
|
|
+ * ...
|
|
+ * 13994 <... ???? resumed>) = ?
|
|
+ *
|
|
+ * Copyright (c) 2019 The strace developers.
|
|
+ * All rights reserved.
|
|
+ *
|
|
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
|
+ */
|
|
+
|
|
+#include "tests.h"
|
|
+
|
|
+#include <sched.h>
|
|
+#include <signal.h>
|
|
+#include <unistd.h>
|
|
+#include <sys/mman.h>
|
|
+#include <sys/wait.h>
|
|
+
|
|
+#define ITERS 10000
|
|
+#define SC_ITERS 10000
|
|
+
|
|
+int
|
|
+main(void)
|
|
+{
|
|
+ volatile sig_atomic_t *const mem =
|
|
+ mmap(NULL, get_page_size(), PROT_READ | PROT_WRITE,
|
|
+ MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
|
+ if (mem == MAP_FAILED)
|
|
+ perror_msg_and_fail("mmap");
|
|
+
|
|
+ for (unsigned int i = 0; i < ITERS; ++i) {
|
|
+ mem[0] = mem[1] = 0;
|
|
+
|
|
+ const pid_t pid = fork();
|
|
+ if (pid < 0)
|
|
+ perror_msg_and_fail("fork");
|
|
+
|
|
+ if (!pid) {
|
|
+ /* wait for the parent */
|
|
+ while (!mem[0])
|
|
+ ;
|
|
+ /* let the parent know we are running */
|
|
+ mem[1] = 1;
|
|
+
|
|
+ for (unsigned int j = 0; j < SC_ITERS; j++)
|
|
+ sched_yield();
|
|
+
|
|
+ pause();
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ /* let the child know we are running */
|
|
+ mem[0] = 1;
|
|
+ /* wait for the child */
|
|
+ while (!mem[1])
|
|
+ ;
|
|
+
|
|
+ if (kill(pid, SIGKILL))
|
|
+ perror_msg_and_fail("kill");
|
|
+ if (wait(NULL) != pid)
|
|
+ perror_msg_and_fail("wait");
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
Index: strace-4.24/tests-m32/kill_child.test
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ strace-4.24/tests-m32/kill_child.test 2019-03-10 05:41:25.066205103 +0100
|
|
@@ -0,0 +1,31 @@
|
|
+#!/bin/sh
|
|
+#
|
|
+# Check whether repeated killing of just forked processes crashes strace.
|
|
+#
|
|
+# Copyright (c) 2019 The strace developers.
|
|
+# All rights reserved.
|
|
+#
|
|
+# SPDX-License-Identifier: GPL-2.0-or-later
|
|
+
|
|
+. "${srcdir=.}/init.sh"
|
|
+
|
|
+run_prog_skip_if_failed date +%s > /dev/null
|
|
+s0="$(date +%s)"
|
|
+
|
|
+run_prog
|
|
+args="-f -qq -e signal=none -e trace=sched_yield,/kill $args"
|
|
+
|
|
+# Run strace until the known corner case is observed.
|
|
+while :; do
|
|
+ run_strace $args
|
|
+
|
|
+ # Printing of "<... SYSCALL resumed>" in strace.c:print_event_exit
|
|
+ # used to segfault when the syscall number had not been obtained
|
|
+ # on syscall entering.
|
|
+ grep -q '^[1-9][0-9]* <\.\.\. ???? resumed>) \+= ?$' "$LOG" && exit 0
|
|
+
|
|
+ s1="$(date +%s)"
|
|
+ if [ "$(($s1-$s0))" -gt "$(($TIMEOUT_DURATION/2))" ]; then
|
|
+ skip_ 'Unable to reproduce <... ???? resumed>'
|
|
+ fi
|
|
+done
|
|
Index: strace-4.24/tests-mx32/kill_child.c
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ strace-4.24/tests-mx32/kill_child.c 2019-03-10 05:41:12.566330273 +0100
|
|
@@ -0,0 +1,69 @@
|
|
+/*
|
|
+ * Check for the corner case that previously lead to segfault
|
|
+ * due to an attempt to access unitialised tcp->s_ent.
|
|
+ *
|
|
+ * 13994 ????( <unfinished ...>
|
|
+ * ...
|
|
+ * 13994 <... ???? resumed>) = ?
|
|
+ *
|
|
+ * Copyright (c) 2019 The strace developers.
|
|
+ * All rights reserved.
|
|
+ *
|
|
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
|
+ */
|
|
+
|
|
+#include "tests.h"
|
|
+
|
|
+#include <sched.h>
|
|
+#include <signal.h>
|
|
+#include <unistd.h>
|
|
+#include <sys/mman.h>
|
|
+#include <sys/wait.h>
|
|
+
|
|
+#define ITERS 10000
|
|
+#define SC_ITERS 10000
|
|
+
|
|
+int
|
|
+main(void)
|
|
+{
|
|
+ volatile sig_atomic_t *const mem =
|
|
+ mmap(NULL, get_page_size(), PROT_READ | PROT_WRITE,
|
|
+ MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
|
+ if (mem == MAP_FAILED)
|
|
+ perror_msg_and_fail("mmap");
|
|
+
|
|
+ for (unsigned int i = 0; i < ITERS; ++i) {
|
|
+ mem[0] = mem[1] = 0;
|
|
+
|
|
+ const pid_t pid = fork();
|
|
+ if (pid < 0)
|
|
+ perror_msg_and_fail("fork");
|
|
+
|
|
+ if (!pid) {
|
|
+ /* wait for the parent */
|
|
+ while (!mem[0])
|
|
+ ;
|
|
+ /* let the parent know we are running */
|
|
+ mem[1] = 1;
|
|
+
|
|
+ for (unsigned int j = 0; j < SC_ITERS; j++)
|
|
+ sched_yield();
|
|
+
|
|
+ pause();
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ /* let the child know we are running */
|
|
+ mem[0] = 1;
|
|
+ /* wait for the child */
|
|
+ while (!mem[1])
|
|
+ ;
|
|
+
|
|
+ if (kill(pid, SIGKILL))
|
|
+ perror_msg_and_fail("kill");
|
|
+ if (wait(NULL) != pid)
|
|
+ perror_msg_and_fail("wait");
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
Index: strace-4.24/tests-mx32/kill_child.test
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ strace-4.24/tests-mx32/kill_child.test 2019-03-10 05:41:27.802177706 +0100
|
|
@@ -0,0 +1,31 @@
|
|
+#!/bin/sh
|
|
+#
|
|
+# Check whether repeated killing of just forked processes crashes strace.
|
|
+#
|
|
+# Copyright (c) 2019 The strace developers.
|
|
+# All rights reserved.
|
|
+#
|
|
+# SPDX-License-Identifier: GPL-2.0-or-later
|
|
+
|
|
+. "${srcdir=.}/init.sh"
|
|
+
|
|
+run_prog_skip_if_failed date +%s > /dev/null
|
|
+s0="$(date +%s)"
|
|
+
|
|
+run_prog
|
|
+args="-f -qq -e signal=none -e trace=sched_yield,/kill $args"
|
|
+
|
|
+# Run strace until the known corner case is observed.
|
|
+while :; do
|
|
+ run_strace $args
|
|
+
|
|
+ # Printing of "<... SYSCALL resumed>" in strace.c:print_event_exit
|
|
+ # used to segfault when the syscall number had not been obtained
|
|
+ # on syscall entering.
|
|
+ grep -q '^[1-9][0-9]* <\.\.\. ???? resumed>) \+= ?$' "$LOG" && exit 0
|
|
+
|
|
+ s1="$(date +%s)"
|
|
+ if [ "$(($s1-$s0))" -gt "$(($TIMEOUT_DURATION/2))" ]; then
|
|
+ skip_ 'Unable to reproduce <... ???? resumed>'
|
|
+ fi
|
|
+done
|
|
Index: strace-4.24/tests-mx32/Makefile.in
|
|
===================================================================
|
|
--- strace-4.24.orig/tests-mx32/Makefile.in 2018-08-14 02:44:38.000000000 +0200
|
|
+++ strace-4.24/tests-mx32/Makefile.in 2019-03-10 05:45:49.892553217 +0100
|
|
@@ -153,8 +153,9 @@
|
|
ioctl_evdev-v$(EXEEXT) ioctl_loop-nv$(EXEEXT) \
|
|
ioctl_loop-v$(EXEEXT) ioctl_nsfs$(EXEEXT) \
|
|
ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
|
|
- is_linux_mips_n64$(EXEEXT) ksysent$(EXEEXT) \
|
|
- list_sigaction_signum$(EXEEXT) localtime$(EXEEXT) \
|
|
+ is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
|
|
+ ksysent$(EXEEXT) list_sigaction_signum$(EXEEXT) \
|
|
+ localtime$(EXEEXT) \
|
|
mmsg-silent$(EXEEXT) mmsg_name-v$(EXEEXT) \
|
|
msg_control-v$(EXEEXT) net-accept-connect$(EXEEXT) \
|
|
net-tpacket_stats-success$(EXEEXT) netlink_inet_diag$(EXEEXT) \
|
|
@@ -1186,6 +1187,10 @@
|
|
kill_OBJECTS = kill.$(OBJEXT)
|
|
kill_LDADD = $(LDADD)
|
|
kill_DEPENDENCIES = libtests.a
|
|
+kill_child_SOURCES = kill_child.c
|
|
+kill_child_OBJECTS = kill_child.$(OBJEXT)
|
|
+kill_child_LDADD = $(LDADD)
|
|
+kill_child_DEPENDENCIES = libtests.a
|
|
ksysent_SOURCES = ksysent.c
|
|
ksysent_OBJECTS = ksysent.$(OBJEXT)
|
|
ksysent_LDADD = $(LDADD)
|
|
@@ -2741,9 +2746,9 @@
|
|
ipc_shm.c ipc_shm-Xabbrev.c ipc_shm-Xraw.c ipc_shm-Xverbose.c \
|
|
is_linux_mips_n64.c kcmp.c kcmp-y.c kern_features.c \
|
|
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
|
|
- keyctl-Xraw.c keyctl-Xverbose.c kill.c ksysent.c lchown.c \
|
|
- lchown32.c link.c linkat.c list_sigaction_signum.c llseek.c \
|
|
- localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
+ keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
|
|
+ lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
|
|
+ llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
|
|
mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
|
|
mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
|
|
@@ -2886,9 +2891,9 @@
|
|
ipc_shm.c ipc_shm-Xabbrev.c ipc_shm-Xraw.c ipc_shm-Xverbose.c \
|
|
is_linux_mips_n64.c kcmp.c kcmp-y.c kern_features.c \
|
|
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
|
|
- keyctl-Xraw.c keyctl-Xverbose.c kill.c ksysent.c lchown.c \
|
|
- lchown32.c link.c linkat.c list_sigaction_signum.c llseek.c \
|
|
- localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
+ keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
|
|
+ lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
|
|
+ llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
|
|
madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
|
|
mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
|
|
mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
|
|
@@ -4227,6 +4232,7 @@
|
|
get_regs.test \
|
|
inject-nf.test \
|
|
interactive_block.test \
|
|
+ kill_child.test \
|
|
ksysent.test \
|
|
localtime.test \
|
|
opipe.test \
|
|
@@ -5190,6 +5196,10 @@
|
|
@rm -f kill$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(kill_OBJECTS) $(kill_LDADD) $(LIBS)
|
|
|
|
+kill_child$(EXEEXT): $(kill_child_OBJECTS) $(kill_child_DEPENDENCIES) $(EXTRA_kill_child_DEPENDENCIES)
|
|
+ @rm -f kill_child$(EXEEXT)
|
|
+ $(AM_V_CCLD)$(LINK) $(kill_child_OBJECTS) $(kill_child_LDADD) $(LIBS)
|
|
+
|
|
ksysent$(EXEEXT): $(ksysent_OBJECTS) $(ksysent_DEPENDENCIES) $(EXTRA_ksysent_DEPENDENCIES)
|
|
@rm -f ksysent$(EXEEXT)
|
|
$(AM_V_CCLD)$(LINK) $(ksysent_OBJECTS) $(ksysent_LDADD) $(LIBS)
|
|
@@ -6855,6 +6865,7 @@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyctl-Xverbose.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyctl.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill.Po@am__quote@
|
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill_child.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ksysent.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@
|
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown32.Po@am__quote@
|