Compare commits

...

No commits in common. "imports/c8s/strace-5.7-3.el8" and "c8" have entirely different histories.

53 changed files with 2006 additions and 50767 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/strace-5.7.tar.xz
SOURCES/strace-5.18.tar.xz

View File

@ -1 +1 @@
95c9d5aa664982d53ce1e5ab058d8fb73e200f0c SOURCES/strace-5.7.tar.xz
e038ea9fc29366ce6119cde27d8cf16ac554a353 SOURCES/strace-5.18.tar.xz

View File

@ -1,44 +0,0 @@
From ff85f882bbd8a399e036b8465520d1ff0867f4f1 Mon Sep 17 00:00:00 2001
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
Date: Mon, 15 Jun 2020 22:01:25 +1200
Subject: [PATCH 113/115] io_uring: Remove struct io_cqring_offsets compile
time asserts
The generated types/check-io_uring.c already checks the kernel's struct
io_cqring_offsets for compatibility with the strace definition so
there's no need for manual checks.
* io_uring.c [HAVE_STRUCT_IO_CQRING_OFFSETS]: Remove static_asserts.
---
io_uring.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/io_uring.c b/io_uring.c
index ac1807b..fd83313 100644
--- a/io_uring.c
+++ b/io_uring.c
@@ -17,21 +17,6 @@
#include "xlat/uring_enter_flags.h"
#include "xlat/uring_register_opcodes.h"
-#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
-static_assert(offsetof(struct_io_cqring_offsets, resv)
- >= offsetof(struct io_cqring_offsets, resv),
- "struct io_cqring_offsets.resv offset mismatch"
- ", please update the decoder");
-static_assert(sizeof_field(struct_io_cqring_offsets, resv)
- <= sizeof_field(struct io_cqring_offsets, resv),
- "struct io_cqring_offsets.resv size mismatch"
- ", please update the decoder");
-# else /* !HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
-static_assert(0, "struct io_cqring_offsets.resv is missing"
- ", please update the decoder");
-# endif
-#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
#ifdef HAVE_STRUCT_IO_URING_PARAMS
# ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
static_assert(offsetof(struct_io_uring_params, resv)
--
2.1.4

View File

@ -1,383 +0,0 @@
From c51b292b237214ccfcae5a84085f8d0a7e85c8ba Mon Sep 17 00:00:00 2001
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
Date: Mon, 15 Jun 2020 22:01:26 +1200
Subject: [PATCH 114/115] io_uring: Add io_cqring_offset flags
Add support for displaying struct io_cqring_offsets.flags introduced
by Linux kernel commits v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21.
* types/io_uring.h (struct_io_cqring_offsets): Replace resv array
with flags, resv1, and resv2 fields.
* xlat/uring_cqring_flags.in: New file.
* configure.ac (AC_CHECK_MEMBERS): Check struct io_cqring_offsets.flags.
* io_uring.c: Include "xlat/uring_cqring_flags.h".
(SYS_FUNC(io_uring_setup)): Replace printing of the resv array
of struct io_cqring_offsets with flags, resv1, and resv2 fields.
* tests/io_uring_setup.c: Check it.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Resolves: https://github.com/strace/strace/issues/138
---
configure.ac | 1 +
io_uring.c | 11 +++++++----
tests/io_uring_setup.c | 31 ++++++++++++++++++++++++++-----
types/io_uring.h | 4 +++-
xlat/uring_cqring_flags.in | 1 +
5 files changed, 38 insertions(+), 10 deletions(-)
create mode 100644 xlat/uring_cqring_flags.in
Index: strace-5.7/configure.ac
===================================================================
--- strace-5.7.orig/configure.ac 2020-11-09 04:39:07.197892960 +0100
+++ strace-5.7/configure.ac 2020-11-09 04:39:14.943826575 +0100
@@ -481,6 +481,7 @@
AC_CHECK_HEADERS([linux/io_uring.h], [
AC_CHECK_MEMBERS(m4_normalize([
+ struct io_cqring_offsets.flags,
struct io_uring_params.features,
struct io_uring_params.wq_fd,
struct io_uring_params.resv
Index: strace-5.7/io_uring.c
===================================================================
--- strace-5.7.orig/io_uring.c 2020-11-09 04:39:07.197892960 +0100
+++ strace-5.7/io_uring.c 2020-11-09 04:39:14.943826575 +0100
@@ -17,6 +17,7 @@
#include "xlat/uring_setup_flags.h"
#include "xlat/uring_enter_flags.h"
#include "xlat/uring_register_opcodes.h"
+#include "xlat/uring_cqring_flags.h"
#ifdef HAVE_STRUCT_IO_URING_PARAMS
# ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
@@ -88,10 +89,12 @@
PRINT_FIELD_U(", ", params.cq_off, ring_entries);
PRINT_FIELD_U(", ", params.cq_off, overflow);
PRINT_FIELD_U(", ", params.cq_off, cqes);
- if (!IS_ARRAY_ZERO(params.cq_off.resv)) {
- PRINT_FIELD_ARRAY(", ", params.cq_off, resv, tcp,
- print_xint64_array_member);
- }
+ PRINT_FIELD_FLAGS(", ", params.cq_off, flags,
+ uring_cqring_flags, "IORING_CQ_???");
+ if (params.cq_off.resv1)
+ PRINT_FIELD_X(", ", params.cq_off, resv1);
+ if (params.cq_off.resv2)
+ PRINT_FIELD_X(", ", params.cq_off, resv2);
tprints("}");
}
tprints("}");
Index: strace-5.7/tests/io_uring_setup.c
===================================================================
--- strace-5.7.orig/tests/io_uring_setup.c 2020-11-09 04:39:07.197892960 +0100
+++ strace-5.7/tests/io_uring_setup.c 2020-11-09 04:39:14.943826575 +0100
@@ -27,6 +27,7 @@
# include "xlat.h"
# include "xlat/uring_setup_features.h"
+# include "xlat/uring_cqring_flags.h"
# ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES
# ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD
@@ -144,20 +145,40 @@
params->sq_off.resv2);
printf("}, cq_off={head=%u, tail=%u, ring_mask=%u"
- ", ring_entries=%u, overflow=%u, cqes=%u",
+ ", ring_entries=%u, overflow=%u, cqes=%u, flags=",
params->cq_off.head,
params->cq_off.tail,
params->cq_off.ring_mask,
params->cq_off.ring_entries,
params->cq_off.overflow,
params->cq_off.cqes);
- if (params->cq_off.resv[0] || params->cq_off.resv[1]) {
- printf(", resv=[%#llx, %#llx]",
+#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS
+ printflags(uring_cqring_flags,
+ params->cq_off.flags,
+ "IORING_CQ_???");
+ if (params->cq_off.resv1)
+ printf(", resv1=%#x", params->cq_off.resv1);
+ if (params->cq_off.resv2)
+ printf(", resv2=%#llx",
(unsigned long long)
- params->cq_off.resv[0],
+ params->cq_off.resv2);
+#else
+ union {
+ struct {
+ uint32_t flags;
+ uint32_t resv1;
+ } s;
+ uint64_t v;
+ } u = { .v = params->cq_off.resv[0] };
+ printflags(uring_cqring_flags, u.s.flags,
+ "IORING_CQ_???");
+ if (u.s.resv1)
+ printf(", resv1=%#x", u.s.resv1);
+ if (params->cq_off.resv[1])
+ printf(", resv2=%#llx",
(unsigned long long)
params->cq_off.resv[1]);
- }
+#endif
printf("}}) = %ld<anon_inode:[io_uring]>\n", rc);
}
Index: strace-5.7/types/io_uring.h
===================================================================
--- strace-5.7.orig/types/io_uring.h 2020-11-09 04:39:07.198892952 +0100
+++ strace-5.7/types/io_uring.h 2020-11-09 04:39:14.944826567 +0100
@@ -31,7 +31,9 @@
uint32_t ring_entries;
uint32_t overflow;
uint32_t cqes;
- uint64_t resv[2];
+ /** Added by v5.8-rc1~190^2~22 */ uint32_t flags;
+ /** Added by v5.8-rc1~190^2~22 */ uint32_t resv1;
+ /** Added by v5.8-rc1~190^2~22 */ uint64_t resv2;
} struct_io_cqring_offsets;
typedef struct {
Index: strace-5.7/xlat/uring_cqring_flags.in
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/xlat/uring_cqring_flags.in 2020-11-09 04:39:14.944826567 +0100
@@ -0,0 +1 @@
+IORING_CQ_EVENTFD_DISABLED 1U
Index: strace-5.7/Makefile.in
===================================================================
--- strace-5.7.orig/Makefile.in 2020-11-09 04:39:07.201892926 +0100
+++ strace-5.7/Makefile.in 2020-11-09 04:42:54.519945367 +0100
@@ -1506,10 +1506,10 @@
xlat/uffd_register_mode_flags.in xlat/uffd_zeropage_flags.in \
xlat/umount_flags.in xlat/unix_diag_attrs.in \
xlat/unix_diag_show.in xlat/unshare_flags.in \
- xlat/uring_enter_flags.in xlat/uring_op_flags.in \
- xlat/uring_ops.in xlat/uring_register_opcodes.in \
- xlat/uring_setup_features.in xlat/uring_setup_flags.in \
- xlat/usagewho.in xlat/v4l2_buf_flags.in \
+ xlat/uring_cqring_flags.in xlat/uring_enter_flags.in \
+ xlat/uring_op_flags.in xlat/uring_ops.in \
+ xlat/uring_register_opcodes.in xlat/uring_setup_features.in \
+ xlat/uring_setup_flags.in xlat/usagewho.in xlat/v4l2_buf_flags.in \
xlat/v4l2_buf_flags_masks.in xlat/v4l2_buf_flags_ts_src.in \
xlat/v4l2_buf_flags_ts_type.in xlat/v4l2_buf_types.in \
xlat/v4l2_capture_modes.in xlat/v4l2_colorspaces.in \
@@ -1755,10 +1755,10 @@
xlat/uffd_register_mode_flags.h xlat/uffd_zeropage_flags.h \
xlat/umount_flags.h xlat/unix_diag_attrs.h \
xlat/unix_diag_show.h xlat/unshare_flags.h \
- xlat/uring_enter_flags.h xlat/uring_op_flags.h \
- xlat/uring_ops.h xlat/uring_register_opcodes.h \
- xlat/uring_setup_features.h xlat/uring_setup_flags.h \
- xlat/usagewho.h xlat/v4l2_buf_flags.h \
+ xlat/uring_cqring_flags.h xlat/uring_enter_flags.h \
+ xlat/uring_op_flags.h xlat/uring_ops.h \
+ xlat/uring_register_opcodes.h xlat/uring_setup_features.h \
+ xlat/uring_setup_flags.h xlat/usagewho.h xlat/v4l2_buf_flags.h \
xlat/v4l2_buf_flags_masks.h xlat/v4l2_buf_flags_ts_src.h \
xlat/v4l2_buf_flags_ts_type.h xlat/v4l2_buf_types.h \
xlat/v4l2_capture_modes.h xlat/v4l2_colorspaces.h \
@@ -9974,6 +9974,8 @@
$(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
$(top_srcdir)/xlat/unshare_flags.h: $(top_srcdir)/xlat/unshare_flags.in $(top_srcdir)/xlat/gen.sh
$(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
+$(top_srcdir)/xlat/uring_cqring_flags.h: $(top_srcdir)/xlat/uring_cqring_flags.in $(top_srcdir)/xlat/gen.sh
+ $(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
$(top_srcdir)/xlat/uring_enter_flags.h: $(top_srcdir)/xlat/uring_enter_flags.in $(top_srcdir)/xlat/gen.sh
$(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
$(top_srcdir)/xlat/uring_op_flags.h: $(top_srcdir)/xlat/uring_op_flags.in $(top_srcdir)/xlat/gen.sh
Index: strace-5.7/configure
===================================================================
--- strace-5.7.orig/configure 2020-11-09 04:39:07.205892892 +0100
+++ strace-5.7/configure 2020-11-09 05:07:10.675485410 +0100
@@ -12580,7 +12580,17 @@
#define HAVE_LINUX_IO_URING_H 1
_ACEOF
- ac_fn_c_check_member "$LINENO" "struct io_uring_params" "features" "ac_cv_member_struct_io_uring_params_features" "#include <linux/io_uring.h>
+ ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "flags" "ac_cv_member_struct_io_cqring_offsets_flags" "#include <linux/io_uring.h>
+"
+if test "x$ac_cv_member_struct_io_cqring_offsets_flags" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct io_uring_params" "features" "ac_cv_member_struct_io_uring_params_features" "#include <linux/io_uring.h>
"
if test "x$ac_cv_member_struct_io_uring_params_features" = xyes; then :
Index: strace-5.7/tests-m32/io_uring_setup.c
===================================================================
--- strace-5.7.orig/tests-m32/io_uring_setup.c 2020-11-09 04:39:07.206892883 +0100
+++ strace-5.7/tests-m32/io_uring_setup.c 2020-11-09 04:39:14.951826507 +0100
@@ -27,6 +27,7 @@
# include "xlat.h"
# include "xlat/uring_setup_features.h"
+# include "xlat/uring_cqring_flags.h"
# ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES
# ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD
@@ -144,20 +145,40 @@
params->sq_off.resv2);
printf("}, cq_off={head=%u, tail=%u, ring_mask=%u"
- ", ring_entries=%u, overflow=%u, cqes=%u",
+ ", ring_entries=%u, overflow=%u, cqes=%u, flags=",
params->cq_off.head,
params->cq_off.tail,
params->cq_off.ring_mask,
params->cq_off.ring_entries,
params->cq_off.overflow,
params->cq_off.cqes);
- if (params->cq_off.resv[0] || params->cq_off.resv[1]) {
- printf(", resv=[%#llx, %#llx]",
+#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS
+ printflags(uring_cqring_flags,
+ params->cq_off.flags,
+ "IORING_CQ_???");
+ if (params->cq_off.resv1)
+ printf(", resv1=%#x", params->cq_off.resv1);
+ if (params->cq_off.resv2)
+ printf(", resv2=%#llx",
(unsigned long long)
- params->cq_off.resv[0],
+ params->cq_off.resv2);
+#else
+ union {
+ struct {
+ uint32_t flags;
+ uint32_t resv1;
+ } s;
+ uint64_t v;
+ } u = { .v = params->cq_off.resv[0] };
+ printflags(uring_cqring_flags, u.s.flags,
+ "IORING_CQ_???");
+ if (u.s.resv1)
+ printf(", resv1=%#x", u.s.resv1);
+ if (params->cq_off.resv[1])
+ printf(", resv2=%#llx",
(unsigned long long)
params->cq_off.resv[1]);
- }
+#endif
printf("}}) = %ld<anon_inode:[io_uring]>\n", rc);
}
Index: strace-5.7/tests-mx32/io_uring_setup.c
===================================================================
--- strace-5.7.orig/tests-mx32/io_uring_setup.c 2020-11-09 04:39:07.206892883 +0100
+++ strace-5.7/tests-mx32/io_uring_setup.c 2020-11-09 04:39:14.951826507 +0100
@@ -27,6 +27,7 @@
# include "xlat.h"
# include "xlat/uring_setup_features.h"
+# include "xlat/uring_cqring_flags.h"
# ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES
# ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD
@@ -144,20 +145,40 @@
params->sq_off.resv2);
printf("}, cq_off={head=%u, tail=%u, ring_mask=%u"
- ", ring_entries=%u, overflow=%u, cqes=%u",
+ ", ring_entries=%u, overflow=%u, cqes=%u, flags=",
params->cq_off.head,
params->cq_off.tail,
params->cq_off.ring_mask,
params->cq_off.ring_entries,
params->cq_off.overflow,
params->cq_off.cqes);
- if (params->cq_off.resv[0] || params->cq_off.resv[1]) {
- printf(", resv=[%#llx, %#llx]",
+#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS
+ printflags(uring_cqring_flags,
+ params->cq_off.flags,
+ "IORING_CQ_???");
+ if (params->cq_off.resv1)
+ printf(", resv1=%#x", params->cq_off.resv1);
+ if (params->cq_off.resv2)
+ printf(", resv2=%#llx",
(unsigned long long)
- params->cq_off.resv[0],
+ params->cq_off.resv2);
+#else
+ union {
+ struct {
+ uint32_t flags;
+ uint32_t resv1;
+ } s;
+ uint64_t v;
+ } u = { .v = params->cq_off.resv[0] };
+ printflags(uring_cqring_flags, u.s.flags,
+ "IORING_CQ_???");
+ if (u.s.resv1)
+ printf(", resv1=%#x", u.s.resv1);
+ if (params->cq_off.resv[1])
+ printf(", resv2=%#llx",
(unsigned long long)
params->cq_off.resv[1]);
- }
+#endif
printf("}}) = %ld<anon_inode:[io_uring]>\n", rc);
}
Index: strace-5.7/xlat/uring_cqring_flags.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/xlat/uring_cqring_flags.h 2020-11-09 05:07:27.046345327 +0100
@@ -0,0 +1,48 @@
+/* Generated by ./xlat/gen.sh from ./xlat/uring_cqring_flags.in; do not edit. */
+
+#include "gcc_compat.h"
+#include "static_assert.h"
+
+#if defined(IORING_CQ_EVENTFD_DISABLED) || (defined(HAVE_DECL_IORING_CQ_EVENTFD_DISABLED) && HAVE_DECL_IORING_CQ_EVENTFD_DISABLED)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((IORING_CQ_EVENTFD_DISABLED) == (1U), "IORING_CQ_EVENTFD_DISABLED != 1U");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define IORING_CQ_EVENTFD_DISABLED 1U
+#endif
+
+#ifndef XLAT_MACROS_ONLY
+
+# ifdef IN_MPERS
+
+# error static const struct xlat uring_cqring_flags in mpers mode
+
+# else
+
+static const struct xlat_data uring_cqring_flags_xdata[] = {
+ XLAT(IORING_CQ_EVENTFD_DISABLED),
+ #define XLAT_VAL_0 ((unsigned) (IORING_CQ_EVENTFD_DISABLED))
+ #define XLAT_STR_0 STRINGIFY(IORING_CQ_EVENTFD_DISABLED)
+};
+static
+const struct xlat uring_cqring_flags[1] = { {
+ .data = uring_cqring_flags_xdata,
+ .size = ARRAY_SIZE(uring_cqring_flags_xdata),
+ .type = XT_NORMAL,
+ .flags_mask = 0
+# ifdef XLAT_VAL_0
+ | XLAT_VAL_0
+# endif
+ ,
+ .flags_strsz = 0
+# ifdef XLAT_STR_0
+ + sizeof(XLAT_STR_0)
+# endif
+ ,
+} };
+
+# undef XLAT_STR_0
+# undef XLAT_VAL_0
+# endif /* !IN_MPERS */
+
+#endif /* !XLAT_MACROS_ONLY */

View File

@ -1,217 +0,0 @@
From dd6b70f5d4db14b432f424071d262e87fa944c96 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sun, 28 Jun 2020 08:00:00 +0000
Subject: [PATCH 115/115] xlat: update IORING_* constants
* xlat/uring_ops.in (IORING_OP_TEE): New constant introduced by Linux
kernel commit v5.8-rc1~190^2~14.
* tests/io_uring_register.c: Update expected output.
---
tests/io_uring_register.c | 12 ++++++------
xlat/uring_ops.in | 1 +
2 files changed, 7 insertions(+), 6 deletions(-)
Index: strace-5.7/tests/io_uring_register.c
===================================================================
--- strace-5.7.orig/tests/io_uring_register.c 2020-11-09 04:44:38.311057254 +0100
+++ strace-5.7/tests/io_uring_register.c 2020-11-09 04:44:40.445038991 +0100
@@ -225,12 +225,12 @@
probe->ops[0].flags = 0;
probe->ops[0].resv2 = 0xbeefface;
- probe->ops[1].op = 32;
+ probe->ops[1].op = 33;
probe->ops[1].resv = 0;
probe->ops[1].flags = IO_URING_OP_SUPPORTED;
probe->ops[1].resv2 = 0xdeadc0de;
- probe->ops[2].op = 33;
+ probe->ops[2].op = 34;
probe->ops[2].resv = 0xaf;
probe->ops[2].flags = 0xbeef;
probe->ops[2].resv2 = 0;
@@ -245,22 +245,22 @@
", {last_op=IORING_OP_EPOLL_CTL, ops_len=%hhu"
", resv2=[0, %#x, 0], ops=["
"{op=IORING_OP_NOP, resv=0xde, flags=0, resv2=0xbeefface}, "
- "{op=IORING_OP_REMOVE_BUFFERS, flags=IO_URING_OP_SUPPORTED"
+ "{op=IORING_OP_TEE, flags=IO_URING_OP_SUPPORTED"
", resv2=0xdeadc0de}, "
- "{op=33 /* IORING_OP_??? */, resv=0xaf"
+ "{op=34 /* IORING_OP_??? */, resv=0xaf"
", flags=IO_URING_OP_SUPPORTED|0xbeee}, "
"{op=254 /* IORING_OP_??? */"
", flags=0xc0de /* IO_URING_OP_??? */}]}, 4) = %s\n",
fd_null, path_null, probe->ops_len, probe->resv2[1], errstr);
- probe->last_op = 33;
+ probe->last_op = 34;
probe->resv2[1] = 0;
fill_memory_ex(probe->ops, sizeof(probe->ops[0]) * (DEFAULT_STRLEN + 1),
0x40, 0x80);
sys_io_uring_register(fd_null, IORING_REGISTER_PROBE, probe,
DEFAULT_STRLEN + 1);
printf("io_uring_register(%u<%s>, IORING_REGISTER_PROBE"
- ", {last_op=33 /* IORING_OP_??? */, ops_len=%hhu, ops=[",
+ ", {last_op=34 /* IORING_OP_??? */, ops_len=%hhu, ops=[",
fd_null, path_null, probe->ops_len);
for (size_t i = 0; i < DEFAULT_STRLEN; i++) {
printf("%s{op=%u /* IORING_OP_??? */, resv=%#hhx"
Index: strace-5.7/xlat/uring_ops.in
===================================================================
--- strace-5.7.orig/xlat/uring_ops.in 2020-11-09 04:44:38.311057254 +0100
+++ strace-5.7/xlat/uring_ops.in 2020-11-09 04:44:40.445038991 +0100
@@ -32,3 +32,4 @@
IORING_OP_SPLICE 30
IORING_OP_PROVIDE_BUFFERS 31
IORING_OP_REMOVE_BUFFERS 32
+IORING_OP_TEE 33
Index: strace-5.7/tests-m32/io_uring_register.c
===================================================================
--- strace-5.7.orig/tests-m32/io_uring_register.c 2020-11-09 04:44:38.312057246 +0100
+++ strace-5.7/tests-m32/io_uring_register.c 2020-11-09 04:44:40.445038991 +0100
@@ -225,12 +225,12 @@
probe->ops[0].flags = 0;
probe->ops[0].resv2 = 0xbeefface;
- probe->ops[1].op = 32;
+ probe->ops[1].op = 33;
probe->ops[1].resv = 0;
probe->ops[1].flags = IO_URING_OP_SUPPORTED;
probe->ops[1].resv2 = 0xdeadc0de;
- probe->ops[2].op = 33;
+ probe->ops[2].op = 34;
probe->ops[2].resv = 0xaf;
probe->ops[2].flags = 0xbeef;
probe->ops[2].resv2 = 0;
@@ -245,22 +245,22 @@
", {last_op=IORING_OP_EPOLL_CTL, ops_len=%hhu"
", resv2=[0, %#x, 0], ops=["
"{op=IORING_OP_NOP, resv=0xde, flags=0, resv2=0xbeefface}, "
- "{op=IORING_OP_REMOVE_BUFFERS, flags=IO_URING_OP_SUPPORTED"
+ "{op=IORING_OP_TEE, flags=IO_URING_OP_SUPPORTED"
", resv2=0xdeadc0de}, "
- "{op=33 /* IORING_OP_??? */, resv=0xaf"
+ "{op=34 /* IORING_OP_??? */, resv=0xaf"
", flags=IO_URING_OP_SUPPORTED|0xbeee}, "
"{op=254 /* IORING_OP_??? */"
", flags=0xc0de /* IO_URING_OP_??? */}]}, 4) = %s\n",
fd_null, path_null, probe->ops_len, probe->resv2[1], errstr);
- probe->last_op = 33;
+ probe->last_op = 34;
probe->resv2[1] = 0;
fill_memory_ex(probe->ops, sizeof(probe->ops[0]) * (DEFAULT_STRLEN + 1),
0x40, 0x80);
sys_io_uring_register(fd_null, IORING_REGISTER_PROBE, probe,
DEFAULT_STRLEN + 1);
printf("io_uring_register(%u<%s>, IORING_REGISTER_PROBE"
- ", {last_op=33 /* IORING_OP_??? */, ops_len=%hhu, ops=[",
+ ", {last_op=34 /* IORING_OP_??? */, ops_len=%hhu, ops=[",
fd_null, path_null, probe->ops_len);
for (size_t i = 0; i < DEFAULT_STRLEN; i++) {
printf("%s{op=%u /* IORING_OP_??? */, resv=%#hhx"
Index: strace-5.7/tests-mx32/io_uring_register.c
===================================================================
--- strace-5.7.orig/tests-mx32/io_uring_register.c 2020-11-09 04:44:38.312057246 +0100
+++ strace-5.7/tests-mx32/io_uring_register.c 2020-11-09 04:44:40.446038982 +0100
@@ -225,12 +225,12 @@
probe->ops[0].flags = 0;
probe->ops[0].resv2 = 0xbeefface;
- probe->ops[1].op = 32;
+ probe->ops[1].op = 33;
probe->ops[1].resv = 0;
probe->ops[1].flags = IO_URING_OP_SUPPORTED;
probe->ops[1].resv2 = 0xdeadc0de;
- probe->ops[2].op = 33;
+ probe->ops[2].op = 34;
probe->ops[2].resv = 0xaf;
probe->ops[2].flags = 0xbeef;
probe->ops[2].resv2 = 0;
@@ -245,22 +245,22 @@
", {last_op=IORING_OP_EPOLL_CTL, ops_len=%hhu"
", resv2=[0, %#x, 0], ops=["
"{op=IORING_OP_NOP, resv=0xde, flags=0, resv2=0xbeefface}, "
- "{op=IORING_OP_REMOVE_BUFFERS, flags=IO_URING_OP_SUPPORTED"
+ "{op=IORING_OP_TEE, flags=IO_URING_OP_SUPPORTED"
", resv2=0xdeadc0de}, "
- "{op=33 /* IORING_OP_??? */, resv=0xaf"
+ "{op=34 /* IORING_OP_??? */, resv=0xaf"
", flags=IO_URING_OP_SUPPORTED|0xbeee}, "
"{op=254 /* IORING_OP_??? */"
", flags=0xc0de /* IO_URING_OP_??? */}]}, 4) = %s\n",
fd_null, path_null, probe->ops_len, probe->resv2[1], errstr);
- probe->last_op = 33;
+ probe->last_op = 34;
probe->resv2[1] = 0;
fill_memory_ex(probe->ops, sizeof(probe->ops[0]) * (DEFAULT_STRLEN + 1),
0x40, 0x80);
sys_io_uring_register(fd_null, IORING_REGISTER_PROBE, probe,
DEFAULT_STRLEN + 1);
printf("io_uring_register(%u<%s>, IORING_REGISTER_PROBE"
- ", {last_op=33 /* IORING_OP_??? */, ops_len=%hhu, ops=[",
+ ", {last_op=34 /* IORING_OP_??? */, ops_len=%hhu, ops=[",
fd_null, path_null, probe->ops_len);
for (size_t i = 0; i < DEFAULT_STRLEN; i++) {
printf("%s{op=%u /* IORING_OP_??? */, resv=%#hhx"
Index: strace-5.7/xlat/uring_ops.h
===================================================================
--- strace-5.7.orig/xlat/uring_ops.h 2020-11-09 04:44:38.313057237 +0100
+++ strace-5.7/xlat/uring_ops.h 2020-11-09 04:47:01.835829135 +0100
@@ -234,6 +234,13 @@
#else
# define IORING_OP_REMOVE_BUFFERS 32
#endif
+#if defined(IORING_OP_TEE) || (defined(HAVE_DECL_IORING_OP_TEE) && HAVE_DECL_IORING_OP_TEE)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((IORING_OP_TEE) == (33), "IORING_OP_TEE != 33");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define IORING_OP_TEE 33
+#endif
#ifndef XLAT_MACROS_ONLY
@@ -343,6 +350,9 @@
[IORING_OP_REMOVE_BUFFERS] = XLAT(IORING_OP_REMOVE_BUFFERS),
#define XLAT_VAL_32 ((unsigned) (IORING_OP_REMOVE_BUFFERS))
#define XLAT_STR_32 STRINGIFY(IORING_OP_REMOVE_BUFFERS)
+ [IORING_OP_TEE] = XLAT(IORING_OP_TEE),
+ #define XLAT_VAL_33 ((unsigned) (IORING_OP_TEE))
+ #define XLAT_STR_33 STRINGIFY(IORING_OP_TEE)
};
static
const struct xlat uring_ops[1] = { {
@@ -449,6 +459,9 @@
# ifdef XLAT_VAL_32
| XLAT_VAL_32
# endif
+# ifdef XLAT_VAL_33
+ | XLAT_VAL_33
+# endif
,
.flags_strsz = 0
# ifdef XLAT_STR_0
@@ -550,6 +563,9 @@
# ifdef XLAT_STR_32
+ sizeof(XLAT_STR_32)
# endif
+# ifdef XLAT_STR_33
+ + sizeof(XLAT_STR_33)
+# endif
,
} };
@@ -619,6 +635,8 @@
# undef XLAT_VAL_31
# undef XLAT_STR_32
# undef XLAT_VAL_32
+# undef XLAT_STR_33
+# undef XLAT_VAL_33
# endif /* !IN_MPERS */
#endif /* !XLAT_MACROS_ONLY */

View File

@ -1,84 +0,0 @@
From b0a361c0a9095b396ff7100203c767ec9ffd2cfa Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Tue, 16 Jun 2020 08:00:00 +0000
Subject: [PATCH] types: skip field lines that start with comments
This allows to exclude certain fields from type checks by placing
comments at the beginning of the corresponding lines.
* types/find_last_type_fields.awk: Skip lines starting with spaces
followed by "/".
---
types/find_last_type_fields.awk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: strace-5.7/types/find_last_type_fields.awk
===================================================================
--- strace-5.7.orig/types/find_last_type_fields.awk 2020-01-21 19:02:38.000000000 +0100
+++ strace-5.7/types/find_last_type_fields.awk 2020-11-09 04:47:06.976785148 +0100
@@ -17,7 +17,7 @@
print a[1] "." last_field
next
}
- if (match($0, /^[[:space:]]+[^];:[]+[[:space:]]+([^][:space:];:[]+)(\[[^];:[]*\])?;.*$/, a)) {
+ if (match($0, /^[[:space:]]+[^];[:space:]:\/[][^];:[]*[[:space:]]+([^][:space:];:[]+)(\[[^];:[]*\])?;.*$/, a)) {
last_field = a[1]
next
}
Index: strace-5.7/types/check-io_uring.c
===================================================================
--- strace-5.7.orig/types/check-io_uring.c 2020-11-09 04:47:06.977785139 +0100
+++ strace-5.7/types/check-io_uring.c 2020-11-09 04:49:10.033732186 +0100
@@ -14,13 +14,13 @@
#endif /* HAVE_STRUCT_IO_SQRING_OFFSETS */
#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
+# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_CQES
static_assert(sizeof(struct io_cqring_offsets) == sizeof(struct_io_cqring_offsets),
"struct io_cqring_offsets size mismatch, please update the decoder or fix the kernel");
# else
-static_assert(sizeof(struct io_cqring_offsets) <= offsetof(struct_io_cqring_offsets, resv),
+static_assert(sizeof(struct io_cqring_offsets) <= offsetof(struct_io_cqring_offsets, cqes),
"struct io_cqring_offsets size mismatch, please update the decoder or fix the kernel");
-# endif /* HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
+# endif /* HAVE_STRUCT_IO_CQRING_OFFSETS_CQES */
#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
#ifdef HAVE_STRUCT_IO_URING_PARAMS
Index: strace-5.7/config.h.in
===================================================================
--- strace-5.7.orig/config.h.in 2020-11-09 04:47:06.980785114 +0100
+++ strace-5.7/config.h.in 2020-11-09 04:50:11.871203054 +0100
@@ -2596,8 +2596,8 @@
/* Define to 1 if the system has the type `struct io_cqring_offsets'. */
#undef HAVE_STRUCT_IO_CQRING_OFFSETS
-/* Define to 1 if `resv' is a member of `struct io_cqring_offsets'. */
-#undef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
+/* Define to 1 if `cqes' is a member of `struct io_cqring_offsets'. */
+#undef HAVE_STRUCT_IO_CQRING_OFFSETS_CQES
/* Define to 1 if the system has the type `struct io_sqring_offsets'. */
#undef HAVE_STRUCT_IO_SQRING_OFFSETS
Index: strace-5.7/configure
===================================================================
--- strace-5.7.orig/configure 2020-11-09 04:47:06.988785045 +0100
+++ strace-5.7/configure 2020-11-09 04:51:12.500684263 +0100
@@ -13475,13 +13475,13 @@
#define HAVE_STRUCT_IO_CQRING_OFFSETS 1
_ACEOF
-ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "resv" "ac_cv_member_struct_io_cqring_offsets_resv" "$ac_includes_default
+ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "cqes" "ac_cv_member_struct_io_cqring_offsets_cqes" "$ac_includes_default
#include <linux/io_uring.h>
"
-if test "x$ac_cv_member_struct_io_cqring_offsets_resv" = xyes; then :
+if test "x$ac_cv_member_struct_io_cqring_offsets_cqes" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IO_CQRING_OFFSETS_RESV 1
+#define HAVE_STRUCT_IO_CQRING_OFFSETS_CQES 1
_ACEOF

View File

@ -1,155 +0,0 @@
From 8806a21b612d76c8732d0df2ebaf52b62166ce51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Sat, 13 Jun 2020 18:18:31 +0200
Subject: [PATCH 119/138] print_fields.h: add PRINT_FIELD_LEN macro
* print_fields.h (PRINT_FIELD_LEN): New macro.
* net.c: (print_get_linger, print_get_ucred, print_tpacket_stats):
Rewrite using PRINT_FIELD_LEN.
---
net.c | 90 ++++++----------------------------------------------------
print_fields.h | 15 ++++++++++
2 files changed, 23 insertions(+), 82 deletions(-)
diff --git a/net.c b/net.c
index a58fa92..9ea34b2 100644
--- a/net.c
+++ b/net.c
@@ -579,24 +579,8 @@ print_get_linger(struct tcb *const tcp, const kernel_ulong_t addr,
if (umoven_or_printaddr(tcp, addr, len, &linger))
return;
- if (len < sizeof(linger.l_onoff)) {
- tprints("{l_onoff=");
- print_quoted_string((void *) &linger.l_onoff,
- len, QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_D("{", linger, l_onoff);
-
- if (len > offsetof(struct linger, l_linger)) {
- len -= offsetof(struct linger, l_linger);
- if (len < sizeof(linger.l_linger)) {
- tprints(", l_linger=");
- print_quoted_string((void *) &linger.l_linger,
- len, QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_D(", ", linger, l_linger);
- }
- }
- }
+ PRINT_FIELD_LEN("{", linger, l_onoff, len, PRINT_FIELD_D);
+ PRINT_FIELD_LEN(", ", linger, l_linger, len, PRINT_FIELD_D);
tprints("}");
}
@@ -617,38 +601,9 @@ print_get_ucred(struct tcb *const tcp, const kernel_ulong_t addr,
if (umoven_or_printaddr(tcp, addr, len, &uc))
return;
- if (len < sizeof(uc.pid)) {
- tprints("{pid=");
- print_quoted_string((void *) &uc.pid,
- len, QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_D("{", uc, pid);
-
- if (len > offsetof(struct ucred, uid)) {
- len -= offsetof(struct ucred, uid);
- if (len < sizeof(uc.uid)) {
- tprints(", uid=");
- print_quoted_string((void *) &uc.uid,
- len, QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_UID(", ", uc, uid);
-
- if (len > offsetof(struct ucred, gid) -
- offsetof(struct ucred, uid)) {
- len -= offsetof(struct ucred, gid) -
- offsetof(struct ucred, uid);
- if (len < sizeof(uc.gid)) {
- tprints(", gid=");
- print_quoted_string((void *) &uc.gid,
- len,
- QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_UID(", ", uc, gid);
- }
- }
- }
- }
- }
+ PRINT_FIELD_LEN("{", uc, pid, len, PRINT_FIELD_D);
+ PRINT_FIELD_LEN(", ", uc, uid, len, PRINT_FIELD_UID);
+ PRINT_FIELD_LEN(", ", uc, gid, len, PRINT_FIELD_UID);
tprints("}");
}
@@ -688,38 +643,9 @@ print_tpacket_stats(struct tcb *const tcp, const kernel_ulong_t addr,
if (umoven_or_printaddr(tcp, addr, len, &stats))
return;
- if (len < sizeof(stats.tp_packets)) {
- tprints("{tp_packets=");
- print_quoted_string((void *) &stats.tp_packets,
- len, QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_U("{", stats, tp_packets);
-
- if (len > offsetof(struct tp_stats, tp_drops)) {
- len -= offsetof(struct tp_stats, tp_drops);
- if (len < sizeof(stats.tp_drops)) {
- tprints(", tp_drops=");
- print_quoted_string((void *) &stats.tp_drops,
- len, QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_U(", ", stats, tp_drops);
-
- if (len > offsetof(struct tp_stats, tp_freeze_q_cnt) -
- offsetof(struct tp_stats, tp_drops)) {
- len -= offsetof(struct tp_stats, tp_freeze_q_cnt) -
- offsetof(struct tp_stats, tp_drops);
- if (len < sizeof(stats.tp_freeze_q_cnt)) {
- tprints(", tp_freeze_q_cnt=");
- print_quoted_string((void *) &stats.tp_freeze_q_cnt,
- len,
- QUOTE_FORCE_HEX);
- } else {
- PRINT_FIELD_U(", ", stats, tp_freeze_q_cnt);
- }
- }
- }
- }
- }
+ PRINT_FIELD_LEN("{", stats, tp_packets, len, PRINT_FIELD_U);
+ PRINT_FIELD_LEN(", ", stats, tp_drops, len, PRINT_FIELD_U);
+ PRINT_FIELD_LEN(", ", stats, tp_freeze_q_cnt, len, PRINT_FIELD_U);
tprints("}");
}
#endif /* PACKET_STATISTICS */
diff --git a/print_fields.h b/print_fields.h
index 02c56bf..70dbbff 100644
--- a/print_fields.h
+++ b/print_fields.h
@@ -277,4 +277,19 @@
(size_), (hwtype_)); \
} while (0)
+# define PRINT_FIELD_LEN(prefix_, where_, field_, \
+ len_, print_func_, ...) \
+ do { \
+ unsigned int start = offsetof(typeof(where_), field_); \
+ unsigned int end = start + sizeof(where_.field_); \
+ if (len_ >= end) { \
+ print_func_(prefix_, where_, field_, \
+ ##__VA_ARGS__); \
+ } else if (len_ > start) { \
+ tprintf("%s%s=", prefix_, #field_); \
+ print_quoted_string((void *)&where_.field_, \
+ len_ - start, QUOTE_FORCE_HEX); \
+ } \
+ } while (0)
+
#endif /* !STRACE_PRINT_FIELDS_H */
--
2.1.4

View File

@ -1,157 +0,0 @@
From c9e41cd3485fa1a65dc6206c5b210b4be4c5597c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Sat, 13 Jun 2020 18:18:32 +0200
Subject: [PATCH 120/138] Move ilog* functions from util.c to defs.h
* util.c (ILOG2_ITER_, ilog2_klong, ilog2_64, ilog2_32): Move ...
* defs.h: ... here.
---
defs.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
util.c | 62 --------------------------------------------------------------
2 files changed, 60 insertions(+), 62 deletions(-)
diff --git a/defs.h b/defs.h
index 3aa07fb..d8bd513 100644
--- a/defs.h
+++ b/defs.h
@@ -1698,4 +1698,64 @@ scno_is_valid(kernel_ulong_t scno)
# define SYS_FUNC(syscall_name) int SYS_FUNC_NAME(sys_ ## syscall_name)(struct tcb *tcp)
+#define ILOG2_ITER_(val_, ret_, bit_) \
+ do { \
+ typeof(ret_) shift_ = \
+ ((val_) > ((((typeof(val_)) 1) \
+ << (1 << (bit_))) - 1)) << (bit_); \
+ (val_) >>= shift_; \
+ (ret_) |= shift_; \
+ } while (0)
+
+/**
+ * Calculate floor(log2(val)), with the exception of val == 0, for which 0
+ * is returned as well.
+ *
+ * @param val 64-bit value to calculate integer base-2 logarithm for.
+ * @return (unsigned int) floor(log2(val)) if val > 0, 0 if val == 0.
+ */
+static inline unsigned int
+ilog2_64(uint64_t val)
+{
+ unsigned int ret = 0;
+
+ ILOG2_ITER_(val, ret, 5);
+ ILOG2_ITER_(val, ret, 4);
+ ILOG2_ITER_(val, ret, 3);
+ ILOG2_ITER_(val, ret, 2);
+ ILOG2_ITER_(val, ret, 1);
+ ILOG2_ITER_(val, ret, 0);
+
+ return ret;
+}
+
+/**
+ * Calculate floor(log2(val)), with the exception of val == 0, for which 0
+ * is returned as well.
+ *
+ * @param val 32-bit value to calculate integer base-2 logarithm for.
+ * @return (unsigned int) floor(log2(val)) if val > 0, 0 if val == 0.
+ */
+static inline unsigned int
+ilog2_32(uint32_t val)
+{
+ unsigned int ret = 0;
+
+ ILOG2_ITER_(val, ret, 4);
+ ILOG2_ITER_(val, ret, 3);
+ ILOG2_ITER_(val, ret, 2);
+ ILOG2_ITER_(val, ret, 1);
+ ILOG2_ITER_(val, ret, 0);
+
+ return ret;
+}
+
+#if SIZEOF_KERNEL_LONG_T > 4
+# define ilog2_klong ilog2_64
+#else
+# define ilog2_klong ilog2_32
+#endif
+
+#undef ILOG2_ITER_
+
#endif /* !STRACE_DEFS_H */
diff --git a/util.c b/util.c
index 59696b5..cde76c1 100644
--- a/util.c
+++ b/util.c
@@ -1120,68 +1120,6 @@ dumpiov_upto(struct tcb *const tcp, const int len, const kernel_ulong_t addr,
#undef iov
}
-#define ILOG2_ITER_(val_, ret_, bit_) \
- do { \
- typeof(ret_) shift_ = \
- ((val_) > ((((typeof(val_)) 1) \
- << (1 << (bit_))) - 1)) << (bit_); \
- (val_) >>= shift_; \
- (ret_) |= shift_; \
- } while (0)
-
-#if SIZEOF_KERNEL_LONG_T > 4
-
-# define ilog2_klong ilog2_64
-/**
- * Calculate floor(log2(val)), with the exception of val == 0, for which 0
- * is returned as well.
- *
- * @param val 64-bit value to calculate integer base-2 logarithm for.
- * @return (unsigned int) floor(log2(val)) if val > 0, 0 if val == 0.
- */
-static inline unsigned int
-ilog2_64(uint64_t val)
-{
- unsigned int ret = 0;
-
- ILOG2_ITER_(val, ret, 5);
- ILOG2_ITER_(val, ret, 4);
- ILOG2_ITER_(val, ret, 3);
- ILOG2_ITER_(val, ret, 2);
- ILOG2_ITER_(val, ret, 1);
- ILOG2_ITER_(val, ret, 0);
-
- return ret;
-}
-
-#else /* SIZEOF_KERNEL_LONG_T == 4 */
-
-# define ilog2_klong ilog2_32
-/**
- * Calculate floor(log2(val)), with the exception of val == 0, for which 0
- * is returned as well.
- *
- * @param val 32-bit value to calculate integer base-2 logarithm for.
- * @return (unsigned int) floor(log2(val)) if val > 0, 0 if val == 0.
- */
-static inline unsigned int
-ilog2_32(uint32_t val)
-{
- unsigned int ret = 0;
-
- ILOG2_ITER_(val, ret, 4);
- ILOG2_ITER_(val, ret, 3);
- ILOG2_ITER_(val, ret, 2);
- ILOG2_ITER_(val, ret, 1);
- ILOG2_ITER_(val, ret, 0);
-
- return ret;
-}
-
-#endif /* SIZEOF_KERNEL_LONG_T */
-
-#undef ILOG2_ITER_
-
void
dumpstr(struct tcb *const tcp, const kernel_ulong_t addr,
const kernel_ulong_t len)
--
2.1.4

View File

@ -1,235 +0,0 @@
From c5be5bb949988c262012e7f4763b1d658c1769b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Fri, 19 Jun 2020 12:06:42 +0200
Subject: [PATCH 122/138] tests/inject-nf.test: replace getpid with geteuid
Since we treat PIDs as signed integers, large values (>=2^31) will
cause overflow when we use printpid.
UIDs are treated as unsigned integers, so geteuid is a good alternative.
(getuid would be problematic, as it does not exists on alpha).
Also, on systems where geteuid32 exists, geteuid returns maximum 16 bit
values, so we have to use geteuid32 in this case.
[ldv: geteuid syscall was introduced on Alpha by Linux kernel commit
v5.1-rc1~160^2~3^2~1, so this test will not work on old Alpha kernels.]
* tests/inject-nf.c: Replace getpid with either geteuid32 or geteuid.
[__alpha__]: Remove.
[__NR_geteuid32]: New condition.
* tests/inject-nf.test (SYSCALL): Replace getpid with '/^geteuid(32)?$'.
Remove alpha workaround.
---
tests/inject-nf.c | 20 +++++++++-----------
tests/inject-nf.test | 9 +--------
2 files changed, 10 insertions(+), 19 deletions(-)
Index: strace-5.7/tests/inject-nf.c
===================================================================
--- strace-5.7.orig/tests/inject-nf.c 2020-09-09 14:50:44.159739392 +0200
+++ strace-5.7/tests/inject-nf.c 2020-09-09 14:56:17.193937896 +0200
@@ -16,28 +16,26 @@
#include "raw_syscall.h"
-#ifdef __alpha__
-/* alpha has no getpid */
-# define SC_NR __NR_getpgrp
-# define SC_NAME "getpgrp"
-# define getpid getpgrp
+#ifdef __NR_geteuid32
+# define SC_NR __NR_geteuid32
+# define SC_NAME "geteuid32"
#else
-# define SC_NR __NR_getpid
-# define SC_NAME "getpid"
+# define SC_NR __NR_geteuid
+# define SC_NAME "geteuid"
#endif
#ifdef raw_syscall_0
# define INVOKE_SC(err) raw_syscall_0(SC_NR, &err)
#else
-/* No raw_syscall_0, let's use getpid() and hope for the best. */
-# define INVOKE_SC(err) getpid()
+/* No raw_syscall_0, let's use geteuid() and hope for the best. */
+# define INVOKE_SC(err) geteuid()
#endif
/*
* This prototype is intentionally different
* from the prototype provided by <unistd.h>.
*/
-extern kernel_ulong_t getpid(void);
+extern kernel_ulong_t geteuid(void);
int
main(int ac, char **av)
@@ -45,7 +43,7 @@
assert(ac == 1 || ac == 2);
kernel_ulong_t expected =
- (ac == 1) ? getpid() : strtoull(av[1], NULL, 0);
+ (ac == 1) ? geteuid() : strtoull(av[1], NULL, 0);
kernel_ulong_t err = 0;
kernel_ulong_t rc = INVOKE_SC(err);
Index: strace-5.7/tests/inject-nf.test
===================================================================
--- strace-5.7.orig/tests/inject-nf.test 2020-09-09 14:50:44.159739392 +0200
+++ strace-5.7/tests/inject-nf.test 2020-09-09 14:56:17.194937896 +0200
@@ -9,14 +9,7 @@
. "${srcdir=.}/scno_tampering.sh"
-case "$STRACE_ARCH" in
-alpha)
- SYSCALL=getpgrp
- ;;
-*)
- SYSCALL=getpid
- ;;
-esac
+SYSCALL='/^geteuid(32)?$'
run_prog
prog="$args"
Index: strace-5.7/tests-m32/inject-nf.c
===================================================================
--- strace-5.7.orig/tests-m32/inject-nf.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-m32/inject-nf.c 2020-09-09 14:58:03.687001371 +0200
@@ -16,28 +16,26 @@
#include "raw_syscall.h"
-#ifdef __alpha__
-/* alpha has no getpid */
-# define SC_NR __NR_getpgrp
-# define SC_NAME "getpgrp"
-# define getpid getpgrp
+#ifdef __NR_geteuid32
+# define SC_NR __NR_geteuid32
+# define SC_NAME "geteuid32"
#else
-# define SC_NR __NR_getpid
-# define SC_NAME "getpid"
+# define SC_NR __NR_geteuid
+# define SC_NAME "geteuid"
#endif
#ifdef raw_syscall_0
# define INVOKE_SC(err) raw_syscall_0(SC_NR, &err)
#else
-/* No raw_syscall_0, let's use getpid() and hope for the best. */
-# define INVOKE_SC(err) getpid()
+/* No raw_syscall_0, let's use geteuid() and hope for the best. */
+# define INVOKE_SC(err) geteuid()
#endif
/*
* This prototype is intentionally different
* from the prototype provided by <unistd.h>.
*/
-extern kernel_ulong_t getpid(void);
+extern kernel_ulong_t geteuid(void);
int
main(int ac, char **av)
@@ -45,7 +43,7 @@
assert(ac == 1 || ac == 2);
kernel_ulong_t expected =
- (ac == 1) ? getpid() : strtoull(av[1], NULL, 0);
+ (ac == 1) ? geteuid() : strtoull(av[1], NULL, 0);
kernel_ulong_t err = 0;
kernel_ulong_t rc = INVOKE_SC(err);
Index: strace-5.7/tests-m32/inject-nf.test
===================================================================
--- strace-5.7.orig/tests-m32/inject-nf.test 2018-12-25 00:46:43.000000000 +0100
+++ strace-5.7/tests-m32/inject-nf.test 2020-09-09 14:58:03.727001394 +0200
@@ -9,14 +9,7 @@
. "${srcdir=.}/scno_tampering.sh"
-case "$STRACE_ARCH" in
-alpha)
- SYSCALL=getpgrp
- ;;
-*)
- SYSCALL=getpid
- ;;
-esac
+SYSCALL='/^geteuid(32)?$'
run_prog
prog="$args"
Index: strace-5.7/tests-mx32/inject-nf.c
===================================================================
--- strace-5.7.orig/tests-mx32/inject-nf.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-mx32/inject-nf.c 2020-09-09 14:58:03.708001383 +0200
@@ -16,28 +16,26 @@
#include "raw_syscall.h"
-#ifdef __alpha__
-/* alpha has no getpid */
-# define SC_NR __NR_getpgrp
-# define SC_NAME "getpgrp"
-# define getpid getpgrp
+#ifdef __NR_geteuid32
+# define SC_NR __NR_geteuid32
+# define SC_NAME "geteuid32"
#else
-# define SC_NR __NR_getpid
-# define SC_NAME "getpid"
+# define SC_NR __NR_geteuid
+# define SC_NAME "geteuid"
#endif
#ifdef raw_syscall_0
# define INVOKE_SC(err) raw_syscall_0(SC_NR, &err)
#else
-/* No raw_syscall_0, let's use getpid() and hope for the best. */
-# define INVOKE_SC(err) getpid()
+/* No raw_syscall_0, let's use geteuid() and hope for the best. */
+# define INVOKE_SC(err) geteuid()
#endif
/*
* This prototype is intentionally different
* from the prototype provided by <unistd.h>.
*/
-extern kernel_ulong_t getpid(void);
+extern kernel_ulong_t geteuid(void);
int
main(int ac, char **av)
@@ -45,7 +43,7 @@
assert(ac == 1 || ac == 2);
kernel_ulong_t expected =
- (ac == 1) ? getpid() : strtoull(av[1], NULL, 0);
+ (ac == 1) ? geteuid() : strtoull(av[1], NULL, 0);
kernel_ulong_t err = 0;
kernel_ulong_t rc = INVOKE_SC(err);
Index: strace-5.7/tests-mx32/inject-nf.test
===================================================================
--- strace-5.7.orig/tests-mx32/inject-nf.test 2018-12-25 00:46:43.000000000 +0100
+++ strace-5.7/tests-mx32/inject-nf.test 2020-09-09 14:58:03.750001408 +0200
@@ -9,14 +9,7 @@
. "${srcdir=.}/scno_tampering.sh"
-case "$STRACE_ARCH" in
-alpha)
- SYSCALL=getpgrp
- ;;
-*)
- SYSCALL=getpid
- ;;
-esac
+SYSCALL='/^geteuid(32)?$'
run_prog
prog="$args"

View File

@ -1,60 +0,0 @@
From eba856eb0246ce2a2ba99d68611da1af7814080e Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Mon, 13 Jul 2020 08:00:00 +0000
Subject: [PATCH 123/138] fcntl: use print_fields.h macros
* fcntl.c: Include "print_fields.h".
(print_struct_flock64, print_f_owner_ex): Use PRINT_FIELD_* macros
from print_fields.h.
---
fcntl.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/fcntl.c b/fcntl.c
index 0b4221c..e84549e 100644
--- a/fcntl.c
+++ b/fcntl.c
@@ -11,6 +11,7 @@
#include "defs.h"
#include "flock.h"
+#include "print_fields.h"
#include "xlat/f_owner_types.h"
#include "xlat/f_seals.h"
@@ -22,14 +23,12 @@
static void
print_struct_flock64(const struct_kernel_flock64 *fl, const int getlk)
{
- tprints("{l_type=");
- printxval(lockfcmds, (unsigned short) fl->l_type, "F_???");
- tprints(", l_whence=");
- printxval(whence_codes, (unsigned short) fl->l_whence, "SEEK_???");
- tprintf(", l_start=%" PRId64 ", l_len=%" PRId64,
- (int64_t) fl->l_start, (int64_t) fl->l_len);
+ PRINT_FIELD_XVAL("{", *fl, l_type, lockfcmds, "F_???");
+ PRINT_FIELD_XVAL(", ", *fl, l_whence, whence_codes, "SEEK_???");
+ PRINT_FIELD_D(", ", *fl, l_start);
+ PRINT_FIELD_D(", ", *fl, l_len);
if (getlk)
- tprintf(", l_pid=%lu", (unsigned long) fl->l_pid);
+ PRINT_FIELD_D(", ", *fl, l_pid);
tprints("}");
}
@@ -59,9 +58,9 @@ print_f_owner_ex(struct tcb *const tcp, const kernel_ulong_t addr)
if (umove_or_printaddr(tcp, addr, &owner))
return;
- tprints("{type=");
- printxval(f_owner_types, owner.type, "F_OWNER_???");
- tprintf(", pid=%d}", owner.pid);
+ PRINT_FIELD_XVAL("{", owner, type, f_owner_types, "F_OWNER_???");
+ PRINT_FIELD_D(", ", owner, pid);
+ tprints("}");
}
static int
--
2.1.4

View File

@ -1,28 +0,0 @@
From 86923d3a0a01c520ea25d22587143ad6b8dab18b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Sat, 13 Jun 2020 18:18:28 +0200
Subject: [PATCH 124/138] kcmp: fix KCMP_FILE decoding
* kcmp.c (SYS_FUNC(kcmp)): Fix KCMP_FILE pid arguments.
Fixes: v4.20~66 ("kcmp: output fds using a separate function")
---
kcmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kcmp.c b/kcmp.c
index 6819265..6211555 100644
--- a/kcmp.c
+++ b/kcmp.c
@@ -38,7 +38,7 @@ SYS_FUNC(kcmp)
tprints(", ");
printfd_pid_tracee_ns(tcp, pid1, idx1);
tprints(", ");
- printfd_pid_tracee_ns(tcp, pid1, idx2);
+ printfd_pid_tracee_ns(tcp, pid2, idx2);
break;
--
2.1.4

View File

@ -1,518 +0,0 @@
From 56a29d0e192b119c101146e2197246f51661b6b5 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Fri, 17 Jul 2020 08:00:00 +0000
Subject: [PATCH 125/138] printsiginfo: fix printing of siginfo_t.si_pid and
siginfo_t.si_uid
* printsiginfo.c (printsigsource): Print siginfo_t.si_pid using
PRINT_FIELD_D, print siginfo_t.si_uid using PRINT_FIELD_UID.
* tests/clone_ptrace.c (main): Update expected output.
* tests/orphaned_process_group.c (main): Likewise.
* tests/pidfd_send_signal.c (main): Likewise.
* tests/ptrace.c (test_peeksiginfo): Likewise.
* tests/rt_sigqueueinfo.c (main): Likewise.
* tests/rt_tgsigqueueinfo.c (main): Likewise.
* tests/siginfo.c (main): Likewise.
* tests/waitid.c (sprint_siginfo): Likewise.
---
printsiginfo.c | 5 ++---
tests/clone_ptrace.c | 2 +-
tests/orphaned_process_group.c | 2 +-
tests/pidfd_send_signal.c | 2 +-
tests/ptrace.c | 12 ++++++------
tests/rt_sigqueueinfo.c | 2 +-
tests/rt_tgsigqueueinfo.c | 4 ++--
tests/siginfo.c | 10 +++++-----
tests/waitid.c | 4 ++--
9 files changed, 21 insertions(+), 22 deletions(-)
Index: strace-5.7/printsiginfo.c
===================================================================
--- strace-5.7.orig/printsiginfo.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/printsiginfo.c 2020-09-09 14:58:30.753017503 +0200
@@ -58,9 +58,8 @@
static void
printsigsource(const siginfo_t *sip)
{
- tprintf(", si_pid=%u, si_uid=%u",
- (unsigned int) sip->si_pid,
- (unsigned int) sip->si_uid);
+ PRINT_FIELD_D(", ", *sip, si_pid);
+ PRINT_FIELD_UID(", ", *sip, si_uid);
}
static void
Index: strace-5.7/tests/clone_ptrace.c
===================================================================
--- strace-5.7.orig/tests/clone_ptrace.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/clone_ptrace.c 2020-09-09 14:58:30.754017504 +0200
@@ -96,7 +96,7 @@
error_msg_and_fail("unexpected child exit status %d", status);
printf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=%d"
- ", si_uid=%u, si_status=%s, si_utime=%u, si_stime=%u} ---\n"
+ ", si_uid=%d, si_status=%s, si_utime=%u, si_stime=%u} ---\n"
#if !QUIET_EXIT
"+++ exited with 0 +++\n"
#endif
Index: strace-5.7/tests/orphaned_process_group.c
===================================================================
--- strace-5.7.orig/tests/orphaned_process_group.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/orphaned_process_group.c 2020-09-09 14:58:30.754017504 +0200
@@ -139,7 +139,7 @@
*/
leader = getpid();
printf("%-5d --- %s {si_signo=%s, si_code=SI_TKILL"
- ", si_pid=%d, si_uid=%u} ---\n",
+ ", si_pid=%d, si_uid=%d} ---\n",
stopped, "SIGSTOP", "SIGSTOP", stopped, geteuid());
printf("%-5d --- stopped by SIGSTOP ---\n", stopped);
printf("%-5d +++ exited with 0 +++\n", leader);
Index: strace-5.7/tests/pidfd_send_signal.c
===================================================================
--- strace-5.7.orig/tests/pidfd_send_signal.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/pidfd_send_signal.c 2020-09-09 14:58:30.754017504 +0200
@@ -54,7 +54,7 @@
sys_pidfd_send_signal(fd, SIGUSR2, si, -1);
printf("pidfd_send_signal(%d, SIGUSR2, {si_signo=SIGUSR1"
- ", si_code=SI_QUEUE, si_errno=%u, si_pid=%u, si_uid=%u"
+ ", si_code=SI_QUEUE, si_errno=%u, si_pid=%d, si_uid=%d"
", si_value={int=%d, ptr=%p}}, %#x) = %s\n",
fd, si->si_errno, si->si_pid, si->si_uid, si->si_int, si->si_ptr,
-1U, errstr);
Index: strace-5.7/tests/ptrace.c
===================================================================
--- strace-5.7.orig/tests/ptrace.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/ptrace.c 2020-09-09 14:58:30.754017504 +0200
@@ -127,16 +127,16 @@
printf("ptrace(PTRACE_PEEKSIGINFO, %u"
", {off=%llu, flags=0, nr=%u}"
", [{si_signo=SIGUSR1, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
", {si_signo=SIGUSR2, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
", {si_signo=SIGALRM, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
"]) = %s\n",
(unsigned) pid, psi->off, psi->nr,
- (unsigned) pid, (unsigned) uid,
- (unsigned) pid, (unsigned) uid,
- (unsigned) pid, (unsigned) uid,
+ (int) pid, (int) uid,
+ (int) pid, (int) uid,
+ (int) pid, (int) uid,
errstr);
}
Index: strace-5.7/tests/rt_sigqueueinfo.c
===================================================================
--- strace-5.7.orig/tests/rt_sigqueueinfo.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/rt_sigqueueinfo.c 2020-09-09 14:58:30.754017504 +0200
@@ -27,7 +27,7 @@
if (sigqueue(pid, SIGUSR1, value))
perror_msg_and_skip("sigqueue");
printf("rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, "
- "si_code=SI_QUEUE, si_pid=%u, si_uid=%u, "
+ "si_code=SI_QUEUE, si_pid=%d, si_uid=%d, "
"si_value={int=%d, ptr=%p}}) = 0\n",
pid, pid, getuid(), value.sival_int, value.sival_ptr);
printf("+++ exited with 0 +++\n");
Index: strace-5.7/tests/rt_tgsigqueueinfo.c
===================================================================
--- strace-5.7.orig/tests/rt_tgsigqueueinfo.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/rt_tgsigqueueinfo.c 2020-09-09 14:58:30.755017504 +0200
@@ -53,8 +53,8 @@
"rt_tgsigqueueinfo");
printf("rt_tgsigqueueinfo(%u, %u, %s, {si_signo=%s"
- ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%u"
- ", si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\n",
+ ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%d"
+ ", si_uid=%d, si_value={int=%d, ptr=%p}}) = 0\n",
info->si_pid, info->si_pid, "SIGUSR1", "SIGUSR1",
info->si_pid, info->si_uid, info->si_value.sival_int,
info->si_value.sival_ptr);
Index: strace-5.7/tests/siginfo.c
===================================================================
--- strace-5.7.orig/tests/siginfo.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/siginfo.c 2020-09-09 14:58:30.755017504 +0200
@@ -63,7 +63,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED"
- ", si_pid=%d, si_uid=%u, si_status=%d"
+ ", si_pid=%d, si_uid=%d, si_status=%d"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid, sinfo.si_status,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -94,7 +94,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED"
- ", si_pid=%d, si_uid=%u, si_status=SIGUSR1"
+ ", si_pid=%d, si_uid=%d, si_status=SIGUSR1"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -121,7 +121,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_STOPPED"
- ", si_pid=%d, si_uid=%u, si_status=SIGSTOP"
+ ", si_pid=%d, si_uid=%d, si_status=SIGSTOP"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -131,7 +131,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_CONTINUED"
- ", si_pid=%d, si_uid=%u, si_status=SIGCONT"
+ ", si_pid=%d, si_uid=%d, si_status=SIGCONT"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -142,7 +142,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED"
- ", si_pid=%d, si_uid=%u, si_status=0"
+ ", si_pid=%d, si_uid=%d, si_status=0"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
Index: strace-5.7/tests/waitid.c
===================================================================
--- strace-5.7.orig/tests/waitid.c 2020-09-09 14:50:44.013739305 +0200
+++ strace-5.7/tests/waitid.c 2020-09-09 14:58:30.755017504 +0200
@@ -103,8 +103,8 @@
snprintf(buf, sizeof(buf),
"{si_signo=SIGCHLD"
", si_code=%s"
- ", si_pid=%u"
- ", si_uid=%u"
+ ", si_pid=%d"
+ ", si_uid=%d"
", si_status=%s"
", si_utime=%llu"
", si_stime=%llu}",
Index: strace-5.7/tests-m32/clone_ptrace.c
===================================================================
--- strace-5.7.orig/tests-m32/clone_ptrace.c 2020-04-04 00:58:26.000000000 +0200
+++ strace-5.7/tests-m32/clone_ptrace.c 2020-09-09 14:59:06.931039067 +0200
@@ -96,7 +96,7 @@
error_msg_and_fail("unexpected child exit status %d", status);
printf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=%d"
- ", si_uid=%u, si_status=%s, si_utime=%u, si_stime=%u} ---\n"
+ ", si_uid=%d, si_status=%s, si_utime=%u, si_stime=%u} ---\n"
#if !QUIET_EXIT
"+++ exited with 0 +++\n"
#endif
Index: strace-5.7/tests-m32/orphaned_process_group.c
===================================================================
--- strace-5.7.orig/tests-m32/orphaned_process_group.c 2019-03-06 17:02:38.000000000 +0100
+++ strace-5.7/tests-m32/orphaned_process_group.c 2020-09-09 14:59:07.012039115 +0200
@@ -139,7 +139,7 @@
*/
leader = getpid();
printf("%-5d --- %s {si_signo=%s, si_code=SI_TKILL"
- ", si_pid=%d, si_uid=%u} ---\n",
+ ", si_pid=%d, si_uid=%d} ---\n",
stopped, "SIGSTOP", "SIGSTOP", stopped, geteuid());
printf("%-5d --- stopped by SIGSTOP ---\n", stopped);
printf("%-5d +++ exited with 0 +++\n", leader);
Index: strace-5.7/tests-m32/pidfd_send_signal.c
===================================================================
--- strace-5.7.orig/tests-m32/pidfd_send_signal.c 2019-08-14 13:22:32.000000000 +0200
+++ strace-5.7/tests-m32/pidfd_send_signal.c 2020-09-09 14:59:07.077039154 +0200
@@ -54,7 +54,7 @@
sys_pidfd_send_signal(fd, SIGUSR2, si, -1);
printf("pidfd_send_signal(%d, SIGUSR2, {si_signo=SIGUSR1"
- ", si_code=SI_QUEUE, si_errno=%u, si_pid=%u, si_uid=%u"
+ ", si_code=SI_QUEUE, si_errno=%u, si_pid=%d, si_uid=%d"
", si_value={int=%d, ptr=%p}}, %#x) = %s\n",
fd, si->si_errno, si->si_pid, si->si_uid, si->si_int, si->si_ptr,
-1U, errstr);
Index: strace-5.7/tests-m32/ptrace.c
===================================================================
--- strace-5.7.orig/tests-m32/ptrace.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-m32/ptrace.c 2020-09-09 14:59:07.142039193 +0200
@@ -127,16 +127,16 @@
printf("ptrace(PTRACE_PEEKSIGINFO, %u"
", {off=%llu, flags=0, nr=%u}"
", [{si_signo=SIGUSR1, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
", {si_signo=SIGUSR2, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
", {si_signo=SIGALRM, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
"]) = %s\n",
(unsigned) pid, psi->off, psi->nr,
- (unsigned) pid, (unsigned) uid,
- (unsigned) pid, (unsigned) uid,
- (unsigned) pid, (unsigned) uid,
+ (int) pid, (int) uid,
+ (int) pid, (int) uid,
+ (int) pid, (int) uid,
errstr);
}
Index: strace-5.7/tests-m32/rt_sigqueueinfo.c
===================================================================
--- strace-5.7.orig/tests-m32/rt_sigqueueinfo.c 2018-12-25 00:46:43.000000000 +0100
+++ strace-5.7/tests-m32/rt_sigqueueinfo.c 2020-09-09 14:59:07.204039230 +0200
@@ -27,7 +27,7 @@
if (sigqueue(pid, SIGUSR1, value))
perror_msg_and_skip("sigqueue");
printf("rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, "
- "si_code=SI_QUEUE, si_pid=%u, si_uid=%u, "
+ "si_code=SI_QUEUE, si_pid=%d, si_uid=%d, "
"si_value={int=%d, ptr=%p}}) = 0\n",
pid, pid, getuid(), value.sival_int, value.sival_ptr);
printf("+++ exited with 0 +++\n");
Index: strace-5.7/tests-m32/rt_tgsigqueueinfo.c
===================================================================
--- strace-5.7.orig/tests-m32/rt_tgsigqueueinfo.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-m32/rt_tgsigqueueinfo.c 2020-09-09 14:59:07.258039262 +0200
@@ -53,8 +53,8 @@
"rt_tgsigqueueinfo");
printf("rt_tgsigqueueinfo(%u, %u, %s, {si_signo=%s"
- ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%u"
- ", si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\n",
+ ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%d"
+ ", si_uid=%d, si_value={int=%d, ptr=%p}}) = 0\n",
info->si_pid, info->si_pid, "SIGUSR1", "SIGUSR1",
info->si_pid, info->si_uid, info->si_value.sival_int,
info->si_value.sival_ptr);
Index: strace-5.7/tests-m32/siginfo.c
===================================================================
--- strace-5.7.orig/tests-m32/siginfo.c 2018-12-25 00:46:43.000000000 +0100
+++ strace-5.7/tests-m32/siginfo.c 2020-09-09 14:59:07.311039293 +0200
@@ -63,7 +63,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED"
- ", si_pid=%d, si_uid=%u, si_status=%d"
+ ", si_pid=%d, si_uid=%d, si_status=%d"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid, sinfo.si_status,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -94,7 +94,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED"
- ", si_pid=%d, si_uid=%u, si_status=SIGUSR1"
+ ", si_pid=%d, si_uid=%d, si_status=SIGUSR1"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -121,7 +121,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_STOPPED"
- ", si_pid=%d, si_uid=%u, si_status=SIGSTOP"
+ ", si_pid=%d, si_uid=%d, si_status=SIGSTOP"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -131,7 +131,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_CONTINUED"
- ", si_pid=%d, si_uid=%u, si_status=SIGCONT"
+ ", si_pid=%d, si_uid=%d, si_status=SIGCONT"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -142,7 +142,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED"
- ", si_pid=%d, si_uid=%u, si_status=0"
+ ", si_pid=%d, si_uid=%d, si_status=0"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
Index: strace-5.7/tests-m32/waitid.c
===================================================================
--- strace-5.7.orig/tests-m32/waitid.c 2020-04-19 03:22:29.000000000 +0200
+++ strace-5.7/tests-m32/waitid.c 2020-09-09 14:59:07.371039329 +0200
@@ -103,8 +103,8 @@
snprintf(buf, sizeof(buf),
"{si_signo=SIGCHLD"
", si_code=%s"
- ", si_pid=%u"
- ", si_uid=%u"
+ ", si_pid=%d"
+ ", si_uid=%d"
", si_status=%s"
", si_utime=%llu"
", si_stime=%llu}",
Index: strace-5.7/tests-mx32/clone_ptrace.c
===================================================================
--- strace-5.7.orig/tests-mx32/clone_ptrace.c 2020-04-04 00:58:26.000000000 +0200
+++ strace-5.7/tests-mx32/clone_ptrace.c 2020-09-09 14:59:06.978039095 +0200
@@ -96,7 +96,7 @@
error_msg_and_fail("unexpected child exit status %d", status);
printf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=%d"
- ", si_uid=%u, si_status=%s, si_utime=%u, si_stime=%u} ---\n"
+ ", si_uid=%d, si_status=%s, si_utime=%u, si_stime=%u} ---\n"
#if !QUIET_EXIT
"+++ exited with 0 +++\n"
#endif
Index: strace-5.7/tests-mx32/orphaned_process_group.c
===================================================================
--- strace-5.7.orig/tests-mx32/orphaned_process_group.c 2019-03-06 17:02:38.000000000 +0100
+++ strace-5.7/tests-mx32/orphaned_process_group.c 2020-09-09 14:59:07.046039135 +0200
@@ -139,7 +139,7 @@
*/
leader = getpid();
printf("%-5d --- %s {si_signo=%s, si_code=SI_TKILL"
- ", si_pid=%d, si_uid=%u} ---\n",
+ ", si_pid=%d, si_uid=%d} ---\n",
stopped, "SIGSTOP", "SIGSTOP", stopped, geteuid());
printf("%-5d --- stopped by SIGSTOP ---\n", stopped);
printf("%-5d +++ exited with 0 +++\n", leader);
Index: strace-5.7/tests-mx32/pidfd_send_signal.c
===================================================================
--- strace-5.7.orig/tests-mx32/pidfd_send_signal.c 2019-08-14 13:22:32.000000000 +0200
+++ strace-5.7/tests-mx32/pidfd_send_signal.c 2020-09-09 14:59:07.110039174 +0200
@@ -54,7 +54,7 @@
sys_pidfd_send_signal(fd, SIGUSR2, si, -1);
printf("pidfd_send_signal(%d, SIGUSR2, {si_signo=SIGUSR1"
- ", si_code=SI_QUEUE, si_errno=%u, si_pid=%u, si_uid=%u"
+ ", si_code=SI_QUEUE, si_errno=%u, si_pid=%d, si_uid=%d"
", si_value={int=%d, ptr=%p}}, %#x) = %s\n",
fd, si->si_errno, si->si_pid, si->si_uid, si->si_int, si->si_ptr,
-1U, errstr);
Index: strace-5.7/tests-mx32/ptrace.c
===================================================================
--- strace-5.7.orig/tests-mx32/ptrace.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-mx32/ptrace.c 2020-09-09 14:59:07.174039212 +0200
@@ -127,16 +127,16 @@
printf("ptrace(PTRACE_PEEKSIGINFO, %u"
", {off=%llu, flags=0, nr=%u}"
", [{si_signo=SIGUSR1, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
", {si_signo=SIGUSR2, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
", {si_signo=SIGALRM, si_code=SI_TKILL"
- ", si_pid=%u, si_uid=%u}"
+ ", si_pid=%d, si_uid=%d}"
"]) = %s\n",
(unsigned) pid, psi->off, psi->nr,
- (unsigned) pid, (unsigned) uid,
- (unsigned) pid, (unsigned) uid,
- (unsigned) pid, (unsigned) uid,
+ (int) pid, (int) uid,
+ (int) pid, (int) uid,
+ (int) pid, (int) uid,
errstr);
}
Index: strace-5.7/tests-mx32/rt_sigqueueinfo.c
===================================================================
--- strace-5.7.orig/tests-mx32/rt_sigqueueinfo.c 2018-12-25 00:46:43.000000000 +0100
+++ strace-5.7/tests-mx32/rt_sigqueueinfo.c 2020-09-09 14:59:07.232039246 +0200
@@ -27,7 +27,7 @@
if (sigqueue(pid, SIGUSR1, value))
perror_msg_and_skip("sigqueue");
printf("rt_sigqueueinfo(%u, SIGUSR1, {si_signo=SIGUSR1, "
- "si_code=SI_QUEUE, si_pid=%u, si_uid=%u, "
+ "si_code=SI_QUEUE, si_pid=%d, si_uid=%d, "
"si_value={int=%d, ptr=%p}}) = 0\n",
pid, pid, getuid(), value.sival_int, value.sival_ptr);
printf("+++ exited with 0 +++\n");
Index: strace-5.7/tests-mx32/rt_tgsigqueueinfo.c
===================================================================
--- strace-5.7.orig/tests-mx32/rt_tgsigqueueinfo.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-mx32/rt_tgsigqueueinfo.c 2020-09-09 14:59:07.284039277 +0200
@@ -53,8 +53,8 @@
"rt_tgsigqueueinfo");
printf("rt_tgsigqueueinfo(%u, %u, %s, {si_signo=%s"
- ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%u"
- ", si_uid=%u, si_value={int=%d, ptr=%p}}) = 0\n",
+ ", si_code=SI_QUEUE, si_errno=ENOENT, si_pid=%d"
+ ", si_uid=%d, si_value={int=%d, ptr=%p}}) = 0\n",
info->si_pid, info->si_pid, "SIGUSR1", "SIGUSR1",
info->si_pid, info->si_uid, info->si_value.sival_int,
info->si_value.sival_ptr);
Index: strace-5.7/tests-mx32/siginfo.c
===================================================================
--- strace-5.7.orig/tests-mx32/siginfo.c 2018-12-25 00:46:43.000000000 +0100
+++ strace-5.7/tests-mx32/siginfo.c 2020-09-09 14:59:07.338039310 +0200
@@ -63,7 +63,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED"
- ", si_pid=%d, si_uid=%u, si_status=%d"
+ ", si_pid=%d, si_uid=%d, si_status=%d"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid, sinfo.si_status,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -94,7 +94,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED"
- ", si_pid=%d, si_uid=%u, si_status=SIGUSR1"
+ ", si_pid=%d, si_uid=%d, si_status=SIGUSR1"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -121,7 +121,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_STOPPED"
- ", si_pid=%d, si_uid=%u, si_status=SIGSTOP"
+ ", si_pid=%d, si_uid=%d, si_status=SIGSTOP"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -131,7 +131,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_CONTINUED"
- ", si_pid=%d, si_uid=%u, si_status=SIGCONT"
+ ", si_pid=%d, si_uid=%d, si_status=SIGCONT"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
@@ -142,7 +142,7 @@
sigsuspend(&unblock_mask);
tprintf("--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED"
- ", si_pid=%d, si_uid=%u, si_status=0"
+ ", si_pid=%d, si_uid=%d, si_status=0"
", si_utime=%llu, si_stime=%llu} ---\n",
sinfo.si_pid, sinfo.si_uid,
zero_extend_signed_to_ull(sinfo.si_utime),
Index: strace-5.7/tests-mx32/waitid.c
===================================================================
--- strace-5.7.orig/tests-mx32/waitid.c 2020-04-19 03:22:29.000000000 +0200
+++ strace-5.7/tests-mx32/waitid.c 2020-09-09 14:59:07.398039345 +0200
@@ -103,8 +103,8 @@
snprintf(buf, sizeof(buf),
"{si_signo=SIGCHLD"
", si_code=%s"
- ", si_pid=%u"
- ", si_uid=%u"
+ ", si_pid=%d"
+ ", si_uid=%d"
", si_status=%s"
", si_utime=%llu"
", si_stime=%llu}",

View File

@ -1,105 +0,0 @@
From 64d04198d3c64756ae8a51646b6eac3dff419cb6 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Fri, 17 Jul 2020 08:00:00 +0000
Subject: [PATCH 126/138] Use PRINT_FIELD_UID instead of printuid where
appropriate
* ipc_msgctl.c: Include "print_fields.h".
(print_msqid_ds): Use PRINT_FIELD_UID instead of printuid.
* ipc_shmctl.c: Include "print_fields.h".
(print_shmid_ds): Use PRINT_FIELD_UID instead of printuid.
* statx.c (SYS_FUNC(statx)): Use PRINT_FIELD_UID instead of printuid.
---
ipc_msgctl.c | 10 +++++-----
ipc_shmctl.c | 10 +++++-----
statx.c | 4 ++--
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/ipc_msgctl.c b/ipc_msgctl.c
index 92eda11..920ed72 100644
--- a/ipc_msgctl.c
+++ b/ipc_msgctl.c
@@ -22,6 +22,7 @@ typedef struct NAME_OF_STRUCT_MSQID_DS msqid_ds_t;
#include MPERS_DEFS
+#include "print_fields.h"
#include "xlat/msgctl_flags.h"
static void
@@ -37,9 +38,8 @@ print_msqid_ds(struct tcb *const tcp, const kernel_ulong_t addr, int cmd)
if (umove_or_printaddr(tcp, addr, &msqid_ds))
return;
- tprints("{msg_perm={");
- printuid("uid=", msqid_ds.msg_perm.uid);
- printuid(", gid=", msqid_ds.msg_perm.gid);
+ PRINT_FIELD_UID("{msg_perm={", msqid_ds.msg_perm, uid);
+ PRINT_FIELD_UID(", ", msqid_ds.msg_perm, gid);
tprints(", mode=");
print_numeric_umode_t(msqid_ds.msg_perm.mode);
@@ -50,8 +50,8 @@ print_msqid_ds(struct tcb *const tcp, const kernel_ulong_t addr, int cmd)
tprintf(", key=%u",
(unsigned) msqid_ds.msg_perm.NAME_OF_STRUCT_IPC_PERM_KEY);
- printuid(", cuid=", msqid_ds.msg_perm.cuid);
- printuid(", cgid=", msqid_ds.msg_perm.cgid);
+ PRINT_FIELD_UID(", ", msqid_ds.msg_perm, cuid);
+ PRINT_FIELD_UID(", ", msqid_ds.msg_perm, cgid);
tprints("}");
tprintf(", msg_stime=%u", (unsigned) msqid_ds.msg_stime);
tprintf(", msg_rtime=%u", (unsigned) msqid_ds.msg_rtime);
diff --git a/ipc_shmctl.c b/ipc_shmctl.c
index 0fb584e..83e36f3 100644
--- a/ipc_shmctl.c
+++ b/ipc_shmctl.c
@@ -22,6 +22,7 @@ typedef struct NAME_OF_STRUCT_SHMID_DS shmid_ds_t;
#include MPERS_DEFS
+#include "print_fields.h"
#include "xlat/shmctl_flags.h"
static void
@@ -37,9 +38,8 @@ print_shmid_ds(struct tcb *const tcp, const kernel_ulong_t addr, int cmd)
if (umove_or_printaddr(tcp, addr, &shmid_ds))
return;
- tprints("{shm_perm={");
- printuid("uid=", shmid_ds.shm_perm.uid);
- printuid(", gid=", shmid_ds.shm_perm.gid);
+ PRINT_FIELD_UID("{shm_perm={", shmid_ds.shm_perm, uid);
+ PRINT_FIELD_UID(", ", shmid_ds.shm_perm, gid);
tprints(", mode=");
print_numeric_umode_t(shmid_ds.shm_perm.mode);
@@ -50,8 +50,8 @@ print_shmid_ds(struct tcb *const tcp, const kernel_ulong_t addr, int cmd)
tprintf(", key=%u",
(unsigned) shmid_ds.shm_perm.NAME_OF_STRUCT_IPC_PERM_KEY);
- printuid(", cuid=", shmid_ds.shm_perm.cuid);
- printuid(", cgid=", shmid_ds.shm_perm.cgid);
+ PRINT_FIELD_UID(", ", shmid_ds.shm_perm, cuid);
+ PRINT_FIELD_UID(", ", shmid_ds.shm_perm, cgid);
tprints("}");
tprintf(", shm_segsz=%u", (unsigned) shmid_ds.shm_segsz);
tprintf(", shm_cpid=%u", (unsigned) shmid_ds.shm_cpid);
diff --git a/statx.c b/statx.c
index 54b6d7c..7b00b8e 100644
--- a/statx.c
+++ b/statx.c
@@ -60,8 +60,8 @@ SYS_FUNC(statx)
if (!abbrev(tcp)) {
PRINT_FIELD_U(", ", stx, stx_nlink);
- printuid(", stx_uid=", stx.stx_uid);
- printuid(", stx_gid=", stx.stx_gid);
+ PRINT_FIELD_UID(", ", stx, stx_uid);
+ PRINT_FIELD_UID(", ", stx, stx_gid);
}
tprints(", stx_mode=");
--
2.1.4

View File

@ -1,525 +0,0 @@
From edf6f95bd19f5ce7ac0ef62f923cd17fb6052f51 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 18 Jul 2020 08:00:00 +0000
Subject: [PATCH 127/138] Consistently print process ids as signed integers
* block.c (block_ioctl): Print struct_blk_user_trace_setup.pid using
PRINT_FIELD_D instead of PRINT_FIELD_U.
* bpf.c (BPF_TASK_FD_QUERY): Print task_fd_query.pid using PRINT_FIELD_D
instead of PRINT_FIELD_U.
* ipc_msgctl.c (print_msqid_ds): Print msqid_ds.msg_lspid
and msqid_ds.msg_lrpid using PRINT_FIELD_D.
* ipc_shmctl.c (print_shmid_ds): Print shmid_ds.shm_cpid and shm_lpid
using PRINT_FIELD_D.
* msghdr.c (print_scm_creds): Print ucred.pid using PRINT_FIELD_D
instead of PRINT_FIELD_U.
* netlink.c (print_nlmsghdr): Print nlmsghdr.nlmsg_pid using %d format
instead of %u.
* tests/bpf.c (BPF_TASK_FD_QUERY_checks): Update expected output.
* tests/ioctl_block.c (main): Update expected output.
* tests/ipc_msg.c (main): Likewise.
* tests/ipc_shm.c (main): Likewise.
* tests/net-yy-netlink.c (main): Likewise.
* tests/netlink_protocol.c (test_nlmsgerr): Likewise.
---
block.c | 2 +-
bpf.c | 2 +-
ipc_msgctl.c | 4 ++--
ipc_shmctl.c | 4 ++--
msghdr.c | 2 +-
netlink.c | 2 +-
tests/bpf.c | 8 ++++----
tests/ioctl_block.c | 2 +-
tests/ipc_msg.c | 6 +++---
tests/ipc_shm.c | 8 ++++----
tests/net-yy-netlink.c | 4 ++--
tests/netlink_protocol.c | 4 ++--
12 files changed, 24 insertions(+), 24 deletions(-)
Index: strace-5.7/block.c
===================================================================
--- strace-5.7.orig/block.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/block.c 2020-09-09 14:59:14.715043707 +0200
@@ -179,7 +179,7 @@
PRINT_FIELD_U(", ", buts, buf_nr);
PRINT_FIELD_U(", ", buts, start_lba);
PRINT_FIELD_U(", ", buts, end_lba);
- PRINT_FIELD_U(", ", buts, pid);
+ PRINT_FIELD_D(", ", buts, pid);
return 0;
} else {
struct_blk_user_trace_setup buts;
Index: strace-5.7/bpf.c
===================================================================
--- strace-5.7.orig/bpf.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/bpf.c 2020-09-09 14:59:14.715043707 +0200
@@ -927,7 +927,7 @@
if (entering(tcp)) {
set_tcb_priv_ulong(tcp, attr.buf_len);
- PRINT_FIELD_U("{task_fd_query={", attr, pid);
+ PRINT_FIELD_D("{task_fd_query={", attr, pid);
PRINT_FIELD_FD(", ", attr, fd, tcp);
PRINT_FIELD_U(", ", attr, flags);
PRINT_FIELD_U(", ", attr, buf_len);
Index: strace-5.7/ipc_msgctl.c
===================================================================
--- strace-5.7.orig/ipc_msgctl.c 2020-09-09 14:59:12.909042630 +0200
+++ strace-5.7/ipc_msgctl.c 2020-09-09 14:59:14.715043707 +0200
@@ -58,8 +58,8 @@
tprintf(", msg_ctime=%u", (unsigned) msqid_ds.msg_ctime);
tprintf(", msg_qnum=%u", (unsigned) msqid_ds.msg_qnum);
tprintf(", msg_qbytes=%u", (unsigned) msqid_ds.msg_qbytes);
- tprintf(", msg_lspid=%u", (unsigned) msqid_ds.msg_lspid);
- tprintf(", msg_lrpid=%u", (unsigned) msqid_ds.msg_lrpid);
+ PRINT_FIELD_D(", ", msqid_ds, msg_lspid);
+ PRINT_FIELD_D(", ", msqid_ds, msg_lrpid);
tprints("}");
break;
Index: strace-5.7/ipc_shmctl.c
===================================================================
--- strace-5.7.orig/ipc_shmctl.c 2020-09-09 14:59:12.909042630 +0200
+++ strace-5.7/ipc_shmctl.c 2020-09-09 14:59:14.716043707 +0200
@@ -54,8 +54,8 @@
PRINT_FIELD_UID(", ", shmid_ds.shm_perm, cgid);
tprints("}");
tprintf(", shm_segsz=%u", (unsigned) shmid_ds.shm_segsz);
- tprintf(", shm_cpid=%u", (unsigned) shmid_ds.shm_cpid);
- tprintf(", shm_lpid=%u", (unsigned) shmid_ds.shm_lpid);
+ PRINT_FIELD_D(", ", shmid_ds, shm_cpid);
+ PRINT_FIELD_D(", ", shmid_ds, shm_lpid);
tprintf(", shm_nattch=%u", (unsigned) shmid_ds.shm_nattch);
tprintf(", shm_atime=%u", (unsigned) shmid_ds.shm_atime);
tprintf(", shm_dtime=%u", (unsigned) shmid_ds.shm_dtime);
Index: strace-5.7/msghdr.c
===================================================================
--- strace-5.7.orig/msghdr.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/msghdr.c 2020-09-09 14:59:14.717043708 +0200
@@ -69,7 +69,7 @@
{
const struct ucred *uc = cmsg_data;
- PRINT_FIELD_U("{", *uc, pid);
+ PRINT_FIELD_D("{", *uc, pid);
PRINT_FIELD_UID(", ", *uc, uid);
PRINT_FIELD_UID(", ", *uc, gid);
tprints("}");
Index: strace-5.7/netlink.c
===================================================================
--- strace-5.7.orig/netlink.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/netlink.c 2020-09-09 14:59:14.717043708 +0200
@@ -446,7 +446,7 @@
decode_nlmsg_flags(nlmsghdr->nlmsg_flags,
nlmsghdr->nlmsg_type, family);
- tprintf(", seq=%u, pid=%u}", nlmsghdr->nlmsg_seq,
+ tprintf(", seq=%u, pid=%d}", nlmsghdr->nlmsg_seq,
nlmsghdr->nlmsg_pid);
}
Index: strace-5.7/tests/bpf.c
===================================================================
--- strace-5.7.orig/tests/bpf.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/tests/bpf.c 2020-09-09 14:59:14.717043708 +0200
@@ -1289,16 +1289,16 @@
static const struct bpf_attr_check BPF_TASK_FD_QUERY_checks[] = {
{
- .data = { .BPF_TASK_FD_QUERY_data = { .pid = 0xdeadbeef } },
+ .data = { .BPF_TASK_FD_QUERY_data = { .pid = 1735928559 } },
.size = offsetofend(struct BPF_TASK_FD_QUERY_struct, pid),
- .str = "task_fd_query={pid=3735928559, fd=0" FD0_PATH
+ .str = "task_fd_query={pid=1735928559, fd=0" FD0_PATH
", flags=0, buf_len=0, buf=NULL, prog_id=0"
", fd_type=BPF_FD_TYPE_RAW_TRACEPOINT"
", probe_offset=0, probe_addr=0}"
},
{ /* 1 */
.data = { .BPF_TASK_FD_QUERY_data = {
- .pid = 0xcafef00d,
+ .pid = 1405705229,
.fd = 0xdeadbeef,
.flags = 0xfacefeed,
.buf_len = 0xdefaced,
@@ -1309,7 +1309,7 @@
.probe_addr = 0xfac5fed5fac7fed8
} },
.size = offsetofend(struct BPF_TASK_FD_QUERY_struct, probe_addr),
- .str = "task_fd_query={pid=3405705229"
+ .str = "task_fd_query={pid=1405705229"
", fd=-559038737"
", flags=4207869677"
", buf_len=233811181"
Index: strace-5.7/tests/ioctl_block.c
===================================================================
--- strace-5.7.orig/tests/ioctl_block.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/tests/ioctl_block.c 2020-09-09 14:59:14.717043708 +0200
@@ -165,7 +165,7 @@
ioctl(-1, BLKTRACESETUP, buts);
printf("ioctl(-1, BLKTRACESETUP, {act_mask=%hu, buf_size=%u, buf_nr=%u"
- ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%u})"
+ ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%d})"
" = -1 EBADF (%m)\n",
buts->act_mask, buts->buf_size, buts->buf_nr,
buts->start_lba, buts->end_lba, buts->pid);
Index: strace-5.7/tests/ipc_msg.c
===================================================================
--- strace-5.7.orig/tests/ipc_msg.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/tests/ipc_msg.c 2020-09-09 14:59:14.717043708 +0200
@@ -128,15 +128,15 @@
printf("msgctl\\(%d, (%s\\|)?%s, \\{msg_perm=\\{uid=%u"
", gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u"
", msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u"
- ", msg_lspid=%u, msg_lrpid=%u\\}\\) = 0\n",
+ ", msg_lspid=%d, msg_lrpid=%d\\}\\) = 0\n",
id, str_ipc_64, str_ipc_stat,
(unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid,
(unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key,
(unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid,
(unsigned) ds.msg_stime, (unsigned) ds.msg_rtime,
(unsigned) ds.msg_ctime, (unsigned) ds.msg_qnum,
- (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid,
- (unsigned) ds.msg_lrpid);
+ (unsigned) ds.msg_qbytes, (int) ds.msg_lspid,
+ (int) ds.msg_lrpid);
if (msgctl(id, IPC_SET, &ds))
perror_msg_and_skip("msgctl IPC_SET");
Index: strace-5.7/tests/ipc_shm.c
===================================================================
--- strace-5.7.orig/tests/ipc_shm.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/tests/ipc_shm.c 2020-09-09 14:59:14.718043708 +0200
@@ -168,15 +168,15 @@
if (shmctl(id, IPC_STAT, &ds))
perror_msg_and_skip("shmctl IPC_STAT");
printf("shmctl\\(%d, (%s\\|)?%s, \\{shm_perm=\\{uid=%u, gid=%u, "
- "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%u, "
- "shm_lpid=%u, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
+ "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%d, "
+ "shm_lpid=%d, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
"shm_ctime=%u\\}\\) = 0\n",
id, str_ipc_64, str_ipc_stat,
(unsigned) ds.shm_perm.uid, (unsigned) ds.shm_perm.gid,
(unsigned) ds.shm_perm.mode, (unsigned) ds.shm_perm.__key,
(unsigned) ds.shm_perm.cuid, (unsigned) ds.shm_perm.cgid,
- (unsigned) ds.shm_segsz, (unsigned) ds.shm_cpid,
- (unsigned) ds.shm_lpid, (unsigned) ds.shm_nattch,
+ (unsigned) ds.shm_segsz, (int) ds.shm_cpid,
+ (int) ds.shm_lpid, (unsigned) ds.shm_nattch,
(unsigned) ds.shm_atime, (unsigned) ds.shm_dtime,
(unsigned) ds. shm_ctime);
Index: strace-5.7/tests/net-yy-netlink.c
===================================================================
--- strace-5.7.orig/tests/net-yy-netlink.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/tests/net-yy-netlink.c 2020-09-09 14:59:14.718043708 +0200
@@ -67,13 +67,13 @@
if (bind(fd, sa, *len))
perror_msg_and_skip("bind");
printf("bind(%d" FMT_UNBOUND ", {sa_family=AF_NETLINK"
- ", nl_pid=%u, nl_groups=00000000}, %u) = 0\n",
+ ", nl_pid=%d, nl_groups=00000000}, %u) = 0\n",
fd, ARG_UNBOUND, addr.nl_pid, (unsigned) *len);
if (getsockname(fd, sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d" FMT_BOUND ", {sa_family=AF_NETLINK"
- ", nl_pid=%u, nl_groups=00000000}, [%u]) = 0\n",
+ ", nl_pid=%d, nl_groups=00000000}, [%u]) = 0\n",
fd, ARG_BOUND, addr.nl_pid, (unsigned) *len);
if (close(fd))
Index: strace-5.7/tests/netlink_protocol.c
===================================================================
--- strace-5.7.orig/tests/netlink_protocol.c 2020-09-09 14:50:43.878739225 +0200
+++ strace-5.7/tests/netlink_protocol.c 2020-09-09 14:59:14.718043708 +0200
@@ -264,7 +264,7 @@
printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
", seq=0, pid=0}, {error=-EACCES"
", msg={len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
- ", seq=%u, pid=%u}}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+ ", seq=%u, pid=%d}}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, nlh->nlmsg_len, err->msg.nlmsg_len, NLM_F_DUMP,
err->msg.nlmsg_seq, err->msg.nlmsg_pid,
nlh->nlmsg_len, sprintrc(rc));
@@ -289,7 +289,7 @@
printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
", seq=0, pid=0}, {error=-EACCES"
", msg={{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
- ", seq=%u, pid=%u}, \"\\x61\\x62\\x63\\x64\"}}}"
+ ", seq=%u, pid=%d}, \"\\x61\\x62\\x63\\x64\"}}}"
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, nlh->nlmsg_len, err->msg.nlmsg_len, NLM_F_DUMP,
err->msg.nlmsg_seq, err->msg.nlmsg_pid,
Index: strace-5.7/tests-m32/bpf.c
===================================================================
--- strace-5.7.orig/tests-m32/bpf.c 2020-04-18 15:47:17.000000000 +0200
+++ strace-5.7/tests-m32/bpf.c 2020-09-09 14:59:52.229066067 +0200
@@ -1289,16 +1289,16 @@
static const struct bpf_attr_check BPF_TASK_FD_QUERY_checks[] = {
{
- .data = { .BPF_TASK_FD_QUERY_data = { .pid = 0xdeadbeef } },
+ .data = { .BPF_TASK_FD_QUERY_data = { .pid = 1735928559 } },
.size = offsetofend(struct BPF_TASK_FD_QUERY_struct, pid),
- .str = "task_fd_query={pid=3735928559, fd=0" FD0_PATH
+ .str = "task_fd_query={pid=1735928559, fd=0" FD0_PATH
", flags=0, buf_len=0, buf=NULL, prog_id=0"
", fd_type=BPF_FD_TYPE_RAW_TRACEPOINT"
", probe_offset=0, probe_addr=0}"
},
{ /* 1 */
.data = { .BPF_TASK_FD_QUERY_data = {
- .pid = 0xcafef00d,
+ .pid = 1405705229,
.fd = 0xdeadbeef,
.flags = 0xfacefeed,
.buf_len = 0xdefaced,
@@ -1309,7 +1309,7 @@
.probe_addr = 0xfac5fed5fac7fed8
} },
.size = offsetofend(struct BPF_TASK_FD_QUERY_struct, probe_addr),
- .str = "task_fd_query={pid=3405705229"
+ .str = "task_fd_query={pid=1405705229"
", fd=-559038737"
", flags=4207869677"
", buf_len=233811181"
Index: strace-5.7/tests-m32/ioctl_block.c
===================================================================
--- strace-5.7.orig/tests-m32/ioctl_block.c 2019-07-24 19:12:18.000000000 +0200
+++ strace-5.7/tests-m32/ioctl_block.c 2020-09-09 14:59:52.290066103 +0200
@@ -165,7 +165,7 @@
ioctl(-1, BLKTRACESETUP, buts);
printf("ioctl(-1, BLKTRACESETUP, {act_mask=%hu, buf_size=%u, buf_nr=%u"
- ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%u})"
+ ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%d})"
" = -1 EBADF (%m)\n",
buts->act_mask, buts->buf_size, buts->buf_nr,
buts->start_lba, buts->end_lba, buts->pid);
Index: strace-5.7/tests-m32/ipc_msg.c
===================================================================
--- strace-5.7.orig/tests-m32/ipc_msg.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-m32/ipc_msg.c 2020-09-09 14:59:52.349066138 +0200
@@ -128,15 +128,15 @@
printf("msgctl\\(%d, (%s\\|)?%s, \\{msg_perm=\\{uid=%u"
", gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u"
", msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u"
- ", msg_lspid=%u, msg_lrpid=%u\\}\\) = 0\n",
+ ", msg_lspid=%d, msg_lrpid=%d\\}\\) = 0\n",
id, str_ipc_64, str_ipc_stat,
(unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid,
(unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key,
(unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid,
(unsigned) ds.msg_stime, (unsigned) ds.msg_rtime,
(unsigned) ds.msg_ctime, (unsigned) ds.msg_qnum,
- (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid,
- (unsigned) ds.msg_lrpid);
+ (unsigned) ds.msg_qbytes, (int) ds.msg_lspid,
+ (int) ds.msg_lrpid);
if (msgctl(id, IPC_SET, &ds))
perror_msg_and_skip("msgctl IPC_SET");
Index: strace-5.7/tests-m32/ipc_shm.c
===================================================================
--- strace-5.7.orig/tests-m32/ipc_shm.c 2019-11-28 20:30:05.000000000 +0100
+++ strace-5.7/tests-m32/ipc_shm.c 2020-09-09 14:59:52.406066172 +0200
@@ -168,15 +168,15 @@
if (shmctl(id, IPC_STAT, &ds))
perror_msg_and_skip("shmctl IPC_STAT");
printf("shmctl\\(%d, (%s\\|)?%s, \\{shm_perm=\\{uid=%u, gid=%u, "
- "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%u, "
- "shm_lpid=%u, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
+ "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%d, "
+ "shm_lpid=%d, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
"shm_ctime=%u\\}\\) = 0\n",
id, str_ipc_64, str_ipc_stat,
(unsigned) ds.shm_perm.uid, (unsigned) ds.shm_perm.gid,
(unsigned) ds.shm_perm.mode, (unsigned) ds.shm_perm.__key,
(unsigned) ds.shm_perm.cuid, (unsigned) ds.shm_perm.cgid,
- (unsigned) ds.shm_segsz, (unsigned) ds.shm_cpid,
- (unsigned) ds.shm_lpid, (unsigned) ds.shm_nattch,
+ (unsigned) ds.shm_segsz, (int) ds.shm_cpid,
+ (int) ds.shm_lpid, (unsigned) ds.shm_nattch,
(unsigned) ds.shm_atime, (unsigned) ds.shm_dtime,
(unsigned) ds. shm_ctime);
Index: strace-5.7/tests-m32/net-yy-netlink.c
===================================================================
--- strace-5.7.orig/tests-m32/net-yy-netlink.c 2020-04-04 00:58:26.000000000 +0200
+++ strace-5.7/tests-m32/net-yy-netlink.c 2020-09-09 14:59:52.464066207 +0200
@@ -67,13 +67,13 @@
if (bind(fd, sa, *len))
perror_msg_and_skip("bind");
printf("bind(%d" FMT_UNBOUND ", {sa_family=AF_NETLINK"
- ", nl_pid=%u, nl_groups=00000000}, %u) = 0\n",
+ ", nl_pid=%d, nl_groups=00000000}, %u) = 0\n",
fd, ARG_UNBOUND, addr.nl_pid, (unsigned) *len);
if (getsockname(fd, sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d" FMT_BOUND ", {sa_family=AF_NETLINK"
- ", nl_pid=%u, nl_groups=00000000}, [%u]) = 0\n",
+ ", nl_pid=%d, nl_groups=00000000}, [%u]) = 0\n",
fd, ARG_BOUND, addr.nl_pid, (unsigned) *len);
if (close(fd))
Index: strace-5.7/tests-m32/netlink_protocol.c
===================================================================
--- strace-5.7.orig/tests-m32/netlink_protocol.c 2018-12-30 16:35:21.000000000 +0100
+++ strace-5.7/tests-m32/netlink_protocol.c 2020-09-09 14:59:52.524066242 +0200
@@ -264,7 +264,7 @@
printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
", seq=0, pid=0}, {error=-EACCES"
", msg={len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
- ", seq=%u, pid=%u}}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+ ", seq=%u, pid=%d}}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, nlh->nlmsg_len, err->msg.nlmsg_len, NLM_F_DUMP,
err->msg.nlmsg_seq, err->msg.nlmsg_pid,
nlh->nlmsg_len, sprintrc(rc));
@@ -289,7 +289,7 @@
printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
", seq=0, pid=0}, {error=-EACCES"
", msg={{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
- ", seq=%u, pid=%u}, \"\\x61\\x62\\x63\\x64\"}}}"
+ ", seq=%u, pid=%d}, \"\\x61\\x62\\x63\\x64\"}}}"
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, nlh->nlmsg_len, err->msg.nlmsg_len, NLM_F_DUMP,
err->msg.nlmsg_seq, err->msg.nlmsg_pid,
Index: strace-5.7/tests-mx32/bpf.c
===================================================================
--- strace-5.7.orig/tests-mx32/bpf.c 2020-04-18 15:47:17.000000000 +0200
+++ strace-5.7/tests-mx32/bpf.c 2020-09-09 14:59:52.261066086 +0200
@@ -1289,16 +1289,16 @@
static const struct bpf_attr_check BPF_TASK_FD_QUERY_checks[] = {
{
- .data = { .BPF_TASK_FD_QUERY_data = { .pid = 0xdeadbeef } },
+ .data = { .BPF_TASK_FD_QUERY_data = { .pid = 1735928559 } },
.size = offsetofend(struct BPF_TASK_FD_QUERY_struct, pid),
- .str = "task_fd_query={pid=3735928559, fd=0" FD0_PATH
+ .str = "task_fd_query={pid=1735928559, fd=0" FD0_PATH
", flags=0, buf_len=0, buf=NULL, prog_id=0"
", fd_type=BPF_FD_TYPE_RAW_TRACEPOINT"
", probe_offset=0, probe_addr=0}"
},
{ /* 1 */
.data = { .BPF_TASK_FD_QUERY_data = {
- .pid = 0xcafef00d,
+ .pid = 1405705229,
.fd = 0xdeadbeef,
.flags = 0xfacefeed,
.buf_len = 0xdefaced,
@@ -1309,7 +1309,7 @@
.probe_addr = 0xfac5fed5fac7fed8
} },
.size = offsetofend(struct BPF_TASK_FD_QUERY_struct, probe_addr),
- .str = "task_fd_query={pid=3405705229"
+ .str = "task_fd_query={pid=1405705229"
", fd=-559038737"
", flags=4207869677"
", buf_len=233811181"
Index: strace-5.7/tests-mx32/ioctl_block.c
===================================================================
--- strace-5.7.orig/tests-mx32/ioctl_block.c 2019-07-24 19:12:18.000000000 +0200
+++ strace-5.7/tests-mx32/ioctl_block.c 2020-09-09 14:59:52.319066120 +0200
@@ -165,7 +165,7 @@
ioctl(-1, BLKTRACESETUP, buts);
printf("ioctl(-1, BLKTRACESETUP, {act_mask=%hu, buf_size=%u, buf_nr=%u"
- ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%u})"
+ ", start_lba=%" PRI__u64 ", end_lba=%" PRI__u64 ", pid=%d})"
" = -1 EBADF (%m)\n",
buts->act_mask, buts->buf_size, buts->buf_nr,
buts->start_lba, buts->end_lba, buts->pid);
Index: strace-5.7/tests-mx32/ipc_msg.c
===================================================================
--- strace-5.7.orig/tests-mx32/ipc_msg.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-mx32/ipc_msg.c 2020-09-09 14:59:52.377066155 +0200
@@ -128,15 +128,15 @@
printf("msgctl\\(%d, (%s\\|)?%s, \\{msg_perm=\\{uid=%u"
", gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u"
", msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u"
- ", msg_lspid=%u, msg_lrpid=%u\\}\\) = 0\n",
+ ", msg_lspid=%d, msg_lrpid=%d\\}\\) = 0\n",
id, str_ipc_64, str_ipc_stat,
(unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid,
(unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key,
(unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid,
(unsigned) ds.msg_stime, (unsigned) ds.msg_rtime,
(unsigned) ds.msg_ctime, (unsigned) ds.msg_qnum,
- (unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid,
- (unsigned) ds.msg_lrpid);
+ (unsigned) ds.msg_qbytes, (int) ds.msg_lspid,
+ (int) ds.msg_lrpid);
if (msgctl(id, IPC_SET, &ds))
perror_msg_and_skip("msgctl IPC_SET");
Index: strace-5.7/tests-mx32/ipc_shm.c
===================================================================
--- strace-5.7.orig/tests-mx32/ipc_shm.c 2019-11-28 20:30:05.000000000 +0100
+++ strace-5.7/tests-mx32/ipc_shm.c 2020-09-09 14:59:52.435066189 +0200
@@ -168,15 +168,15 @@
if (shmctl(id, IPC_STAT, &ds))
perror_msg_and_skip("shmctl IPC_STAT");
printf("shmctl\\(%d, (%s\\|)?%s, \\{shm_perm=\\{uid=%u, gid=%u, "
- "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%u, "
- "shm_lpid=%u, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
+ "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, shm_segsz=%u, shm_cpid=%d, "
+ "shm_lpid=%d, shm_nattch=%u, shm_atime=%u, shm_dtime=%u, "
"shm_ctime=%u\\}\\) = 0\n",
id, str_ipc_64, str_ipc_stat,
(unsigned) ds.shm_perm.uid, (unsigned) ds.shm_perm.gid,
(unsigned) ds.shm_perm.mode, (unsigned) ds.shm_perm.__key,
(unsigned) ds.shm_perm.cuid, (unsigned) ds.shm_perm.cgid,
- (unsigned) ds.shm_segsz, (unsigned) ds.shm_cpid,
- (unsigned) ds.shm_lpid, (unsigned) ds.shm_nattch,
+ (unsigned) ds.shm_segsz, (int) ds.shm_cpid,
+ (int) ds.shm_lpid, (unsigned) ds.shm_nattch,
(unsigned) ds.shm_atime, (unsigned) ds.shm_dtime,
(unsigned) ds. shm_ctime);
Index: strace-5.7/tests-mx32/net-yy-netlink.c
===================================================================
--- strace-5.7.orig/tests-mx32/net-yy-netlink.c 2020-04-04 00:58:26.000000000 +0200
+++ strace-5.7/tests-mx32/net-yy-netlink.c 2020-09-09 14:59:52.494066225 +0200
@@ -67,13 +67,13 @@
if (bind(fd, sa, *len))
perror_msg_and_skip("bind");
printf("bind(%d" FMT_UNBOUND ", {sa_family=AF_NETLINK"
- ", nl_pid=%u, nl_groups=00000000}, %u) = 0\n",
+ ", nl_pid=%d, nl_groups=00000000}, %u) = 0\n",
fd, ARG_UNBOUND, addr.nl_pid, (unsigned) *len);
if (getsockname(fd, sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d" FMT_BOUND ", {sa_family=AF_NETLINK"
- ", nl_pid=%u, nl_groups=00000000}, [%u]) = 0\n",
+ ", nl_pid=%d, nl_groups=00000000}, [%u]) = 0\n",
fd, ARG_BOUND, addr.nl_pid, (unsigned) *len);
if (close(fd))
Index: strace-5.7/tests-mx32/netlink_protocol.c
===================================================================
--- strace-5.7.orig/tests-mx32/netlink_protocol.c 2018-12-30 16:35:21.000000000 +0100
+++ strace-5.7/tests-mx32/netlink_protocol.c 2020-09-09 14:59:52.553066260 +0200
@@ -264,7 +264,7 @@
printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
", seq=0, pid=0}, {error=-EACCES"
", msg={len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
- ", seq=%u, pid=%u}}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+ ", seq=%u, pid=%d}}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, nlh->nlmsg_len, err->msg.nlmsg_len, NLM_F_DUMP,
err->msg.nlmsg_seq, err->msg.nlmsg_pid,
nlh->nlmsg_len, sprintrc(rc));
@@ -289,7 +289,7 @@
printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
", seq=0, pid=0}, {error=-EACCES"
", msg={{len=%u, type=NLMSG_NOOP, flags=NLM_F_REQUEST|0x%x"
- ", seq=%u, pid=%u}, \"\\x61\\x62\\x63\\x64\"}}}"
+ ", seq=%u, pid=%d}, \"\\x61\\x62\\x63\\x64\"}}}"
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, nlh->nlmsg_len, err->msg.nlmsg_len, NLM_F_DUMP,
err->msg.nlmsg_seq, err->msg.nlmsg_pid,

View File

@ -1,56 +0,0 @@
From 924f71a4296be54e109784dfdb487b732bfc9bbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Fri, 17 Jul 2020 23:24:36 +0200
Subject: [PATCH 128/138] Remove tcb parameter of read_int_from_file
* defs.h (read_int_from_file): Remove tcb parameter.
* util.c (read_int_from_file): Likewise.
* msghdr.c (get_optmem_max): Remove tcb parameter of read_int_from_file.
---
defs.h | 2 +-
msghdr.c | 2 +-
util.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/defs.h b/defs.h
index d8bd513..dae1cd9 100644
--- a/defs.h
+++ b/defs.h
@@ -498,7 +498,7 @@ extern unsigned os_release;
# undef KERNEL_VERSION
# define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
-extern int read_int_from_file(struct tcb *, const char *, int *);
+extern int read_int_from_file(const char *, int *);
extern void set_sortby(const char *);
extern int set_overhead(const char *);
diff --git a/msghdr.c b/msghdr.c
index becbb51..1ab4c6e 100644
--- a/msghdr.c
+++ b/msghdr.c
@@ -293,7 +293,7 @@ get_optmem_max(struct tcb *tcp)
static int optmem_max;
if (!optmem_max) {
- if (read_int_from_file(tcp, "/proc/sys/net/core/optmem_max",
+ if (read_int_from_file("/proc/sys/net/core/optmem_max",
&optmem_max) || optmem_max <= 0) {
optmem_max = sizeof(long long) * (2 * IOV_MAX + 512);
} else {
diff --git a/util.c b/util.c
index cde76c1..286c690 100644
--- a/util.c
+++ b/util.c
@@ -1517,7 +1517,7 @@ print_abnormal_hi(const kernel_ulong_t val)
}
int
-read_int_from_file(struct tcb *tcp, const char *const fname, int *const pvalue)
+read_int_from_file(const char *const fname, int *const pvalue)
{
const int fd = open_file(fname, O_RDONLY);
if (fd < 0)
--
2.1.4

View File

@ -1,417 +0,0 @@
From 09ca090db1a67eaf590372ae85a94ba8b41223c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Mon, 27 Jul 2020 20:54:06 +0200
Subject: [PATCH 129/138] Add "struct tcb *" parameters to various functions
This is going to be needed to implement pidns support.
* defs.h (print_sockaddr): Add a "struct tcb *" parameter.
* printsiginfo.h (printsiginfo): Likewise.
* fcntl.c (print_struct_flock64): Likewise. All callers updated.
* print_fields.h (PRINT_FIELD_SOCKADDR): Likewise. All callers updated.
* printsiginfo.c (printsigsource, print_si_info, printsiginfo): Likewise.
All callers updated.
* sockaddr.c (print_sockaddr_data_un, print_sockaddr_data_in,
print_sockaddr_data_in6, print_sockaddr_data_ax25,
print_sockaddr_data_ipx, print_sockaddr_data_x25,
print_sockaddr_data_nl, print_sockaddr_data_ll,
print_sockaddr_data_bt, sockaddr_printer, print_sockaddr): Likewise.
All callers updated.
---
defs.h | 2 +-
fcntl.c | 6 +++---
msghdr.c | 4 ++--
print_fields.h | 4 ++--
print_group_req.c | 2 +-
printsiginfo.c | 22 +++++++++++-----------
printsiginfo.h | 2 +-
sock.c | 10 +++++-----
sockaddr.c | 33 ++++++++++++++++++++-------------
strace.c | 2 +-
10 files changed, 47 insertions(+), 40 deletions(-)
diff --git a/defs.h b/defs.h
index dae1cd9..48987f9 100644
--- a/defs.h
+++ b/defs.h
@@ -1059,7 +1059,7 @@ printfd(struct tcb *tcp, int fd)
* of the tracee the descriptor tcp). This is a stub.
*/
extern void printfd_pid_tracee_ns(struct tcb *tcp, pid_t pid, int fd);
-extern void print_sockaddr(const void *sa, int len);
+extern void print_sockaddr(struct tcb *, const void *sa, int len);
extern bool
print_inet_addr(int af, const void *addr, unsigned int len, const char *var_name);
extern bool
diff --git a/fcntl.c b/fcntl.c
index e84549e..345634c 100644
--- a/fcntl.c
+++ b/fcntl.c
@@ -21,7 +21,7 @@
#include "xlat/notifyflags.h"
static void
-print_struct_flock64(const struct_kernel_flock64 *fl, const int getlk)
+print_struct_flock64(struct tcb *const tcp, const struct_kernel_flock64 *fl, const int getlk)
{
PRINT_FIELD_XVAL("{", *fl, l_type, lockfcmds, "F_???");
PRINT_FIELD_XVAL(", ", *fl, l_whence, whence_codes, "SEEK_???");
@@ -38,7 +38,7 @@ printflock64(struct tcb *const tcp, const kernel_ulong_t addr, const int getlk)
struct_kernel_flock64 fl;
if (fetch_struct_flock64(tcp, addr, &fl))
- print_struct_flock64(&fl, getlk);
+ print_struct_flock64(tcp, &fl, getlk);
}
static void
@@ -47,7 +47,7 @@ printflock(struct tcb *const tcp, const kernel_ulong_t addr, const int getlk)
struct_kernel_flock64 fl;
if (fetch_struct_flock(tcp, addr, &fl))
- print_struct_flock64(&fl, getlk);
+ print_struct_flock64(tcp, &fl, getlk);
}
static void
diff --git a/msghdr.c b/msghdr.c
index 1ab4c6e..ef6dc24 100644
--- a/msghdr.c
+++ b/msghdr.c
@@ -216,7 +216,7 @@ print_cmsg_ip_recverr(struct tcb *tcp, const void *cmsg_data,
PRINT_FIELD_U(", ", *err, ee_code);
PRINT_FIELD_U(", ", *err, ee_info);
PRINT_FIELD_U(", ", *err, ee_data);
- PRINT_FIELD_SOCKADDR(", ", *err, offender);
+ PRINT_FIELD_SOCKADDR(", ", *err, offender, tcp);
tprints("}");
}
@@ -228,7 +228,7 @@ print_cmsg_ip_origdstaddr(struct tcb *tcp, const void *cmsg_data,
data_len > sizeof(struct sockaddr_storage)
? sizeof(struct sockaddr_storage) : data_len;
- print_sockaddr(cmsg_data, addr_len);
+ print_sockaddr(tcp, cmsg_data, addr_len);
}
typedef void (* const cmsg_printer)(struct tcb *, const void *, unsigned int);
diff --git a/print_fields.h b/print_fields.h
index 70dbbff..2413398 100644
--- a/print_fields.h
+++ b/print_fields.h
@@ -211,10 +211,10 @@
print_ifindex((where_).field_); \
} while (0)
-# define PRINT_FIELD_SOCKADDR(prefix_, where_, field_) \
+# define PRINT_FIELD_SOCKADDR(prefix_, where_, field_, tcp_) \
do { \
STRACE_PRINTF("%s%s=", (prefix_), #field_); \
- print_sockaddr(&(where_).field_, \
+ print_sockaddr(tcp_, &(where_).field_, \
sizeof((where_).field_)); \
} while (0)
diff --git a/print_group_req.c b/print_group_req.c
index f0ce58b..9e8ce60 100644
--- a/print_group_req.c
+++ b/print_group_req.c
@@ -30,7 +30,7 @@ MPERS_PRINTER_DECL(void, print_group_req, struct tcb *const tcp,
printaddr(addr);
} else if (!umove_or_printaddr(tcp, addr, &greq)) {
PRINT_FIELD_IFINDEX("{", greq, gr_interface);
- PRINT_FIELD_SOCKADDR(", ", greq, gr_group);
+ PRINT_FIELD_SOCKADDR(", ", greq, gr_group, tcp);
tprints("}");
}
}
diff --git a/printsiginfo.c b/printsiginfo.c
index 0a9932d..8ed1e7b 100644
--- a/printsiginfo.c
+++ b/printsiginfo.c
@@ -56,7 +56,7 @@
#endif
static void
-printsigsource(const siginfo_t *sip)
+printsigsource(struct tcb *tcp, const siginfo_t *sip)
{
PRINT_FIELD_D(", ", *sip, si_pid);
PRINT_FIELD_UID(", ", *sip, si_uid);
@@ -116,7 +116,7 @@ print_si_code(int si_signo, unsigned int si_code)
}
static void
-print_si_info(const siginfo_t *sip)
+print_si_info(struct tcb *tcp, const siginfo_t *sip)
{
if (sip->si_errno)
PRINT_FIELD_ERR_U(", ", *sip, si_errno);
@@ -124,10 +124,10 @@ print_si_info(const siginfo_t *sip)
if (SI_FROMUSER(sip)) {
switch (sip->si_code) {
case SI_USER:
- printsigsource(sip);
+ printsigsource(tcp, sip);
break;
case SI_TKILL:
- printsigsource(sip);
+ printsigsource(tcp, sip);
break;
#if defined HAVE_SIGINFO_T_SI_TIMERID && defined HAVE_SIGINFO_T_SI_OVERRUN
case SI_TIMER:
@@ -137,7 +137,7 @@ print_si_info(const siginfo_t *sip)
break;
#endif
default:
- printsigsource(sip);
+ printsigsource(tcp, sip);
if (sip->si_ptr)
printsigval(sip);
break;
@@ -145,7 +145,7 @@ print_si_info(const siginfo_t *sip)
} else {
switch (sip->si_signo) {
case SIGCHLD:
- printsigsource(sip);
+ printsigsource(tcp, sip);
tprints(", si_status=");
if (sip->si_code == CLD_EXITED)
tprintf("%d", sip->si_status);
@@ -204,7 +204,7 @@ print_si_info(const siginfo_t *sip)
#endif
default:
if (sip->si_pid || sip->si_uid)
- printsigsource(sip);
+ printsigsource(tcp, sip);
if (sip->si_ptr)
printsigval(sip);
}
@@ -215,7 +215,7 @@ print_si_info(const siginfo_t *sip)
static
#endif
void
-printsiginfo(const siginfo_t *sip)
+printsiginfo(struct tcb *tcp, const siginfo_t *sip)
{
if (sip->si_signo == 0) {
tprints("{}");
@@ -230,7 +230,7 @@ printsiginfo(const siginfo_t *sip)
#ifdef SI_NOINFO
if (sip->si_code != SI_NOINFO)
#endif
- print_si_info(sip);
+ print_si_info(tcp, sip);
tprints("}");
}
@@ -241,13 +241,13 @@ MPERS_PRINTER_DECL(void, printsiginfo_at,
siginfo_t si;
if (!umove_or_printaddr(tcp, addr, &si))
- printsiginfo(&si);
+ printsiginfo(tcp, &si);
}
static bool
print_siginfo_t(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
{
- printsiginfo((const siginfo_t *) elem_buf);
+ printsiginfo(tcp, (const siginfo_t *) elem_buf);
return true;
}
diff --git a/printsiginfo.h b/printsiginfo.h
index 4088cb5..3fec2ab 100644
--- a/printsiginfo.h
+++ b/printsiginfo.h
@@ -8,6 +8,6 @@
#ifndef STRACE_PRINTSIGINFO_H
# define STRACE_PRINTSIGINFO_H
-extern void printsiginfo(const siginfo_t *);
+extern void printsiginfo(struct tcb *, const siginfo_t *);
#endif /* !STRACE_PRINTSIGINFO_H */
diff --git a/sock.c b/sock.c
index 5b14007..99a3190 100644
--- a/sock.c
+++ b/sock.c
@@ -44,19 +44,19 @@ print_ifreq(struct tcb *const tcp, const unsigned int code,
switch (code) {
case SIOCSIFADDR:
case SIOCGIFADDR:
- PRINT_FIELD_SOCKADDR("", *ifr, ifr_addr);
+ PRINT_FIELD_SOCKADDR("", *ifr, ifr_addr, tcp);
break;
case SIOCSIFDSTADDR:
case SIOCGIFDSTADDR:
- PRINT_FIELD_SOCKADDR("", *ifr, ifr_dstaddr);
+ PRINT_FIELD_SOCKADDR("", *ifr, ifr_dstaddr, tcp);
break;
case SIOCSIFBRDADDR:
case SIOCGIFBRDADDR:
- PRINT_FIELD_SOCKADDR("", *ifr, ifr_broadaddr);
+ PRINT_FIELD_SOCKADDR("", *ifr, ifr_broadaddr, tcp);
break;
case SIOCSIFNETMASK:
case SIOCGIFNETMASK:
- PRINT_FIELD_SOCKADDR("", *ifr, ifr_netmask);
+ PRINT_FIELD_SOCKADDR("", *ifr, ifr_netmask, tcp);
break;
case SIOCSIFHWADDR:
case SIOCGIFHWADDR: {
@@ -126,7 +126,7 @@ print_ifconf_ifreq(struct tcb *tcp, void *elem_buf, size_t elem_size,
tprints("{ifr_name=");
print_ifname(ifr->ifr_name);
- PRINT_FIELD_SOCKADDR(", ", *ifr, ifr_addr);
+ PRINT_FIELD_SOCKADDR(", ", *ifr, ifr_addr, tcp);
tprints("}");
return true;
diff --git a/sockaddr.c b/sockaddr.c
index b6b9aa7..b004633 100644
--- a/sockaddr.c
+++ b/sockaddr.c
@@ -47,7 +47,7 @@ const size_t arp_hardware_types_size = ARRAY_SIZE(arp_hardware_types) - 1;
const size_t ethernet_protocols_size = ARRAY_SIZE(ethernet_protocols) - 1;
static void
-print_sockaddr_data_un(const void *const buf, const int addrlen)
+print_sockaddr_data_un(struct tcb *tcp, const void *const buf, const int addrlen)
{
const struct sockaddr_un *const sa_un = buf;
const int un_len = addrlen > (int) sizeof(*sa_un)
@@ -172,7 +172,8 @@ decode_inet_addr(struct tcb *const tcp,
}
static void
-print_sockaddr_data_in(const void *const buf, const int addrlen)
+print_sockaddr_data_in(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
const struct sockaddr_in *const sa_in = buf;
@@ -183,7 +184,8 @@ print_sockaddr_data_in(const void *const buf, const int addrlen)
#define SIN6_MIN_LEN offsetof(struct sockaddr_in6, sin6_scope_id)
static void
-print_sockaddr_data_in6(const void *const buf, const int addrlen)
+print_sockaddr_data_in6(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
const struct sockaddr_in6 *const sa_in6 = buf;
@@ -322,7 +324,8 @@ print_ax25_addr(const void /* ax25_address */ *addr_void)
}
static void
-print_sockaddr_data_ax25(const void *const buf, const int addrlen)
+print_sockaddr_data_ax25(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
const struct full_sockaddr_ax25 *const sax25 = buf;
size_t addrlen_us = MAX(addrlen, 0);
@@ -372,7 +375,8 @@ digis_end:
}
static void
-print_sockaddr_data_ipx(const void *const buf, const int addrlen)
+print_sockaddr_data_ipx(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
const struct sockaddr_ipx *const sa_ipx = buf;
unsigned int i;
@@ -399,7 +403,8 @@ print_x25_addr(const void /* struct x25_address */ *addr_void)
}
static void
-print_sockaddr_data_x25(const void *const buf, const int addrlen)
+print_sockaddr_data_x25(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
const struct sockaddr_x25 *const sa_x25 = buf;
@@ -407,7 +412,7 @@ print_sockaddr_data_x25(const void *const buf, const int addrlen)
}
static void
-print_sockaddr_data_nl(const void *const buf, const int addrlen)
+print_sockaddr_data_nl(struct tcb *tcp, const void *const buf, const int addrlen)
{
const struct sockaddr_nl *const sa_nl = buf;
@@ -442,7 +447,8 @@ print_sll_protocol(const struct sockaddr_ll *const sa_ll)
}
static void
-print_sockaddr_data_ll(const void *const buf, const int addrlen)
+print_sockaddr_data_ll(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
const struct sockaddr_ll *const sa_ll = buf;
@@ -567,7 +573,8 @@ print_bluetooth_l2_cid_end:
}
static void
-print_sockaddr_data_bt(const void *const buf, const int addrlen)
+print_sockaddr_data_bt(struct tcb *tcp, const void *const buf,
+ const int addrlen)
{
struct sockaddr_hci {
/* sa_family_t */ uint16_t hci_family;
@@ -651,7 +658,7 @@ print_sockaddr_data_bt(const void *const buf, const int addrlen)
}
}
-typedef void (* const sockaddr_printer)(const void *const, const int);
+typedef void (* const sockaddr_printer)(struct tcb *tcp, const void *const, const int);
static const struct {
const sockaddr_printer printer;
@@ -669,7 +676,7 @@ static const struct {
};
void
-print_sockaddr(const void *const buf, const int addrlen)
+print_sockaddr(struct tcb *tcp, const void *const buf, const int addrlen)
{
const struct sockaddr *const sa = buf;
@@ -682,7 +689,7 @@ print_sockaddr(const void *const buf, const int addrlen)
if (sa->sa_family < ARRAY_SIZE(sa_printers)
&& sa_printers[sa->sa_family].printer
&& addrlen >= sa_printers[sa->sa_family].min_len) {
- sa_printers[sa->sa_family].printer(buf, addrlen);
+ sa_printers[sa->sa_family].printer(tcp, buf, addrlen);
} else {
print_sockaddr_data_raw(buf, addrlen);
}
@@ -713,7 +720,7 @@ decode_sockaddr(struct tcb *const tcp, const kernel_ulong_t addr, int addrlen)
memset(&addrbuf.pad[addrlen], 0, sizeof(addrbuf.pad) - addrlen);
- print_sockaddr(&addrbuf, addrlen);
+ print_sockaddr(tcp, &addrbuf, addrlen);
return addrbuf.sa.sa_family;
}
diff --git a/strace.c b/strace.c
index 311e4d6..4c96a98 100644
--- a/strace.c
+++ b/strace.c
@@ -2941,7 +2941,7 @@ print_stopped(struct tcb *tcp, const siginfo_t *si, const unsigned int sig)
printleader(tcp);
if (si) {
tprintf("--- %s ", sprintsigname(sig));
- printsiginfo(si);
+ printsiginfo(tcp, si);
tprints(" ---\n");
} else
tprintf("--- stopped by %s ---\n", sprintsigname(sig));
--
2.1.4

View File

@ -1,415 +0,0 @@
From 98cb4de5002be3b81c45489200bcab0ae323123d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Mon, 27 Jul 2020 20:54:07 +0200
Subject: [PATCH 131/138] Introduce SYS_FUNC(tkill)
This is going to be needed to implement pidns support
in tkill syscall decoder.
syscallent*.h files are updated automatically by:
git grep -l 'SEN(kill).*"tkill"' |
xargs sed -i '/"tkill"/ s/SEN(kill)/SEN(tkill)/'
* signal.c (SYS_FUNC(tkill)): New syscall decoder.
* linux/32/syscallent.h: Use SEN(tkill) for "tkill" syscall.
* linux/64/syscallent.h: Likewise.
* linux/alpha/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/powerpc64/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/xtensa/syscallent.h: Likewise.
---
linux/32/syscallent.h | 2 +-
linux/64/syscallent.h | 2 +-
linux/alpha/syscallent.h | 2 +-
linux/arm/syscallent.h | 2 +-
linux/avr32/syscallent.h | 2 +-
linux/bfin/syscallent.h | 2 +-
linux/hppa/syscallent.h | 2 +-
linux/i386/syscallent.h | 2 +-
linux/ia64/syscallent.h | 2 +-
linux/m68k/syscallent.h | 2 +-
linux/microblaze/syscallent.h | 2 +-
linux/mips/syscallent-n32.h | 2 +-
linux/mips/syscallent-n64.h | 2 +-
linux/mips/syscallent-o32.h | 2 +-
linux/powerpc/syscallent.h | 2 +-
linux/powerpc64/syscallent.h | 2 +-
linux/s390/syscallent.h | 2 +-
linux/s390x/syscallent.h | 2 +-
linux/sh/syscallent.h | 2 +-
linux/sh64/syscallent.h | 2 +-
linux/sparc/syscallent.h | 2 +-
linux/sparc64/syscallent.h | 2 +-
linux/x32/syscallent.h | 2 +-
linux/x86_64/syscallent.h | 2 +-
linux/xtensa/syscallent.h | 2 +-
signal.c | 9 +++++++++
26 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/linux/32/syscallent.h b/linux/32/syscallent.h
index c74ab18..79c36e0 100644
--- a/linux/32/syscallent.h
+++ b/linux/32/syscallent.h
@@ -142,7 +142,7 @@
/* [127] sched_rr_get_interval */
[128] = { 0, 0, SEN(restart_syscall), "restart_syscall" },
[129] = { 2, TS|TP, SEN(kill), "kill" },
-[130] = { 2, TS|TP, SEN(kill), "tkill" },
+[130] = { 2, TS|TP, SEN(tkill), "tkill" },
[131] = { 3, TS|TP, SEN(tgkill), "tgkill" },
[132] = { 2, TS, SEN(sigaltstack), "sigaltstack" },
[133] = { 2, TS, SEN(rt_sigsuspend), "rt_sigsuspend" },
diff --git a/linux/64/syscallent.h b/linux/64/syscallent.h
index 3fb1305..ce5602e 100644
--- a/linux/64/syscallent.h
+++ b/linux/64/syscallent.h
@@ -135,7 +135,7 @@
[127] = { 2, 0, SEN(sched_rr_get_interval_time64),"sched_rr_get_interval"},
[128] = { 0, 0, SEN(restart_syscall), "restart_syscall" },
[129] = { 2, TS|TP, SEN(kill), "kill" },
-[130] = { 2, TS|TP, SEN(kill), "tkill" },
+[130] = { 2, TS|TP, SEN(tkill), "tkill" },
[131] = { 3, TS|TP, SEN(tgkill), "tgkill" },
[132] = { 2, TS, SEN(sigaltstack), "sigaltstack" },
[133] = { 2, TS, SEN(rt_sigsuspend), "rt_sigsuspend" },
diff --git a/linux/alpha/syscallent.h b/linux/alpha/syscallent.h
index 93f0b0e..7859b9c 100644
--- a/linux/alpha/syscallent.h
+++ b/linux/alpha/syscallent.h
@@ -325,7 +325,7 @@
[378] = { 0, PU|NF, SEN(gettid), "gettid" },
[379] = { 3, TD, SEN(readahead), "readahead" },
[380] = { },
-[381] = { 2, TS|TP, SEN(kill), "tkill" },
+[381] = { 2, TS|TP, SEN(tkill), "tkill" },
[382] = { 5, TF, SEN(setxattr), "setxattr" },
[383] = { 5, TF, SEN(setxattr), "lsetxattr" },
[384] = { 5, TD, SEN(fsetxattr), "fsetxattr" },
diff --git a/linux/arm/syscallent.h b/linux/arm/syscallent.h
index 73497b6..87b0687 100644
--- a/linux/arm/syscallent.h
+++ b/linux/arm/syscallent.h
@@ -245,7 +245,7 @@
[235] = { 2, TF, SEN(removexattr), "removexattr" },
[236] = { 2, TF, SEN(removexattr), "lremovexattr" },
[237] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[238] = { 2, TS|TP, SEN(kill), "tkill" },
+[238] = { 2, TS|TP, SEN(tkill), "tkill" },
[239] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[240] = { 6, 0, SEN(futex_time32), "futex" },
[241] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/avr32/syscallent.h b/linux/avr32/syscallent.h
index b3cf2da..491ff8e 100644
--- a/linux/avr32/syscallent.h
+++ b/linux/avr32/syscallent.h
@@ -196,7 +196,7 @@
[187] = { 2, TF, SEN(removexattr), "removexattr" },
[188] = { 2, TF, SEN(removexattr), "lremovexattr" },
[189] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[190] = { 2, TS|TP, SEN(kill), "tkill" },
+[190] = { 2, TS|TP, SEN(tkill), "tkill" },
[191] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[192] = { 6, 0, SEN(futex_time32), "futex" },
[193] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/bfin/syscallent.h b/linux/bfin/syscallent.h
index b93a844..53d5c23 100644
--- a/linux/bfin/syscallent.h
+++ b/linux/bfin/syscallent.h
@@ -244,7 +244,7 @@
[235] = { 2, TF, SEN(removexattr), "removexattr" },
[236] = { 2, TF, SEN(removexattr), "lremovexattr" },
[237] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[238] = { 2, TS|TP, SEN(kill), "tkill" },
+[238] = { 2, TS|TP, SEN(tkill), "tkill" },
[239] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[240] = { 6, 0, SEN(futex_time32), "futex" },
[241] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/hppa/syscallent.h b/linux/hppa/syscallent.h
index 31341d4..20cae3c 100644
--- a/linux/hppa/syscallent.h
+++ b/linux/hppa/syscallent.h
@@ -211,7 +211,7 @@
[205] = { 5, 0, SEN(printargs), "acl_set" },
[206] = { 0, PU|NF, SEN(gettid), "gettid" },
[207] = { 4, TD, SEN(readahead), "readahead" },
-[208] = { 2, TS|TP, SEN(kill), "tkill" },
+[208] = { 2, TS|TP, SEN(tkill), "tkill" },
[209] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[210] = { 6, 0, SEN(futex_time32), "futex" },
[211] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/i386/syscallent.h b/linux/i386/syscallent.h
index efe0ff7..521e7ba 100644
--- a/linux/i386/syscallent.h
+++ b/linux/i386/syscallent.h
@@ -244,7 +244,7 @@
[235] = { 2, TF, SEN(removexattr), "removexattr" },
[236] = { 2, TF, SEN(removexattr), "lremovexattr" },
[237] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[238] = { 2, TS|TP, SEN(kill), "tkill" },
+[238] = { 2, TS|TP, SEN(tkill), "tkill" },
[239] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[240] = { 6, 0, SEN(futex_time32), "futex" },
[241] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/ia64/syscallent.h b/linux/ia64/syscallent.h
index 8aeda41..c5088e1 100644
--- a/linux/ia64/syscallent.h
+++ b/linux/ia64/syscallent.h
@@ -225,7 +225,7 @@
[BASE_NR + 202] = { 2, TF, SEN(removexattr), "removexattr" },
[BASE_NR + 203] = { 2, TF, SEN(removexattr), "lremovexattr" },
[BASE_NR + 204] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[BASE_NR + 205] = { 2, TS|TP, SEN(kill), "tkill" },
+[BASE_NR + 205] = { 2, TS|TP, SEN(tkill), "tkill" },
[BASE_NR + 206] = { 6, 0, SEN(futex_time64), "futex" },
[BASE_NR + 207] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
[BASE_NR + 208] = { 3, 0, SEN(sched_getaffinity), "sched_getaffinity" },
diff --git a/linux/m68k/syscallent.h b/linux/m68k/syscallent.h
index 1876bed..107780c 100644
--- a/linux/m68k/syscallent.h
+++ b/linux/m68k/syscallent.h
@@ -228,7 +228,7 @@
[218 ... 219] = { },
[220] = { 3, TD, SEN(getdents64), "getdents64" },
[221] = { 0, PU|NF, SEN(gettid), "gettid" },
-[222] = { 2, TS|TP, SEN(kill), "tkill" },
+[222] = { 2, TS|TP, SEN(tkill), "tkill" },
[223] = { 5, TF, SEN(setxattr), "setxattr" },
[224] = { 5, TF, SEN(setxattr), "lsetxattr" },
[225] = { 5, TD, SEN(fsetxattr), "fsetxattr" },
diff --git a/linux/microblaze/syscallent.h b/linux/microblaze/syscallent.h
index 5d071bc..d830a3e 100644
--- a/linux/microblaze/syscallent.h
+++ b/linux/microblaze/syscallent.h
@@ -244,7 +244,7 @@
[235] = { 2, TF, SEN(removexattr), "removexattr" },
[236] = { 2, TF, SEN(removexattr), "lremovexattr" },
[237] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[238] = { 2, TS|TP, SEN(kill), "tkill" },
+[238] = { 2, TS|TP, SEN(tkill), "tkill" },
[239] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[240] = { 6, 0, SEN(futex_time32), "futex" },
[241] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/mips/syscallent-n32.h b/linux/mips/syscallent-n32.h
index cfd199d..5ab0c53 100644
--- a/linux/mips/syscallent-n32.h
+++ b/linux/mips/syscallent-n32.h
@@ -200,7 +200,7 @@
[BASE_NR + 189] = { 2, TF, SEN(removexattr), "removexattr" },
[BASE_NR + 190] = { 2, TF, SEN(removexattr), "lremovexattr" },
[BASE_NR + 191] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[BASE_NR + 192] = { 2, TS|TP, SEN(kill), "tkill" },
+[BASE_NR + 192] = { 2, TS|TP, SEN(tkill), "tkill" },
[BASE_NR + 193] = { 1, TCL, SEN(time), "time" },
[BASE_NR + 194] = { 6, 0, SEN(futex_time32), "futex" },
[BASE_NR + 195] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/mips/syscallent-n64.h b/linux/mips/syscallent-n64.h
index 7ef6700..1964872 100644
--- a/linux/mips/syscallent-n64.h
+++ b/linux/mips/syscallent-n64.h
@@ -200,7 +200,7 @@
[BASE_NR + 189] = { 2, TF, SEN(removexattr), "removexattr" },
[BASE_NR + 190] = { 2, TF, SEN(removexattr), "lremovexattr" },
[BASE_NR + 191] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[BASE_NR + 192] = { 2, TS|TP, SEN(kill), "tkill" },
+[BASE_NR + 192] = { 2, TS|TP, SEN(tkill), "tkill" },
[BASE_NR + 193] = { 1, TCL, SEN(time), "time" },
[BASE_NR + 194] = { 6, 0, SEN(futex_time64), "futex" },
[BASE_NR + 195] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/mips/syscallent-o32.h b/linux/mips/syscallent-o32.h
index d2b26f7..eb8908e 100644
--- a/linux/mips/syscallent-o32.h
+++ b/linux/mips/syscallent-o32.h
@@ -245,7 +245,7 @@
[BASE_NR + 233] = { 2, TF, SEN(removexattr), "removexattr" },
[BASE_NR + 234] = { 2, TF, SEN(removexattr), "lremovexattr" },
[BASE_NR + 235] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[BASE_NR + 236] = { 2, TS|TP, SEN(kill), "tkill" },
+[BASE_NR + 236] = { 2, TS|TP, SEN(tkill), "tkill" },
[BASE_NR + 237] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[BASE_NR + 238] = { 6, 0, SEN(futex_time32), "futex" },
[BASE_NR + 239] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/powerpc/syscallent.h b/linux/powerpc/syscallent.h
index b0962b4..7a77979 100644
--- a/linux/powerpc/syscallent.h
+++ b/linux/powerpc/syscallent.h
@@ -215,7 +215,7 @@
[205] = { 3, TM, SEN(madvise), "madvise" },
[206] = { 3, TM, SEN(mincore), "mincore" },
[207] = { 0, PU|NF, SEN(gettid), "gettid" },
-[208] = { 2, TS|TP, SEN(kill), "tkill" },
+[208] = { 2, TS|TP, SEN(tkill), "tkill" },
[209] = { 5, TF, SEN(setxattr), "setxattr" },
[210] = { 5, TF, SEN(setxattr), "lsetxattr" },
[211] = { 5, TD, SEN(fsetxattr), "fsetxattr" },
diff --git a/linux/powerpc64/syscallent.h b/linux/powerpc64/syscallent.h
index 1a0dfb5..f20fd78 100644
--- a/linux/powerpc64/syscallent.h
+++ b/linux/powerpc64/syscallent.h
@@ -210,7 +210,7 @@
[205] = { 3, TM, SEN(madvise), "madvise" },
[206] = { 3, TM, SEN(mincore), "mincore" },
[207] = { 0, PU|NF, SEN(gettid), "gettid" },
-[208] = { 2, TS|TP, SEN(kill), "tkill" },
+[208] = { 2, TS|TP, SEN(tkill), "tkill" },
[209] = { 5, TF, SEN(setxattr), "setxattr" },
[210] = { 5, TF, SEN(setxattr), "lsetxattr" },
[211] = { 5, TD, SEN(fsetxattr), "fsetxattr" },
diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index 105089f..6844c7e 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -246,7 +246,7 @@
[234] = { 2, TF, SEN(removexattr), "lremovexattr" },
[235] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
[236] = { 0, PU|NF, SEN(gettid), "gettid" },
-[237] = { 2, TS|TP, SEN(kill), "tkill" },
+[237] = { 2, TS|TP, SEN(tkill), "tkill" },
[238] = { 6, 0, SEN(futex_time32), "futex" },
[239] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
[240] = { 3, 0, SEN(sched_getaffinity), "sched_getaffinity" },
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index e9cf57a..c805204 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -230,7 +230,7 @@
[234] = { 2, TF, SEN(removexattr), "lremovexattr" },
[235] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
[236] = { 0, PU|NF, SEN(gettid), "gettid" },
-[237] = { 2, TS|TP, SEN(kill), "tkill" },
+[237] = { 2, TS|TP, SEN(tkill), "tkill" },
[238] = { 6, 0, SEN(futex_time64), "futex" },
[239] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
[240] = { 3, 0, SEN(sched_getaffinity), "sched_getaffinity" },
diff --git a/linux/sh/syscallent.h b/linux/sh/syscallent.h
index 70dc7da..6a89f75 100644
--- a/linux/sh/syscallent.h
+++ b/linux/sh/syscallent.h
@@ -245,7 +245,7 @@
[235] = { 2, TF, SEN(removexattr), "removexattr" },
[236] = { 2, TF, SEN(removexattr), "lremovexattr" },
[237] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[238] = { 2, TS|TP, SEN(kill), "tkill" },
+[238] = { 2, TS|TP, SEN(tkill), "tkill" },
[239] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[240] = { 6, 0, SEN(futex_time32), "futex" },
[241] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/sh64/syscallent.h b/linux/sh64/syscallent.h
index eff5dc0..4ec35d3 100644
--- a/linux/sh64/syscallent.h
+++ b/linux/sh64/syscallent.h
@@ -271,7 +271,7 @@
[263] = { 2, TF, SEN(removexattr), "removexattr" },
[264] = { 2, TF, SEN(removexattr), "lremovexattr" },
[265] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[266] = { 2, TS|TP, SEN(kill), "tkill" },
+[266] = { 2, TS|TP, SEN(tkill), "tkill" },
[267] = { 4, TD|TN, SEN(sendfile64), "sendfile64" },
[268] = { 6, 0, SEN(futex_time64), "futex" },
[269] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/sparc/syscallent.h b/linux/sparc/syscallent.h
index 8c8bd18..a274791 100644
--- a/linux/sparc/syscallent.h
+++ b/linux/sparc/syscallent.h
@@ -192,7 +192,7 @@
[184] = { 5, 0, SEN(query_module), "query_module" },
[185] = { 2, 0, SEN(setpgid), "setpgid" },
[186] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[187] = { 2, TS|TP, SEN(kill), "tkill" },
+[187] = { 2, TS|TP, SEN(tkill), "tkill" },
[188] = { 1, TP|SE, SEN(exit), "exit_group" },
[189] = { 1, 0, SEN(uname), "uname" },
[190] = { 3, 0, SEN(init_module), "init_module" },
diff --git a/linux/sparc64/syscallent.h b/linux/sparc64/syscallent.h
index 0e0e0c4..61c32f9 100644
--- a/linux/sparc64/syscallent.h
+++ b/linux/sparc64/syscallent.h
@@ -190,7 +190,7 @@
[184] = { 5, 0, SEN(query_module), "query_module" },
[185] = { 2, 0, SEN(setpgid), "setpgid" },
[186] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[187] = { 2, TS|TP, SEN(kill), "tkill" },
+[187] = { 2, TS|TP, SEN(tkill), "tkill" },
[188] = { 1, TP|SE, SEN(exit), "exit_group" },
[189] = { 1, 0, SEN(uname), "uname" },
[190] = { 3, 0, SEN(init_module), "init_module" },
diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h
index db8ecfd..d64060d 100644
--- a/linux/x32/syscallent.h
+++ b/linux/x32/syscallent.h
@@ -205,7 +205,7 @@
[197] = { 2, TF, SEN(removexattr), "removexattr" },
[198] = { 2, TF, SEN(removexattr), "lremovexattr" },
[199] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[200] = { 2, TS|TP, SEN(kill), "tkill" },
+[200] = { 2, TS|TP, SEN(tkill), "tkill" },
[201] = { 1, TCL, SEN(time), "time" },
[202] = { 6, 0, SEN(futex_time64), "futex" },
[203] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h
index c69a5aa..027093a 100644
--- a/linux/x86_64/syscallent.h
+++ b/linux/x86_64/syscallent.h
@@ -205,7 +205,7 @@
[197] = { 2, TF, SEN(removexattr), "removexattr" },
[198] = { 2, TF, SEN(removexattr), "lremovexattr" },
[199] = { 2, TD, SEN(fremovexattr), "fremovexattr" },
-[200] = { 2, TS|TP, SEN(kill), "tkill" },
+[200] = { 2, TS|TP, SEN(tkill), "tkill" },
[201] = { 1, TCL, SEN(time), "time" },
[202] = { 6, 0, SEN(futex_time64), "futex" },
[203] = { 3, 0, SEN(sched_setaffinity), "sched_setaffinity" },
diff --git a/linux/xtensa/syscallent.h b/linux/xtensa/syscallent.h
index 61f1dd4..6de03d2 100644
--- a/linux/xtensa/syscallent.h
+++ b/linux/xtensa/syscallent.h
@@ -124,7 +124,7 @@
[121] = { 4, TP, SEN(wait4), "wait4" },
[122] = { 5, TP, SEN(waitid), "waitid" },
[123] = { 2, TS|TP, SEN(kill), "kill" },
-[124] = { 2, TS|TP, SEN(kill), "tkill" },
+[124] = { 2, TS|TP, SEN(tkill), "tkill" },
[125] = { 3, TS|TP, SEN(tgkill), "tgkill" },
[126] = { 1, 0, SEN(set_tid_address), "set_tid_address" },
[127] = { 0, PU|NF, SEN(gettid), "gettid" },
diff --git a/signal.c b/signal.c
index 3cb54bb..5f1acac 100644
--- a/signal.c
+++ b/signal.c
@@ -446,6 +446,15 @@ SYS_FUNC(kill)
return RVAL_DECODED;
}
+SYS_FUNC(tkill)
+{
+ tprintf("%d", (int) tcp->u_arg[0]);
+ tprints(", ");
+ printsignal(tcp->u_arg[1]);
+
+ return RVAL_DECODED;
+}
+
SYS_FUNC(tgkill)
{
/* tgid, tid */
--
2.1.4

View File

@ -1,683 +0,0 @@
From 24119509205a17c71de10e913cfc38dc52aa6563 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 1 Aug 2020 08:00:00 +0000
Subject: [PATCH 132/138] tests: check decoding of tkill syscall
* tests/tkill.c: New file.
* tests/gen_tests.in (tkill): New entry.
* tests/pure_executables.list: Add tkill.
* tests/.gitignore: Likewise.
---
tests/.gitignore | 1 +
tests/gen_tests.in | 1 +
tests/pure_executables.list | 1 +
tests/tkill.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 63 insertions(+)
create mode 100644 tests/tkill.c
Index: strace-5.7/tests/gen_tests.in
===================================================================
--- strace-5.7.orig/tests/gen_tests.in 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests/gen_tests.in 2020-09-09 19:30:36.780885588 +0200
@@ -668,6 +668,7 @@
timerfd_xettime -e trace=timerfd_create,timerfd_settime,timerfd_gettime
times -esignal=none
times-fail -a12 -e trace=times
+tkill -a12 --signal='!cont'
trace_clock test_trace_expr 'clock_nanosleep|times' -e%clock
trace_creds test_trace_expr '([gs]et[^p]*([gu]id|groups)|caps|prctl|[fl]?chown|print(path-umovestr|strn-umoven)-undumpable|ptrace|quotactl|rt_sigtimedwait|rt_(tg)?sigqueueinfo).*' -e%creds
trace_fstat test_trace_expr '' -e%fstat -v -P stat.sample -P /dev/full
Index: strace-5.7/tests/pure_executables.list
===================================================================
--- strace-5.7.orig/tests/pure_executables.list 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests/pure_executables.list 2020-09-09 19:30:36.780885588 +0200
@@ -589,6 +589,7 @@
timerfd_xettime
times
times-fail
+tkill
truncate
truncate64
ugetrlimit
Index: strace-5.7/tests/tkill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests/tkill.c 2020-09-09 19:21:10.469548041 +0200
@@ -0,0 +1,60 @@
+/*
+ * Check decoding of tkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tkill(const unsigned int tid, const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tid;
+ const kernel_ulong_t arg2 = fill | sig;
+ const long rc = syscall(__NR_tkill, arg1, arg2, bad, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tkill(pid, 0);
+ printf("tkill(%d, 0) = %s\n", pid, errstr);
+
+ k_tkill(pid, SIGCONT);
+ printf("tkill(%d, SIGCONT) = %s\n", pid, errstr);
+
+ k_tkill(bad_pid, bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, bad_sig, errstr);
+
+ k_tkill(bad_pid, -bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tkill")
+
+#endif
Index: strace-5.7/tests-m32/gen_tests.in
===================================================================
--- strace-5.7.orig/tests-m32/gen_tests.in 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests-m32/gen_tests.in 2020-09-09 19:30:36.780885588 +0200
@@ -668,6 +668,7 @@
timerfd_xettime -e trace=timerfd_create,timerfd_settime,timerfd_gettime
times -esignal=none
times-fail -a12 -e trace=times
+tkill -a12 --signal='!cont'
trace_clock test_trace_expr 'clock_nanosleep|times' -e%clock
trace_creds test_trace_expr '([gs]et[^p]*([gu]id|groups)|caps|prctl|[fl]?chown|print(path-umovestr|strn-umoven)-undumpable|ptrace|quotactl|rt_sigtimedwait|rt_(tg)?sigqueueinfo).*' -e%creds
trace_fstat test_trace_expr '' -e%fstat -v -P stat.sample -P /dev/full
Index: strace-5.7/tests-m32/pure_executables.list
===================================================================
--- strace-5.7.orig/tests-m32/pure_executables.list 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests-m32/pure_executables.list 2020-09-09 19:30:36.780885588 +0200
@@ -589,6 +589,7 @@
timerfd_xettime
times
times-fail
+tkill
truncate
truncate64
ugetrlimit
Index: strace-5.7/tests-m32/tkill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-m32/tkill.c 2020-09-09 19:21:10.469548041 +0200
@@ -0,0 +1,60 @@
+/*
+ * Check decoding of tkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tkill(const unsigned int tid, const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tid;
+ const kernel_ulong_t arg2 = fill | sig;
+ const long rc = syscall(__NR_tkill, arg1, arg2, bad, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tkill(pid, 0);
+ printf("tkill(%d, 0) = %s\n", pid, errstr);
+
+ k_tkill(pid, SIGCONT);
+ printf("tkill(%d, SIGCONT) = %s\n", pid, errstr);
+
+ k_tkill(bad_pid, bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, bad_sig, errstr);
+
+ k_tkill(bad_pid, -bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tkill")
+
+#endif
Index: strace-5.7/tests-mx32/gen_tests.in
===================================================================
--- strace-5.7.orig/tests-mx32/gen_tests.in 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests-mx32/gen_tests.in 2020-09-09 19:30:36.780885588 +0200
@@ -668,6 +668,7 @@
timerfd_xettime -e trace=timerfd_create,timerfd_settime,timerfd_gettime
times -esignal=none
times-fail -a12 -e trace=times
+tkill -a12 --signal='!cont'
trace_clock test_trace_expr 'clock_nanosleep|times' -e%clock
trace_creds test_trace_expr '([gs]et[^p]*([gu]id|groups)|caps|prctl|[fl]?chown|print(path-umovestr|strn-umoven)-undumpable|ptrace|quotactl|rt_sigtimedwait|rt_(tg)?sigqueueinfo).*' -e%creds
trace_fstat test_trace_expr '' -e%fstat -v -P stat.sample -P /dev/full
Index: strace-5.7/tests-mx32/pure_executables.list
===================================================================
--- strace-5.7.orig/tests-mx32/pure_executables.list 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests-mx32/pure_executables.list 2020-09-09 19:30:36.780885588 +0200
@@ -589,6 +589,7 @@
timerfd_xettime
times
times-fail
+tkill
truncate
truncate64
ugetrlimit
Index: strace-5.7/tests-mx32/tkill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-mx32/tkill.c 2020-09-09 19:21:10.469548041 +0200
@@ -0,0 +1,60 @@
+/*
+ * Check decoding of tkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tkill(const unsigned int tid, const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tid;
+ const kernel_ulong_t arg2 = fill | sig;
+ const long rc = syscall(__NR_tkill, arg1, arg2, bad, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tkill(pid, 0);
+ printf("tkill(%d, 0) = %s\n", pid, errstr);
+
+ k_tkill(pid, SIGCONT);
+ printf("tkill(%d, SIGCONT) = %s\n", pid, errstr);
+
+ k_tkill(bad_pid, bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, bad_sig, errstr);
+
+ k_tkill(bad_pid, -bad_sig);
+ printf("tkill(%d, %d) = %s\n", bad_pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tkill")
+
+#endif
Index: strace-5.7/tests-m32/Makefile.in
===================================================================
--- strace-5.7.orig/tests-m32/Makefile.in 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests-m32/Makefile.in 2020-09-09 19:32:14.800944013 +0200
@@ -496,14 +496,15 @@
sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) time$(EXEEXT) \
timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
timerfd_xettime$(EXEEXT) times$(EXEEXT) times-fail$(EXEEXT) \
- truncate$(EXEEXT) truncate64$(EXEEXT) ugetrlimit$(EXEEXT) \
- uio$(EXEEXT) umask$(EXEEXT) umount$(EXEEXT) umount2$(EXEEXT) \
- umoven-illptr$(EXEEXT) umovestr$(EXEEXT) \
- umovestr-illptr$(EXEEXT) umovestr2$(EXEEXT) umovestr3$(EXEEXT) \
- umovestr_cached$(EXEEXT) umovestr_cached_adjacent$(EXEEXT) \
- uname$(EXEEXT) unlink$(EXEEXT) unlinkat$(EXEEXT) \
- unshare$(EXEEXT) userfaultfd$(EXEEXT) ustat$(EXEEXT) \
- utime$(EXEEXT) utimensat$(EXEEXT) utimensat-Xabbrev$(EXEEXT) \
+ tkill$(EXEEXT) truncate$(EXEEXT) truncate64$(EXEEXT) \
+ ugetrlimit$(EXEEXT) uio$(EXEEXT) umask$(EXEEXT) \
+ umount$(EXEEXT) umount2$(EXEEXT) umoven-illptr$(EXEEXT) \
+ umovestr$(EXEEXT) umovestr-illptr$(EXEEXT) umovestr2$(EXEEXT) \
+ umovestr3$(EXEEXT) umovestr_cached$(EXEEXT) \
+ umovestr_cached_adjacent$(EXEEXT) uname$(EXEEXT) \
+ unlink$(EXEEXT) unlinkat$(EXEEXT) unshare$(EXEEXT) \
+ userfaultfd$(EXEEXT) ustat$(EXEEXT) utime$(EXEEXT) \
+ utimensat$(EXEEXT) utimensat-Xabbrev$(EXEEXT) \
utimensat-Xraw$(EXEEXT) utimensat-Xverbose$(EXEEXT) \
utimes$(EXEEXT) vhangup$(EXEEXT) vmsplice$(EXEEXT) \
wait4$(EXEEXT) waitid$(EXEEXT) waitpid$(EXEEXT) xattr$(EXEEXT) \
@@ -3484,6 +3485,10 @@
times_fail_OBJECTS = times-fail.$(OBJEXT)
times_fail_LDADD = $(LDADD)
times_fail_DEPENDENCIES = libtests.a
+tkill_SOURCES = tkill.c
+tkill_OBJECTS = tkill.$(OBJEXT)
+tkill_LDADD = $(LDADD)
+tkill_DEPENDENCIES = libtests.a
tracer_ppid_pgid_sid_SOURCES = tracer_ppid_pgid_sid.c
tracer_ppid_pgid_sid_OBJECTS = tracer_ppid_pgid_sid.$(OBJEXT)
tracer_ppid_pgid_sid_LDADD = $(LDADD)
@@ -4184,7 +4189,7 @@
./$(DEPDIR)/threads-execve.Po ./$(DEPDIR)/time.Po \
./$(DEPDIR)/timer_create.Po ./$(DEPDIR)/timer_xettime.Po \
./$(DEPDIR)/timerfd_xettime.Po ./$(DEPDIR)/times-fail.Po \
- ./$(DEPDIR)/times.Po ./$(DEPDIR)/tracer_ppid_pgid_sid.Po \
+ ./$(DEPDIR)/times.Po ./$(DEPDIR)/tkill.Po ./$(DEPDIR)/tracer_ppid_pgid_sid.Po \
./$(DEPDIR)/truncate.Po ./$(DEPDIR)/truncate64-truncate64.Po \
./$(DEPDIR)/ugetrlimit.Po ./$(DEPDIR)/uio-uio.Po \
./$(DEPDIR)/umask.Po ./$(DEPDIR)/umount.Po \
@@ -4441,7 +4446,7 @@
syslog-success.c tee.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
- timer_xettime.c timerfd_xettime.c times.c times-fail.c \
+ timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
tracer_ppid_pgid_sid.c truncate.c truncate64.c ugetrlimit.c \
uio.c umask.c umount.c umount2.c umoven-illptr.c umovestr.c \
umovestr-illptr.c umovestr2.c umovestr3.c umovestr_cached.c \
@@ -4667,7 +4672,7 @@
syslog-success.c tee.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
- timer_xettime.c timerfd_xettime.c times.c times-fail.c \
+ timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
tracer_ppid_pgid_sid.c truncate.c truncate64.c ugetrlimit.c \
uio.c umask.c umount.c umount2.c umoven-illptr.c umovestr.c \
umovestr-illptr.c umovestr2.c umovestr3.c umovestr_cached.c \
@@ -5725,6 +5730,7 @@
timerfd_xettime \
times \
times-fail \
+ tkill \
truncate \
truncate64 \
ugetrlimit \
@@ -6133,9 +6139,10 @@
threads-execve-qqq.gen.test time.gen.test \
timer_create.gen.test timer_xettime.gen.test \
timerfd_xettime.gen.test times.gen.test times-fail.gen.test \
- trace_clock.gen.test trace_creds.gen.test trace_fstat.gen.test \
- trace_fstatfs.gen.test trace_lstat.gen.test \
- trace_personality_32.gen.test trace_personality_64.gen.test \
+ tkill.gen.test trace_clock.gen.test trace_creds.gen.test \
+ trace_fstat.gen.test trace_fstatfs.gen.test \
+ trace_lstat.gen.test trace_personality_32.gen.test \
+ trace_personality_64.gen.test \
trace_personality_regex_32.gen.test \
trace_personality_regex_64.gen.test \
trace_personality_regex_x32.gen.test \
@@ -9392,6 +9399,10 @@
@rm -f times-fail$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(times_fail_OBJECTS) $(times_fail_LDADD) $(LIBS)
+tkill$(EXEEXT): $(tkill_OBJECTS) $(tkill_DEPENDENCIES) $(EXTRA_tkill_DEPENDENCIES)
+ @rm -f tkill$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tkill_OBJECTS) $(tkill_LDADD) $(LIBS)
+
tracer_ppid_pgid_sid$(EXEEXT): $(tracer_ppid_pgid_sid_OBJECTS) $(tracer_ppid_pgid_sid_DEPENDENCIES) $(EXTRA_tracer_ppid_pgid_sid_DEPENDENCIES)
@rm -f tracer_ppid_pgid_sid$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tracer_ppid_pgid_sid_OBJECTS) $(tracer_ppid_pgid_sid_LDADD) $(LIBS)
@@ -10349,6 +10360,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timerfd_xettime.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times-fail.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tkill.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracer_ppid_pgid_sid.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/truncate.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/truncate64-truncate64.Po@am__quote@ # am--include-marker
@@ -12169,6 +12181,7 @@
-rm -f ./$(DEPDIR)/timerfd_xettime.Po
-rm -f ./$(DEPDIR)/times-fail.Po
-rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tkill.Po
-rm -f ./$(DEPDIR)/tracer_ppid_pgid_sid.Po
-rm -f ./$(DEPDIR)/truncate.Po
-rm -f ./$(DEPDIR)/truncate64-truncate64.Po
@@ -13024,6 +13037,7 @@
-rm -f ./$(DEPDIR)/timerfd_xettime.Po
-rm -f ./$(DEPDIR)/times-fail.Po
-rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tkill.Po
-rm -f ./$(DEPDIR)/tracer_ppid_pgid_sid.Po
-rm -f ./$(DEPDIR)/truncate.Po
-rm -f ./$(DEPDIR)/truncate64-truncate64.Po
@@ -15101,6 +15115,9 @@
$(srcdir)/times-fail.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
+$(srcdir)/tkill.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
+ $(AM_V_GEN) $^ $@
+
$(srcdir)/trace_clock.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
Index: strace-5.7/tests-mx32/Makefile.in
===================================================================
--- strace-5.7.orig/tests-mx32/Makefile.in 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests-mx32/Makefile.in 2020-09-09 19:32:39.854958946 +0200
@@ -496,14 +496,15 @@
sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) time$(EXEEXT) \
timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
timerfd_xettime$(EXEEXT) times$(EXEEXT) times-fail$(EXEEXT) \
- truncate$(EXEEXT) truncate64$(EXEEXT) ugetrlimit$(EXEEXT) \
- uio$(EXEEXT) umask$(EXEEXT) umount$(EXEEXT) umount2$(EXEEXT) \
- umoven-illptr$(EXEEXT) umovestr$(EXEEXT) \
- umovestr-illptr$(EXEEXT) umovestr2$(EXEEXT) umovestr3$(EXEEXT) \
- umovestr_cached$(EXEEXT) umovestr_cached_adjacent$(EXEEXT) \
- uname$(EXEEXT) unlink$(EXEEXT) unlinkat$(EXEEXT) \
- unshare$(EXEEXT) userfaultfd$(EXEEXT) ustat$(EXEEXT) \
- utime$(EXEEXT) utimensat$(EXEEXT) utimensat-Xabbrev$(EXEEXT) \
+ tkill$(EXEEXT) truncate$(EXEEXT) truncate64$(EXEEXT) \
+ ugetrlimit$(EXEEXT) uio$(EXEEXT) umask$(EXEEXT) \
+ umount$(EXEEXT) umount2$(EXEEXT) umoven-illptr$(EXEEXT) \
+ umovestr$(EXEEXT) umovestr-illptr$(EXEEXT) umovestr2$(EXEEXT) \
+ umovestr3$(EXEEXT) umovestr_cached$(EXEEXT) \
+ umovestr_cached_adjacent$(EXEEXT) uname$(EXEEXT) \
+ unlink$(EXEEXT) unlinkat$(EXEEXT) unshare$(EXEEXT) \
+ userfaultfd$(EXEEXT) ustat$(EXEEXT) utime$(EXEEXT) \
+ utimensat$(EXEEXT) utimensat-Xabbrev$(EXEEXT) \
utimensat-Xraw$(EXEEXT) utimensat-Xverbose$(EXEEXT) \
utimes$(EXEEXT) vhangup$(EXEEXT) vmsplice$(EXEEXT) \
wait4$(EXEEXT) waitid$(EXEEXT) waitpid$(EXEEXT) xattr$(EXEEXT) \
@@ -3484,6 +3485,10 @@
times_fail_OBJECTS = times-fail.$(OBJEXT)
times_fail_LDADD = $(LDADD)
times_fail_DEPENDENCIES = libtests.a
+tkill_SOURCES = tkill.c
+tkill_OBJECTS = tkill.$(OBJEXT)
+tkill_LDADD = $(LDADD)
+tkill_DEPENDENCIES = libtests.a
tracer_ppid_pgid_sid_SOURCES = tracer_ppid_pgid_sid.c
tracer_ppid_pgid_sid_OBJECTS = tracer_ppid_pgid_sid.$(OBJEXT)
tracer_ppid_pgid_sid_LDADD = $(LDADD)
@@ -4184,7 +4189,7 @@
./$(DEPDIR)/threads-execve.Po ./$(DEPDIR)/time.Po \
./$(DEPDIR)/timer_create.Po ./$(DEPDIR)/timer_xettime.Po \
./$(DEPDIR)/timerfd_xettime.Po ./$(DEPDIR)/times-fail.Po \
- ./$(DEPDIR)/times.Po ./$(DEPDIR)/tracer_ppid_pgid_sid.Po \
+ ./$(DEPDIR)/times.Po ./$(DEPDIR)/tkill.Po ./$(DEPDIR)/tracer_ppid_pgid_sid.Po \
./$(DEPDIR)/truncate.Po ./$(DEPDIR)/truncate64-truncate64.Po \
./$(DEPDIR)/ugetrlimit.Po ./$(DEPDIR)/uio-uio.Po \
./$(DEPDIR)/umask.Po ./$(DEPDIR)/umount.Po \
@@ -4441,7 +4446,7 @@
syslog-success.c tee.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
- timer_xettime.c timerfd_xettime.c times.c times-fail.c \
+ timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
tracer_ppid_pgid_sid.c truncate.c truncate64.c ugetrlimit.c \
uio.c umask.c umount.c umount2.c umoven-illptr.c umovestr.c \
umovestr-illptr.c umovestr2.c umovestr3.c umovestr_cached.c \
@@ -4667,7 +4672,7 @@
syslog-success.c tee.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
- timer_xettime.c timerfd_xettime.c times.c times-fail.c \
+ timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
tracer_ppid_pgid_sid.c truncate.c truncate64.c ugetrlimit.c \
uio.c umask.c umount.c umount2.c umoven-illptr.c umovestr.c \
umovestr-illptr.c umovestr2.c umovestr3.c umovestr_cached.c \
@@ -5725,6 +5730,7 @@
timerfd_xettime \
times \
times-fail \
+ tkill \
truncate \
truncate64 \
ugetrlimit \
@@ -6133,9 +6139,10 @@
threads-execve-qqq.gen.test time.gen.test \
timer_create.gen.test timer_xettime.gen.test \
timerfd_xettime.gen.test times.gen.test times-fail.gen.test \
- trace_clock.gen.test trace_creds.gen.test trace_fstat.gen.test \
- trace_fstatfs.gen.test trace_lstat.gen.test \
- trace_personality_32.gen.test trace_personality_64.gen.test \
+ tkill.gen.test trace_clock.gen.test trace_creds.gen.test \
+ trace_fstat.gen.test trace_fstatfs.gen.test \
+ trace_lstat.gen.test trace_personality_32.gen.test \
+ trace_personality_64.gen.test \
trace_personality_regex_32.gen.test \
trace_personality_regex_64.gen.test \
trace_personality_regex_x32.gen.test \
@@ -9392,6 +9399,10 @@
@rm -f times-fail$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(times_fail_OBJECTS) $(times_fail_LDADD) $(LIBS)
+tkill$(EXEEXT): $(tkill_OBJECTS) $(tkill_DEPENDENCIES) $(EXTRA_tkill_DEPENDENCIES)
+ @rm -f tkill$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tkill_OBJECTS) $(tkill_LDADD) $(LIBS)
+
tracer_ppid_pgid_sid$(EXEEXT): $(tracer_ppid_pgid_sid_OBJECTS) $(tracer_ppid_pgid_sid_DEPENDENCIES) $(EXTRA_tracer_ppid_pgid_sid_DEPENDENCIES)
@rm -f tracer_ppid_pgid_sid$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tracer_ppid_pgid_sid_OBJECTS) $(tracer_ppid_pgid_sid_LDADD) $(LIBS)
@@ -10349,6 +10360,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timerfd_xettime.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times-fail.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tkill.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracer_ppid_pgid_sid.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/truncate.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/truncate64-truncate64.Po@am__quote@ # am--include-marker
@@ -12169,6 +12181,7 @@
-rm -f ./$(DEPDIR)/timerfd_xettime.Po
-rm -f ./$(DEPDIR)/times-fail.Po
-rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tkill.Po
-rm -f ./$(DEPDIR)/tracer_ppid_pgid_sid.Po
-rm -f ./$(DEPDIR)/truncate.Po
-rm -f ./$(DEPDIR)/truncate64-truncate64.Po
@@ -13024,6 +13037,7 @@
-rm -f ./$(DEPDIR)/timerfd_xettime.Po
-rm -f ./$(DEPDIR)/times-fail.Po
-rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tkill.Po
-rm -f ./$(DEPDIR)/tracer_ppid_pgid_sid.Po
-rm -f ./$(DEPDIR)/truncate.Po
-rm -f ./$(DEPDIR)/truncate64-truncate64.Po
@@ -15101,6 +15115,9 @@
$(srcdir)/times-fail.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
+$(srcdir)/tkill.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
+ $(AM_V_GEN) $^ $@
+
$(srcdir)/trace_clock.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
Index: strace-5.7/tests/Makefile.in
===================================================================
--- strace-5.7.orig/tests/Makefile.in 2020-09-09 15:47:07.671767616 +0200
+++ strace-5.7/tests/Makefile.in 2020-09-09 19:30:36.780885588 +0200
@@ -496,14 +496,15 @@
sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) time$(EXEEXT) \
timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
timerfd_xettime$(EXEEXT) times$(EXEEXT) times-fail$(EXEEXT) \
- truncate$(EXEEXT) truncate64$(EXEEXT) ugetrlimit$(EXEEXT) \
- uio$(EXEEXT) umask$(EXEEXT) umount$(EXEEXT) umount2$(EXEEXT) \
- umoven-illptr$(EXEEXT) umovestr$(EXEEXT) \
- umovestr-illptr$(EXEEXT) umovestr2$(EXEEXT) umovestr3$(EXEEXT) \
- umovestr_cached$(EXEEXT) umovestr_cached_adjacent$(EXEEXT) \
- uname$(EXEEXT) unlink$(EXEEXT) unlinkat$(EXEEXT) \
- unshare$(EXEEXT) userfaultfd$(EXEEXT) ustat$(EXEEXT) \
- utime$(EXEEXT) utimensat$(EXEEXT) utimensat-Xabbrev$(EXEEXT) \
+ tkill$(EXEEXT) truncate$(EXEEXT) truncate64$(EXEEXT) \
+ ugetrlimit$(EXEEXT) uio$(EXEEXT) umask$(EXEEXT) \
+ umount$(EXEEXT) umount2$(EXEEXT) umoven-illptr$(EXEEXT) \
+ umovestr$(EXEEXT) umovestr-illptr$(EXEEXT) umovestr2$(EXEEXT) \
+ umovestr3$(EXEEXT) umovestr_cached$(EXEEXT) \
+ umovestr_cached_adjacent$(EXEEXT) uname$(EXEEXT) \
+ unlink$(EXEEXT) unlinkat$(EXEEXT) unshare$(EXEEXT) \
+ userfaultfd$(EXEEXT) ustat$(EXEEXT) utime$(EXEEXT) \
+ utimensat$(EXEEXT) utimensat-Xabbrev$(EXEEXT) \
utimensat-Xraw$(EXEEXT) utimensat-Xverbose$(EXEEXT) \
utimes$(EXEEXT) vhangup$(EXEEXT) vmsplice$(EXEEXT) \
wait4$(EXEEXT) waitid$(EXEEXT) waitpid$(EXEEXT) xattr$(EXEEXT) \
@@ -3484,6 +3485,10 @@
times_fail_OBJECTS = times-fail.$(OBJEXT)
times_fail_LDADD = $(LDADD)
times_fail_DEPENDENCIES = libtests.a
+tkill_SOURCES = tkill.c
+tkill_OBJECTS = tkill.$(OBJEXT)
+tkill_LDADD = $(LDADD)
+tkill_DEPENDENCIES = libtests.a
tracer_ppid_pgid_sid_SOURCES = tracer_ppid_pgid_sid.c
tracer_ppid_pgid_sid_OBJECTS = tracer_ppid_pgid_sid.$(OBJEXT)
tracer_ppid_pgid_sid_LDADD = $(LDADD)
@@ -4184,7 +4189,7 @@
./$(DEPDIR)/threads-execve.Po ./$(DEPDIR)/time.Po \
./$(DEPDIR)/timer_create.Po ./$(DEPDIR)/timer_xettime.Po \
./$(DEPDIR)/timerfd_xettime.Po ./$(DEPDIR)/times-fail.Po \
- ./$(DEPDIR)/times.Po ./$(DEPDIR)/tracer_ppid_pgid_sid.Po \
+ ./$(DEPDIR)/times.Po ./$(DEPDIR)/tkill.Po ./$(DEPDIR)/tracer_ppid_pgid_sid.Po \
./$(DEPDIR)/truncate.Po ./$(DEPDIR)/truncate64-truncate64.Po \
./$(DEPDIR)/ugetrlimit.Po ./$(DEPDIR)/uio-uio.Po \
./$(DEPDIR)/umask.Po ./$(DEPDIR)/umount.Po \
@@ -4441,7 +4446,7 @@
syslog-success.c tee.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
- timer_xettime.c timerfd_xettime.c times.c times-fail.c \
+ timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
tracer_ppid_pgid_sid.c truncate.c truncate64.c ugetrlimit.c \
uio.c umask.c umount.c umount2.c umoven-illptr.c umovestr.c \
umovestr-illptr.c umovestr2.c umovestr3.c umovestr_cached.c \
@@ -4667,7 +4672,7 @@
syslog-success.c tee.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
- timer_xettime.c timerfd_xettime.c times.c times-fail.c \
+ timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
tracer_ppid_pgid_sid.c truncate.c truncate64.c ugetrlimit.c \
uio.c umask.c umount.c umount2.c umoven-illptr.c umovestr.c \
umovestr-illptr.c umovestr2.c umovestr3.c umovestr_cached.c \
@@ -5725,6 +5730,7 @@
timerfd_xettime \
times \
times-fail \
+ tkill \
truncate \
truncate64 \
ugetrlimit \
@@ -6133,9 +6139,10 @@
threads-execve-qqq.gen.test time.gen.test \
timer_create.gen.test timer_xettime.gen.test \
timerfd_xettime.gen.test times.gen.test times-fail.gen.test \
- trace_clock.gen.test trace_creds.gen.test trace_fstat.gen.test \
- trace_fstatfs.gen.test trace_lstat.gen.test \
- trace_personality_32.gen.test trace_personality_64.gen.test \
+ tkill.gen.test trace_clock.gen.test trace_creds.gen.test \
+ trace_fstat.gen.test trace_fstatfs.gen.test \
+ trace_lstat.gen.test trace_personality_32.gen.test \
+ trace_personality_64.gen.test \
trace_personality_regex_32.gen.test \
trace_personality_regex_64.gen.test \
trace_personality_regex_x32.gen.test \
@@ -9392,6 +9399,10 @@
@rm -f times-fail$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(times_fail_OBJECTS) $(times_fail_LDADD) $(LIBS)
+tkill$(EXEEXT): $(tkill_OBJECTS) $(tkill_DEPENDENCIES) $(EXTRA_tkill_DEPENDENCIES)
+ @rm -f tkill$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tkill_OBJECTS) $(tkill_LDADD) $(LIBS)
+
tracer_ppid_pgid_sid$(EXEEXT): $(tracer_ppid_pgid_sid_OBJECTS) $(tracer_ppid_pgid_sid_DEPENDENCIES) $(EXTRA_tracer_ppid_pgid_sid_DEPENDENCIES)
@rm -f tracer_ppid_pgid_sid$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tracer_ppid_pgid_sid_OBJECTS) $(tracer_ppid_pgid_sid_LDADD) $(LIBS)
@@ -10349,6 +10360,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timerfd_xettime.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times-fail.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tkill.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracer_ppid_pgid_sid.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/truncate.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/truncate64-truncate64.Po@am__quote@ # am--include-marker
@@ -12169,6 +12181,7 @@
-rm -f ./$(DEPDIR)/timerfd_xettime.Po
-rm -f ./$(DEPDIR)/times-fail.Po
-rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tkill.Po
-rm -f ./$(DEPDIR)/tracer_ppid_pgid_sid.Po
-rm -f ./$(DEPDIR)/truncate.Po
-rm -f ./$(DEPDIR)/truncate64-truncate64.Po
@@ -13024,6 +13037,7 @@
-rm -f ./$(DEPDIR)/timerfd_xettime.Po
-rm -f ./$(DEPDIR)/times-fail.Po
-rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tkill.Po
-rm -f ./$(DEPDIR)/tracer_ppid_pgid_sid.Po
-rm -f ./$(DEPDIR)/truncate.Po
-rm -f ./$(DEPDIR)/truncate64-truncate64.Po
@@ -15101,6 +15115,9 @@
$(srcdir)/times-fail.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
+$(srcdir)/tkill.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
+ $(AM_V_GEN) $^ $@
+
$(srcdir)/trace_clock.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@

View File

@ -1,656 +0,0 @@
From 9d4d64f6fdfcae908aec455888e92a69c9c81c64 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 1 Aug 2020 08:00:00 +0000
Subject: [PATCH 133/138] tests: check decoding of tgkill syscall
* tests/tgkill.c: New file.
* tests/gen_tests.in (tgkill): New entry.
* tests/pure_executables.list: Add tgkill.
* tests/.gitignore: Likewise.
---
tests/.gitignore | 1 +
tests/gen_tests.in | 1 +
tests/pure_executables.list | 1 +
tests/tgkill.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 72 insertions(+)
create mode 100644 tests/tgkill.c
Index: strace-5.7/tests/gen_tests.in
===================================================================
--- strace-5.7.orig/tests/gen_tests.in 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests/gen_tests.in 2020-09-09 19:32:50.740965435 +0200
@@ -658,6 +658,7 @@
sysinfo -a14
syslog -a35
tee
+tgkill -a15 --signal='!cont'
threads-execve--quiet-thread-execve +threads-execve.test -s40 --quiet=personality,thread-execve
threads-execve-q +threads-execve.test -q
threads-execve-qq +threads-execve.test -qq
Index: strace-5.7/tests/pure_executables.list
===================================================================
--- strace-5.7.orig/tests/pure_executables.list 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests/pure_executables.list 2020-09-09 19:32:45.308962197 +0200
@@ -583,6 +583,7 @@
sysinfo
syslog
tee
+tgkill
time
timer_create
timer_xettime
Index: strace-5.7/tests/tgkill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests/tgkill.c 2020-09-09 19:32:50.740965435 +0200
@@ -0,0 +1,69 @@
+/*
+ * Check decoding of tgkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tgkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tgkill(const unsigned int tgid,
+ const unsigned int tid,
+ const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tgid;
+ const kernel_ulong_t arg2 = fill | tid;
+ const kernel_ulong_t arg3 = fill | sig;
+ const long rc = syscall(__NR_tgkill, arg1, arg2, arg3, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tgkill(pid, pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", pid, pid, errstr);
+
+ k_tgkill(pid, bad_pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", pid, bad_pid, errstr);
+
+ k_tgkill(bad_pid, pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", bad_pid, pid, errstr);
+
+ k_tgkill(pid, pid, SIGCONT);
+ printf("tgkill(%d, %d, SIGCONT) = %s\n", pid, pid, errstr);
+
+ k_tgkill(pid, pid, bad_sig);
+ printf("tgkill(%d, %d, %d) = %s\n", pid, pid, bad_sig, errstr);
+
+ k_tgkill(pid, pid, -bad_sig);
+ printf("tgkill(%d, %d, %d) = %s\n", pid, pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tgkill")
+
+#endif
Index: strace-5.7/tests-m32/gen_tests.in
===================================================================
--- strace-5.7.orig/tests-m32/gen_tests.in 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests-m32/gen_tests.in 2020-09-09 19:32:50.740965435 +0200
@@ -658,6 +658,7 @@
sysinfo -a14
syslog -a35
tee
+tgkill -a15 --signal='!cont'
threads-execve--quiet-thread-execve +threads-execve.test -s40 --quiet=personality,thread-execve
threads-execve-q +threads-execve.test -q
threads-execve-qq +threads-execve.test -qq
Index: strace-5.7/tests-m32/pure_executables.list
===================================================================
--- strace-5.7.orig/tests-m32/pure_executables.list 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests-m32/pure_executables.list 2020-09-09 19:32:45.309962197 +0200
@@ -583,6 +583,7 @@
sysinfo
syslog
tee
+tgkill
time
timer_create
timer_xettime
Index: strace-5.7/tests-m32/tgkill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-m32/tgkill.c 2020-09-09 19:32:50.740965435 +0200
@@ -0,0 +1,69 @@
+/*
+ * Check decoding of tgkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tgkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tgkill(const unsigned int tgid,
+ const unsigned int tid,
+ const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tgid;
+ const kernel_ulong_t arg2 = fill | tid;
+ const kernel_ulong_t arg3 = fill | sig;
+ const long rc = syscall(__NR_tgkill, arg1, arg2, arg3, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tgkill(pid, pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", pid, pid, errstr);
+
+ k_tgkill(pid, bad_pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", pid, bad_pid, errstr);
+
+ k_tgkill(bad_pid, pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", bad_pid, pid, errstr);
+
+ k_tgkill(pid, pid, SIGCONT);
+ printf("tgkill(%d, %d, SIGCONT) = %s\n", pid, pid, errstr);
+
+ k_tgkill(pid, pid, bad_sig);
+ printf("tgkill(%d, %d, %d) = %s\n", pid, pid, bad_sig, errstr);
+
+ k_tgkill(pid, pid, -bad_sig);
+ printf("tgkill(%d, %d, %d) = %s\n", pid, pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tgkill")
+
+#endif
Index: strace-5.7/tests-mx32/gen_tests.in
===================================================================
--- strace-5.7.orig/tests-mx32/gen_tests.in 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests-mx32/gen_tests.in 2020-09-09 19:32:50.740965435 +0200
@@ -658,6 +658,7 @@
sysinfo -a14
syslog -a35
tee
+tgkill -a15 --signal='!cont'
threads-execve--quiet-thread-execve +threads-execve.test -s40 --quiet=personality,thread-execve
threads-execve-q +threads-execve.test -q
threads-execve-qq +threads-execve.test -qq
Index: strace-5.7/tests-mx32/pure_executables.list
===================================================================
--- strace-5.7.orig/tests-mx32/pure_executables.list 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests-mx32/pure_executables.list 2020-09-09 19:32:45.310962198 +0200
@@ -583,6 +583,7 @@
sysinfo
syslog
tee
+tgkill
time
timer_create
timer_xettime
Index: strace-5.7/tests-mx32/tgkill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-mx32/tgkill.c 2020-09-09 19:32:50.740965435 +0200
@@ -0,0 +1,69 @@
+/*
+ * Check decoding of tgkill syscall.
+ *
+ * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include "scno.h"
+
+#ifdef __NR_tgkill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_tgkill(const unsigned int tgid,
+ const unsigned int tid,
+ const unsigned int sig)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+ const kernel_ulong_t arg1 = fill | tgid;
+ const kernel_ulong_t arg2 = fill | tid;
+ const kernel_ulong_t arg3 = fill | sig;
+ const long rc = syscall(__NR_tgkill, arg1, arg2, arg3, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
+int
+main(void)
+{
+ const int pid = getpid();
+ const int bad_pid = -1;
+ const int bad_sig = 0xface;
+
+ k_tgkill(pid, pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", pid, pid, errstr);
+
+ k_tgkill(pid, bad_pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", pid, bad_pid, errstr);
+
+ k_tgkill(bad_pid, pid, 0);
+ printf("tgkill(%d, %d, 0) = %s\n", bad_pid, pid, errstr);
+
+ k_tgkill(pid, pid, SIGCONT);
+ printf("tgkill(%d, %d, SIGCONT) = %s\n", pid, pid, errstr);
+
+ k_tgkill(pid, pid, bad_sig);
+ printf("tgkill(%d, %d, %d) = %s\n", pid, pid, bad_sig, errstr);
+
+ k_tgkill(pid, pid, -bad_sig);
+ printf("tgkill(%d, %d, %d) = %s\n", pid, pid, -bad_sig, errstr);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_tgkill")
+
+#endif
Index: strace-5.7/tests-m32/Makefile.in
===================================================================
--- strace-5.7.orig/tests-m32/Makefile.in 2020-09-09 19:32:14.800944013 +0200
+++ strace-5.7/tests-m32/Makefile.in 2020-09-09 19:49:34.530563739 +0200
@@ -493,8 +493,8 @@
strace-xx$(EXEEXT) swap$(EXEEXT) sxetmask$(EXEEXT) \
symlink$(EXEEXT) symlinkat$(EXEEXT) sync$(EXEEXT) \
sync_file_range$(EXEEXT) sync_file_range2$(EXEEXT) \
- sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) time$(EXEEXT) \
- timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
+ sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) tgkill$(EXEEXT) \
+ time$(EXEEXT) timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
timerfd_xettime$(EXEEXT) times$(EXEEXT) times-fail$(EXEEXT) \
tkill$(EXEEXT) truncate$(EXEEXT) truncate64$(EXEEXT) \
ugetrlimit$(EXEEXT) uio$(EXEEXT) umask$(EXEEXT) \
@@ -3444,6 +3444,10 @@
tee_OBJECTS = tee.$(OBJEXT)
tee_LDADD = $(LDADD)
tee_DEPENDENCIES = libtests.a
+tgkill_SOURCES = tgkill.c
+tgkill_OBJECTS = tgkill.$(OBJEXT)
+tgkill_LDADD = $(LDADD)
+tgkill_DEPENDENCIES = libtests.a
threads_execve_SOURCES = threads-execve.c
threads_execve_OBJECTS = threads-execve.$(OBJEXT)
threads_execve_DEPENDENCIES = $(am__DEPENDENCIES_1) $(LDADD)
@@ -4181,7 +4185,7 @@
./$(DEPDIR)/symlinkat.Po ./$(DEPDIR)/sync.Po \
./$(DEPDIR)/sync_file_range.Po ./$(DEPDIR)/sync_file_range2.Po \
./$(DEPDIR)/sysinfo.Po ./$(DEPDIR)/syslog-success.Po \
- ./$(DEPDIR)/syslog.Po ./$(DEPDIR)/tee.Po \
+ ./$(DEPDIR)/syslog.Po ./$(DEPDIR)/tee.Po ./$(DEPDIR)/tgkill.Po \
./$(DEPDIR)/threads-execve--quiet-thread-execve.Po \
./$(DEPDIR)/threads-execve-q.Po \
./$(DEPDIR)/threads-execve-qq.Po \
@@ -4443,7 +4447,7 @@
strace--strings-in-hex-non-ascii.c strace-x.c strace-xx.c \
swap.c sxetmask.c symlink.c symlinkat.c sync.c \
sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
- syslog-success.c tee.c threads-execve.c \
+ syslog-success.c tee.c tgkill.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
@@ -4669,7 +4673,7 @@
strace--strings-in-hex-non-ascii.c strace-x.c strace-xx.c \
swap.c sxetmask.c symlink.c symlinkat.c sync.c \
sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
- syslog-success.c tee.c threads-execve.c \
+ syslog-success.c tee.c tgkill.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
@@ -5724,6 +5728,7 @@
sysinfo \
syslog \
tee \
+ tgkill \
time \
timer_create \
timer_xettime \
@@ -6133,7 +6138,7 @@
strace-xx.gen.test swap.gen.test sxetmask.gen.test \
symlink.gen.test symlinkat.gen.test sync.gen.test \
sync_file_range.gen.test sync_file_range2.gen.test \
- sysinfo.gen.test syslog.gen.test tee.gen.test \
+ sysinfo.gen.test syslog.gen.test tee.gen.test tgkill.gen.test \
threads-execve--quiet-thread-execve.gen.test \
threads-execve-q.gen.test threads-execve-qq.gen.test \
threads-execve-qqq.gen.test time.gen.test \
@@ -9355,6 +9360,10 @@
@rm -f tee$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tee_OBJECTS) $(tee_LDADD) $(LIBS)
+tgkill$(EXEEXT): $(tgkill_OBJECTS) $(tgkill_DEPENDENCIES) $(EXTRA_tgkill_DEPENDENCIES)
+ @rm -f tgkill$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tgkill_OBJECTS) $(tgkill_LDADD) $(LIBS)
+
threads-execve$(EXEEXT): $(threads_execve_OBJECTS) $(threads_execve_DEPENDENCIES) $(EXTRA_threads_execve_DEPENDENCIES)
@rm -f threads-execve$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(threads_execve_OBJECTS) $(threads_execve_LDADD) $(LIBS)
@@ -10349,6 +10358,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslog-success.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslog.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tee.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tgkill.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve--quiet-thread-execve.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve-q.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve-qq.Po@am__quote@ # am--include-marker
@@ -12170,6 +12180,7 @@
-rm -f ./$(DEPDIR)/syslog-success.Po
-rm -f ./$(DEPDIR)/syslog.Po
-rm -f ./$(DEPDIR)/tee.Po
+ -rm -f ./$(DEPDIR)/tgkill.Po
-rm -f ./$(DEPDIR)/threads-execve--quiet-thread-execve.Po
-rm -f ./$(DEPDIR)/threads-execve-q.Po
-rm -f ./$(DEPDIR)/threads-execve-qq.Po
@@ -13026,6 +13037,7 @@
-rm -f ./$(DEPDIR)/syslog-success.Po
-rm -f ./$(DEPDIR)/syslog.Po
-rm -f ./$(DEPDIR)/tee.Po
+ -rm -f ./$(DEPDIR)/tgkill.Po
-rm -f ./$(DEPDIR)/threads-execve--quiet-thread-execve.Po
-rm -f ./$(DEPDIR)/threads-execve-q.Po
-rm -f ./$(DEPDIR)/threads-execve-qq.Po
@@ -15085,6 +15097,9 @@
$(srcdir)/tee.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
+$(srcdir)/tgkill.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
+ $(AM_V_GEN) $^ $@
+
$(srcdir)/threads-execve--quiet-thread-execve.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
Index: strace-5.7/tests-mx32/Makefile.in
===================================================================
--- strace-5.7.orig/tests-mx32/Makefile.in 2020-09-09 19:32:39.854958946 +0200
+++ strace-5.7/tests-mx32/Makefile.in 2020-09-09 19:49:39.557566736 +0200
@@ -493,8 +493,8 @@
strace-xx$(EXEEXT) swap$(EXEEXT) sxetmask$(EXEEXT) \
symlink$(EXEEXT) symlinkat$(EXEEXT) sync$(EXEEXT) \
sync_file_range$(EXEEXT) sync_file_range2$(EXEEXT) \
- sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) time$(EXEEXT) \
- timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
+ sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) tgkill$(EXEEXT) \
+ time$(EXEEXT) timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
timerfd_xettime$(EXEEXT) times$(EXEEXT) times-fail$(EXEEXT) \
tkill$(EXEEXT) truncate$(EXEEXT) truncate64$(EXEEXT) \
ugetrlimit$(EXEEXT) uio$(EXEEXT) umask$(EXEEXT) \
@@ -3444,6 +3444,10 @@
tee_OBJECTS = tee.$(OBJEXT)
tee_LDADD = $(LDADD)
tee_DEPENDENCIES = libtests.a
+tgkill_SOURCES = tgkill.c
+tgkill_OBJECTS = tgkill.$(OBJEXT)
+tgkill_LDADD = $(LDADD)
+tgkill_DEPENDENCIES = libtests.a
threads_execve_SOURCES = threads-execve.c
threads_execve_OBJECTS = threads-execve.$(OBJEXT)
threads_execve_DEPENDENCIES = $(am__DEPENDENCIES_1) $(LDADD)
@@ -4181,7 +4185,7 @@
./$(DEPDIR)/symlinkat.Po ./$(DEPDIR)/sync.Po \
./$(DEPDIR)/sync_file_range.Po ./$(DEPDIR)/sync_file_range2.Po \
./$(DEPDIR)/sysinfo.Po ./$(DEPDIR)/syslog-success.Po \
- ./$(DEPDIR)/syslog.Po ./$(DEPDIR)/tee.Po \
+ ./$(DEPDIR)/syslog.Po ./$(DEPDIR)/tee.Po ./$(DEPDIR)/tgkill.Po \
./$(DEPDIR)/threads-execve--quiet-thread-execve.Po \
./$(DEPDIR)/threads-execve-q.Po \
./$(DEPDIR)/threads-execve-qq.Po \
@@ -4443,7 +4447,7 @@
strace--strings-in-hex-non-ascii.c strace-x.c strace-xx.c \
swap.c sxetmask.c symlink.c symlinkat.c sync.c \
sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
- syslog-success.c tee.c threads-execve.c \
+ syslog-success.c tee.c tgkill.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
@@ -4669,7 +4673,7 @@
strace--strings-in-hex-non-ascii.c strace-x.c strace-xx.c \
swap.c sxetmask.c symlink.c symlinkat.c sync.c \
sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
- syslog-success.c tee.c threads-execve.c \
+ syslog-success.c tee.c tgkill.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
@@ -5724,6 +5728,7 @@
sysinfo \
syslog \
tee \
+ tgkill \
time \
timer_create \
timer_xettime \
@@ -6133,7 +6138,7 @@
strace-xx.gen.test swap.gen.test sxetmask.gen.test \
symlink.gen.test symlinkat.gen.test sync.gen.test \
sync_file_range.gen.test sync_file_range2.gen.test \
- sysinfo.gen.test syslog.gen.test tee.gen.test \
+ sysinfo.gen.test syslog.gen.test tee.gen.test tgkill.gen.test \
threads-execve--quiet-thread-execve.gen.test \
threads-execve-q.gen.test threads-execve-qq.gen.test \
threads-execve-qqq.gen.test time.gen.test \
@@ -9355,6 +9360,10 @@
@rm -f tee$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tee_OBJECTS) $(tee_LDADD) $(LIBS)
+tgkill$(EXEEXT): $(tgkill_OBJECTS) $(tgkill_DEPENDENCIES) $(EXTRA_tgkill_DEPENDENCIES)
+ @rm -f tgkill$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tgkill_OBJECTS) $(tgkill_LDADD) $(LIBS)
+
threads-execve$(EXEEXT): $(threads_execve_OBJECTS) $(threads_execve_DEPENDENCIES) $(EXTRA_threads_execve_DEPENDENCIES)
@rm -f threads-execve$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(threads_execve_OBJECTS) $(threads_execve_LDADD) $(LIBS)
@@ -10349,6 +10358,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslog-success.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslog.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tee.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tgkill.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve--quiet-thread-execve.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve-q.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve-qq.Po@am__quote@ # am--include-marker
@@ -12170,6 +12180,7 @@
-rm -f ./$(DEPDIR)/syslog-success.Po
-rm -f ./$(DEPDIR)/syslog.Po
-rm -f ./$(DEPDIR)/tee.Po
+ -rm -f ./$(DEPDIR)/tgkill.Po
-rm -f ./$(DEPDIR)/threads-execve--quiet-thread-execve.Po
-rm -f ./$(DEPDIR)/threads-execve-q.Po
-rm -f ./$(DEPDIR)/threads-execve-qq.Po
@@ -13026,6 +13037,7 @@
-rm -f ./$(DEPDIR)/syslog-success.Po
-rm -f ./$(DEPDIR)/syslog.Po
-rm -f ./$(DEPDIR)/tee.Po
+ -rm -f ./$(DEPDIR)/tgkill.Po
-rm -f ./$(DEPDIR)/threads-execve--quiet-thread-execve.Po
-rm -f ./$(DEPDIR)/threads-execve-q.Po
-rm -f ./$(DEPDIR)/threads-execve-qq.Po
@@ -15085,6 +15097,9 @@
$(srcdir)/tee.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
+$(srcdir)/tgkill.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
+ $(AM_V_GEN) $^ $@
+
$(srcdir)/threads-execve--quiet-thread-execve.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
Index: strace-5.7/tests/Makefile.in
===================================================================
--- strace-5.7.orig/tests/Makefile.in 2020-09-09 19:30:36.780885588 +0200
+++ strace-5.7/tests/Makefile.in 2020-09-09 19:46:24.904450714 +0200
@@ -493,8 +493,8 @@
strace-xx$(EXEEXT) swap$(EXEEXT) sxetmask$(EXEEXT) \
symlink$(EXEEXT) symlinkat$(EXEEXT) sync$(EXEEXT) \
sync_file_range$(EXEEXT) sync_file_range2$(EXEEXT) \
- sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) time$(EXEEXT) \
- timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
+ sysinfo$(EXEEXT) syslog$(EXEEXT) tee$(EXEEXT) tgkill$(EXEEXT) \
+ time$(EXEEXT) timer_create$(EXEEXT) timer_xettime$(EXEEXT) \
timerfd_xettime$(EXEEXT) times$(EXEEXT) times-fail$(EXEEXT) \
tkill$(EXEEXT) truncate$(EXEEXT) truncate64$(EXEEXT) \
ugetrlimit$(EXEEXT) uio$(EXEEXT) umask$(EXEEXT) \
@@ -3444,6 +3444,10 @@
tee_OBJECTS = tee.$(OBJEXT)
tee_LDADD = $(LDADD)
tee_DEPENDENCIES = libtests.a
+tgkill_SOURCES = tgkill.c
+tgkill_OBJECTS = tgkill.$(OBJEXT)
+tgkill_LDADD = $(LDADD)
+tgkill_DEPENDENCIES = libtests.a
threads_execve_SOURCES = threads-execve.c
threads_execve_OBJECTS = threads-execve.$(OBJEXT)
threads_execve_DEPENDENCIES = $(am__DEPENDENCIES_1) $(LDADD)
@@ -4181,7 +4185,7 @@
./$(DEPDIR)/symlinkat.Po ./$(DEPDIR)/sync.Po \
./$(DEPDIR)/sync_file_range.Po ./$(DEPDIR)/sync_file_range2.Po \
./$(DEPDIR)/sysinfo.Po ./$(DEPDIR)/syslog-success.Po \
- ./$(DEPDIR)/syslog.Po ./$(DEPDIR)/tee.Po \
+ ./$(DEPDIR)/syslog.Po ./$(DEPDIR)/tee.Po ./$(DEPDIR)/tgkill.Po \
./$(DEPDIR)/threads-execve--quiet-thread-execve.Po \
./$(DEPDIR)/threads-execve-q.Po \
./$(DEPDIR)/threads-execve-qq.Po \
@@ -4443,7 +4447,7 @@
strace--strings-in-hex-non-ascii.c strace-x.c strace-xx.c \
swap.c sxetmask.c symlink.c symlinkat.c sync.c \
sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
- syslog-success.c tee.c threads-execve.c \
+ syslog-success.c tee.c tgkill.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
@@ -4669,7 +4673,7 @@
strace--strings-in-hex-non-ascii.c strace-x.c strace-xx.c \
swap.c sxetmask.c symlink.c symlinkat.c sync.c \
sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
- syslog-success.c tee.c threads-execve.c \
+ syslog-success.c tee.c tgkill.c threads-execve.c \
threads-execve--quiet-thread-execve.c threads-execve-q.c \
threads-execve-qq.c threads-execve-qqq.c time.c timer_create.c \
timer_xettime.c timerfd_xettime.c times.c times-fail.c tkill.c \
@@ -5724,6 +5728,7 @@
sysinfo \
syslog \
tee \
+ tgkill \
time \
timer_create \
timer_xettime \
@@ -6133,7 +6138,7 @@
strace-xx.gen.test swap.gen.test sxetmask.gen.test \
symlink.gen.test symlinkat.gen.test sync.gen.test \
sync_file_range.gen.test sync_file_range2.gen.test \
- sysinfo.gen.test syslog.gen.test tee.gen.test \
+ sysinfo.gen.test syslog.gen.test tee.gen.test tgkill.gen.test \
threads-execve--quiet-thread-execve.gen.test \
threads-execve-q.gen.test threads-execve-qq.gen.test \
threads-execve-qqq.gen.test time.gen.test \
@@ -9355,6 +9360,10 @@
@rm -f tee$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tee_OBJECTS) $(tee_LDADD) $(LIBS)
+tgkill$(EXEEXT): $(tgkill_OBJECTS) $(tgkill_DEPENDENCIES) $(EXTRA_tgkill_DEPENDENCIES)
+ @rm -f tgkill$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tgkill_OBJECTS) $(tgkill_LDADD) $(LIBS)
+
threads-execve$(EXEEXT): $(threads_execve_OBJECTS) $(threads_execve_DEPENDENCIES) $(EXTRA_threads_execve_DEPENDENCIES)
@rm -f threads-execve$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(threads_execve_OBJECTS) $(threads_execve_LDADD) $(LIBS)
@@ -10349,6 +10358,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslog-success.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syslog.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tee.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tgkill.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve--quiet-thread-execve.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve-q.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threads-execve-qq.Po@am__quote@ # am--include-marker
@@ -12170,6 +12180,7 @@
-rm -f ./$(DEPDIR)/syslog-success.Po
-rm -f ./$(DEPDIR)/syslog.Po
-rm -f ./$(DEPDIR)/tee.Po
+ -rm -f ./$(DEPDIR)/tgkill.Po
-rm -f ./$(DEPDIR)/threads-execve--quiet-thread-execve.Po
-rm -f ./$(DEPDIR)/threads-execve-q.Po
-rm -f ./$(DEPDIR)/threads-execve-qq.Po
@@ -13026,6 +13037,7 @@
-rm -f ./$(DEPDIR)/syslog-success.Po
-rm -f ./$(DEPDIR)/syslog.Po
-rm -f ./$(DEPDIR)/tee.Po
+ -rm -f ./$(DEPDIR)/tgkill.Po
-rm -f ./$(DEPDIR)/threads-execve--quiet-thread-execve.Po
-rm -f ./$(DEPDIR)/threads-execve-q.Po
-rm -f ./$(DEPDIR)/threads-execve-qq.Po
@@ -15085,6 +15097,9 @@
$(srcdir)/tee.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@
+$(srcdir)/tgkill.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
+ $(AM_V_GEN) $^ $@
+
$(srcdir)/threads-execve--quiet-thread-execve.gen.test: $(abs_srcdir)/gen_tests.sh $(srcdir)/gen_tests.in
$(AM_V_GEN) $^ $@

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +0,0 @@
From bba566504901b2c07885ecf325829875a96381a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
Date: Tue, 30 Jun 2020 17:20:12 +0200
Subject: [PATCH 136/138] Use get_proc_pid for /proc paths
* mmap_cache.c (mmap_cache_rebuild_if_invalid): Use proc pid instead of
tcp->pid for /proc path.
* util.c (getfdproto): Likewise.
(pidfd_get_pid): Likewise.
* pathtrace.c (getfdpath_pid): Likewise.
* strace.c (attach_tcb): Likewise.
---
mmap_cache.c | 2 +-
pathtrace.c | 7 ++++++-
strace.c | 2 +-
util.c | 9 +++++++--
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/mmap_cache.c b/mmap_cache.c
index 89c6225..9825df2 100644
--- a/mmap_cache.c
+++ b/mmap_cache.c
@@ -84,7 +84,7 @@ mmap_cache_rebuild_if_invalid(struct tcb *tcp, const char *caller)
return MMAP_CACHE_REBUILD_READY;
char filename[sizeof("/proc/4294967296/maps")];
- xsprintf(filename, "/proc/%u/maps", tcp->pid);
+ xsprintf(filename, "/proc/%u/maps", get_proc_pid(tcp));
FILE *fp = fopen_stream(filename, "r");
if (!fp) {
diff --git a/pathtrace.c b/pathtrace.c
index f85cf14..87dc64b 100644
--- a/pathtrace.c
+++ b/pathtrace.c
@@ -87,7 +87,12 @@ getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize)
if (fd < 0)
return -1;
- xsprintf(linkpath, "/proc/%u/fd/%u", pid, fd);
+ int proc_pid = 0;
+ translate_pid(NULL, pid, PT_TID, &proc_pid);
+ if (!proc_pid)
+ return -1;
+
+ xsprintf(linkpath, "/proc/%u/fd/%u", proc_pid, fd);
n = readlink(linkpath, buf, bufsize - 1);
/*
* NB: if buf is too small, readlink doesn't fail,
diff --git a/strace.c b/strace.c
index 249533e..ef23f08 100644
--- a/strace.c
+++ b/strace.c
@@ -1196,7 +1196,7 @@ attach_tcb(struct tcb *const tcp)
unsigned int ntid = 0, nerr = 0;
if (followfork && tcp->pid != strace_child &&
- xsprintf(procdir, task_path, tcp->pid) > 0 &&
+ xsprintf(procdir, task_path, get_proc_pid(tcp)) > 0 &&
(dir = opendir(procdir)) != NULL) {
struct_dirent *de;
diff --git a/util.c b/util.c
index 2568021..481144b 100644
--- a/util.c
+++ b/util.c
@@ -501,7 +501,7 @@ getfdproto(struct tcb *tcp, int fd)
if (fd < 0)
return SOCK_PROTO_UNKNOWN;
- xsprintf(path, "/proc/%u/fd/%u", tcp->pid, fd);
+ xsprintf(path, "/proc/%u/fd/%u", get_proc_pid(tcp), fd);
r = getxattr(path, "system.sockprotoname", buf, bufsize - 1);
if (r <= 0)
return SOCK_PROTO_UNKNOWN;
@@ -582,8 +582,13 @@ printdev(struct tcb *tcp, int fd, const char *path)
pid_t
pidfd_get_pid(pid_t pid_of_fd, int fd)
{
+ int proc_pid = 0;
+ translate_pid(NULL, pid_of_fd, PT_TID, &proc_pid);
+ if (!proc_pid)
+ return -1;
+
char fdi_path[sizeof("/proc/%u/fdinfo/%u") + 2 * sizeof(int) * 3];
- xsprintf(fdi_path, "/proc/%u/fdinfo/%u", pid_of_fd, fd);
+ xsprintf(fdi_path, "/proc/%u/fdinfo/%u", proc_pid, fd);
FILE *f = fopen_stream(fdi_path, "r");
if (!f)
--
2.1.4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,795 +0,0 @@
From e244ae965b17280313d92baef71165efc00ac51b Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 4 Jul 2020 08:00:00 +0000
Subject: [PATCH 144/149] tests: check decoding of faccessat syscall in -P, -y,
and -yy modes
* tests/faccessat.c: Rewrite.
* tests/faccessat-P.c: New file.
* tests/faccessat-y.c: Likewise.
* tests/faccessat-yy.c: Likewise.
* tests/faccessat.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add faccessat.test.
* tests/gen_tests.in (faccessat): Remove.
(faccessat-P, faccessat-y, faccessat-yy): New entries.
* tests/pure_executables.list: Add faccessat-P, faccessat-y,
and faccessat-yy.
* tests/.gitignore: Likewise.
---
tests/.gitignore | 3 ++
tests/Makefile.am | 1 +
tests/faccessat-P.c | 4 ++
tests/faccessat-y.c | 4 ++
tests/faccessat-yy.c | 4 ++
tests/faccessat.c | 127 ++++++++++++++++++++++++++++++++++++++++++--
tests/faccessat.test | 19 +++++++
tests/gen_tests.in | 4 +-
tests/pure_executables.list | 3 ++
9 files changed, 163 insertions(+), 6 deletions(-)
create mode 100644 tests/faccessat-P.c
create mode 100644 tests/faccessat-y.c
create mode 100644 tests/faccessat-yy.c
create mode 100755 tests/faccessat.test
Index: strace-5.7/tests/Makefile.am
===================================================================
--- strace-5.7.orig/tests/Makefile.am 2021-08-24 19:42:16.041519983 +0200
+++ strace-5.7/tests/Makefile.am 2021-08-24 19:46:08.275554370 +0200
@@ -346,6 +346,7 @@
execve-v.test \
execve.test \
fadvise64.test \
+ faccessat.test \
futex.test \
getuid.test \
int_0x80.test \
Index: strace-5.7/tests/faccessat-P.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests/faccessat-P.c 2021-08-24 19:46:08.275554370 +0200
@@ -0,0 +1,4 @@
+#define PATH_TRACING
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests/faccessat-y.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests/faccessat-y.c 2021-08-24 19:46:08.276554362 +0200
@@ -0,0 +1,4 @@
+#define FD_PATH "</dev/full>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests/faccessat-yy.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests/faccessat-yy.c 2021-08-24 19:46:08.276554362 +0200
@@ -0,0 +1,4 @@
+#define FD_PATH "</dev/full<char 1:7>>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests/faccessat.c
===================================================================
--- strace-5.7.orig/tests/faccessat.c 2021-08-24 17:01:53.365934740 +0200
+++ strace-5.7/tests/faccessat.c 2021-08-24 19:46:08.277554353 +0200
@@ -1,4 +1,6 @@
/*
+ * Check decoding of faccessat syscall.
+ *
* Copyright (c) 2016-2019 The strace developers.
* All rights reserved.
*
@@ -10,18 +12,133 @@
#ifdef __NR_faccessat
+# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
+# ifndef FD_PATH
+# define FD_PATH ""
+# endif
+# ifndef SKIP_IF_PROC_IS_UNAVAILABLE
+# define SKIP_IF_PROC_IS_UNAVAILABLE
+# endif
+
+static const char *errstr;
+
+static long
+k_faccessat(const unsigned int dirfd,
+ const void *const pathname,
+ const unsigned int mode)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+
+ const kernel_ulong_t arg1 = fill | dirfd;
+ const kernel_ulong_t arg2 = (uintptr_t) pathname;
+ const kernel_ulong_t arg3 = fill | mode;
+ const long rc = syscall(__NR_faccessat,
+ arg1, arg2, arg3, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
int
main(void)
{
- static const char sample[] = "faccessat.sample";
- const long int fd = (long int) 0xdeadbeefffffffffULL;
+ SKIP_IF_PROC_IS_UNAVAILABLE;
- long rc = syscall(__NR_faccessat, fd, sample, F_OK);
- printf("faccessat(%d, \"%s\", F_OK) = %ld %s (%m)\n",
- (int) fd, sample, rc, errno2name());
+ TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
+ char *unterminated_str;
+ if (asprintf(&unterminated_str, "%p", unterminated) < 0)
+ perror_msg_and_fail("asprintf");
+ const void *const efault = unterminated + 1;
+ char *efault_str;
+ if (asprintf(&efault_str, "%p", efault) < 0)
+ perror_msg_and_fail("asprintf");
+
+ typedef struct {
+ char sym;
+ char null;
+ } sym_null;
+
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, dot);
+ dot->sym = '.';
+ dot->null = '\0';
+ const char *const null = &dot->null;
+
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, slash);
+ slash->sym = '/';
+ slash->null = '\0';
+
+ static const char path[] = "/dev/full";
+ const char *const fd_path = tail_memdup(path, sizeof(path));
+ int fd = open(path, O_WRONLY);
+ if (fd < 0)
+ perror_msg_and_fail("open: %s", path);
+ char *fd_str;
+ if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
+ perror_msg_and_fail("asprintf");
+ char *path_quoted;
+ if (asprintf(&path_quoted, "\"%s\"", path) < 0)
+ perror_msg_and_fail("asprintf");
+
+ struct {
+ int val;
+ const char *str;
+ } dirfds[] = {
+ { ARG_STR(-1) },
+ { -100, "AT_FDCWD" },
+ { fd, fd_str },
+ }, modes[] = {
+ { ARG_STR(F_OK) },
+ { ARG_STR(R_OK) },
+ { ARG_STR(W_OK) },
+ { ARG_STR(X_OK) },
+ { ARG_STR(R_OK|W_OK) },
+ { ARG_STR(R_OK|X_OK) },
+ { ARG_STR(W_OK|X_OK) },
+ { ARG_STR(R_OK|W_OK|X_OK) },
+ { 8, "0x8 /* ?_OK */" },
+ { -1, "R_OK|W_OK|X_OK|0xfffffff8" },
+ };
+
+ struct {
+ const void *val;
+ const char *str;
+ } paths[] = {
+ { 0, "NULL" },
+ { efault, efault_str },
+ { unterminated, unterminated_str },
+ { null, "\"\"" },
+ { &dot->sym, "\".\"" },
+ { &slash->sym, "\"/\"" },
+ { fd_path, path_quoted },
+ };
+
+ for (unsigned int dirfd_i = 0;
+ dirfd_i < ARRAY_SIZE(dirfds);
+ ++dirfd_i) {
+ for (unsigned int path_i = 0;
+ path_i < ARRAY_SIZE(paths);
+ ++path_i) {
+ for (unsigned int mode_i = 0;
+ mode_i < ARRAY_SIZE(modes);
+ ++mode_i) {
+ k_faccessat(dirfds[dirfd_i].val,
+ paths[path_i].val,
+ modes[mode_i].val);
+# ifdef PATH_TRACING
+ if (dirfds[dirfd_i].val == fd ||
+ paths[path_i].val == fd_path)
+# endif
+ printf("faccessat(%s, %s, %s) = %s\n",
+ dirfds[dirfd_i].str,
+ paths[path_i].str,
+ modes[mode_i].str,
+ errstr);
+ }
+ }
+ }
puts("+++ exited with 0 +++");
return 0;
Index: strace-5.7/tests/faccessat.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests/faccessat.test 2021-08-24 19:46:08.277554353 +0200
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Check decoding of faccessat syscall.
+#
+# Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. "${srcdir=.}/init.sh"
+
+check_prog sed
+
+run_prog > /dev/null
+run_strace -a23 --trace=faccessat "$@" $args > "$EXP"
+
+# Filter out faccessat() calls made by ld.so and libc.
+sed -n '/^faccessat(-1, NULL,/,$p' < "$LOG" > "$OUT"
+match_diff "$OUT" "$EXP"
Index: strace-5.7/tests/gen_tests.in
===================================================================
--- strace-5.7.orig/tests/gen_tests.in 2021-08-24 19:37:43.192829355 +0200
+++ strace-5.7/tests/gen_tests.in 2021-08-24 19:46:08.278554345 +0200
@@ -73,7 +73,9 @@
erestartsys -a34 -e signal=none -e trace=recvfrom
execveat
execveat-v -v -e trace=execveat
-faccessat -P $NAME.sample
+faccessat-P -a23 --trace=faccessat -P /dev/full
+faccessat-y +faccessat.test -a24 -y
+faccessat-yy +faccessat.test -a24 -yy
fadvise64_64 +fadvise64.test
fallocate -a18
fanotify_init
Index: strace-5.7/tests/pure_executables.list
===================================================================
--- strace-5.7.orig/tests/pure_executables.list 2021-08-24 19:37:43.192829355 +0200
+++ strace-5.7/tests/pure_executables.list 2021-08-24 19:46:08.279554336 +0200
@@ -61,6 +61,9 @@
execve
execveat
faccessat
+faccessat-P
+faccessat-y
+faccessat-yy
fadvise64
fadvise64_64
fallocate
Index: strace-5.7/tests-m32/Makefile.am
===================================================================
--- strace-5.7.orig/tests-m32/Makefile.am 2021-08-24 19:42:16.045519949 +0200
+++ strace-5.7/tests-m32/Makefile.am 2021-08-24 19:46:08.279554336 +0200
@@ -346,6 +346,7 @@
execve-v.test \
execve.test \
fadvise64.test \
+ faccessat.test \
futex.test \
getuid.test \
int_0x80.test \
Index: strace-5.7/tests-m32/faccessat-P.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-m32/faccessat-P.c 2021-08-24 19:46:08.279554336 +0200
@@ -0,0 +1,4 @@
+#define PATH_TRACING
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests-m32/faccessat-y.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-m32/faccessat-y.c 2021-08-24 19:46:08.280554328 +0200
@@ -0,0 +1,4 @@
+#define FD_PATH "</dev/full>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests-m32/faccessat-yy.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-m32/faccessat-yy.c 2021-08-24 19:46:08.280554328 +0200
@@ -0,0 +1,4 @@
+#define FD_PATH "</dev/full<char 1:7>>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests-m32/faccessat.c
===================================================================
--- strace-5.7.orig/tests-m32/faccessat.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-m32/faccessat.c 2021-08-24 19:46:08.281554319 +0200
@@ -1,4 +1,6 @@
/*
+ * Check decoding of faccessat syscall.
+ *
* Copyright (c) 2016-2019 The strace developers.
* All rights reserved.
*
@@ -10,18 +12,133 @@
#ifdef __NR_faccessat
+# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
+# ifndef FD_PATH
+# define FD_PATH ""
+# endif
+# ifndef SKIP_IF_PROC_IS_UNAVAILABLE
+# define SKIP_IF_PROC_IS_UNAVAILABLE
+# endif
+
+static const char *errstr;
+
+static long
+k_faccessat(const unsigned int dirfd,
+ const void *const pathname,
+ const unsigned int mode)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+
+ const kernel_ulong_t arg1 = fill | dirfd;
+ const kernel_ulong_t arg2 = (uintptr_t) pathname;
+ const kernel_ulong_t arg3 = fill | mode;
+ const long rc = syscall(__NR_faccessat,
+ arg1, arg2, arg3, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
int
main(void)
{
- static const char sample[] = "faccessat.sample";
- const long int fd = (long int) 0xdeadbeefffffffffULL;
+ SKIP_IF_PROC_IS_UNAVAILABLE;
- long rc = syscall(__NR_faccessat, fd, sample, F_OK);
- printf("faccessat(%d, \"%s\", F_OK) = %ld %s (%m)\n",
- (int) fd, sample, rc, errno2name());
+ TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
+ char *unterminated_str;
+ if (asprintf(&unterminated_str, "%p", unterminated) < 0)
+ perror_msg_and_fail("asprintf");
+ const void *const efault = unterminated + 1;
+ char *efault_str;
+ if (asprintf(&efault_str, "%p", efault) < 0)
+ perror_msg_and_fail("asprintf");
+
+ typedef struct {
+ char sym;
+ char null;
+ } sym_null;
+
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, dot);
+ dot->sym = '.';
+ dot->null = '\0';
+ const char *const null = &dot->null;
+
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, slash);
+ slash->sym = '/';
+ slash->null = '\0';
+
+ static const char path[] = "/dev/full";
+ const char *const fd_path = tail_memdup(path, sizeof(path));
+ int fd = open(path, O_WRONLY);
+ if (fd < 0)
+ perror_msg_and_fail("open: %s", path);
+ char *fd_str;
+ if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
+ perror_msg_and_fail("asprintf");
+ char *path_quoted;
+ if (asprintf(&path_quoted, "\"%s\"", path) < 0)
+ perror_msg_and_fail("asprintf");
+
+ struct {
+ int val;
+ const char *str;
+ } dirfds[] = {
+ { ARG_STR(-1) },
+ { -100, "AT_FDCWD" },
+ { fd, fd_str },
+ }, modes[] = {
+ { ARG_STR(F_OK) },
+ { ARG_STR(R_OK) },
+ { ARG_STR(W_OK) },
+ { ARG_STR(X_OK) },
+ { ARG_STR(R_OK|W_OK) },
+ { ARG_STR(R_OK|X_OK) },
+ { ARG_STR(W_OK|X_OK) },
+ { ARG_STR(R_OK|W_OK|X_OK) },
+ { 8, "0x8 /* ?_OK */" },
+ { -1, "R_OK|W_OK|X_OK|0xfffffff8" },
+ };
+
+ struct {
+ const void *val;
+ const char *str;
+ } paths[] = {
+ { 0, "NULL" },
+ { efault, efault_str },
+ { unterminated, unterminated_str },
+ { null, "\"\"" },
+ { &dot->sym, "\".\"" },
+ { &slash->sym, "\"/\"" },
+ { fd_path, path_quoted },
+ };
+
+ for (unsigned int dirfd_i = 0;
+ dirfd_i < ARRAY_SIZE(dirfds);
+ ++dirfd_i) {
+ for (unsigned int path_i = 0;
+ path_i < ARRAY_SIZE(paths);
+ ++path_i) {
+ for (unsigned int mode_i = 0;
+ mode_i < ARRAY_SIZE(modes);
+ ++mode_i) {
+ k_faccessat(dirfds[dirfd_i].val,
+ paths[path_i].val,
+ modes[mode_i].val);
+# ifdef PATH_TRACING
+ if (dirfds[dirfd_i].val == fd ||
+ paths[path_i].val == fd_path)
+# endif
+ printf("faccessat(%s, %s, %s) = %s\n",
+ dirfds[dirfd_i].str,
+ paths[path_i].str,
+ modes[mode_i].str,
+ errstr);
+ }
+ }
+ }
puts("+++ exited with 0 +++");
return 0;
Index: strace-5.7/tests-m32/faccessat.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-m32/faccessat.test 2021-08-24 19:46:08.281554319 +0200
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Check decoding of faccessat syscall.
+#
+# Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. "${srcdir=.}/init.sh"
+
+check_prog sed
+
+run_prog > /dev/null
+run_strace -a23 --trace=faccessat "$@" $args > "$EXP"
+
+# Filter out faccessat() calls made by ld.so and libc.
+sed -n '/^faccessat(-1, NULL,/,$p' < "$LOG" > "$OUT"
+match_diff "$OUT" "$EXP"
Index: strace-5.7/tests-m32/gen_tests.in
===================================================================
--- strace-5.7.orig/tests-m32/gen_tests.in 2021-08-24 19:37:43.193829347 +0200
+++ strace-5.7/tests-m32/gen_tests.in 2021-08-24 19:46:08.282554311 +0200
@@ -73,7 +73,9 @@
erestartsys -a34 -e signal=none -e trace=recvfrom
execveat
execveat-v -v -e trace=execveat
-faccessat -P $NAME.sample
+faccessat-P -a23 --trace=faccessat -P /dev/full
+faccessat-y +faccessat.test -a24 -y
+faccessat-yy +faccessat.test -a24 -yy
fadvise64_64 +fadvise64.test
fallocate -a18
fanotify_init
Index: strace-5.7/tests-m32/pure_executables.list
===================================================================
--- strace-5.7.orig/tests-m32/pure_executables.list 2021-08-24 19:37:43.193829347 +0200
+++ strace-5.7/tests-m32/pure_executables.list 2021-08-24 19:46:08.283554302 +0200
@@ -61,6 +61,9 @@
execve
execveat
faccessat
+faccessat-P
+faccessat-y
+faccessat-yy
fadvise64
fadvise64_64
fallocate
Index: strace-5.7/tests-mx32/Makefile.am
===================================================================
--- strace-5.7.orig/tests-mx32/Makefile.am 2021-08-24 19:42:16.048519924 +0200
+++ strace-5.7/tests-mx32/Makefile.am 2021-08-24 19:46:08.283554302 +0200
@@ -346,6 +346,7 @@
execve-v.test \
execve.test \
fadvise64.test \
+ faccessat.test \
futex.test \
getuid.test \
int_0x80.test \
Index: strace-5.7/tests-mx32/faccessat-P.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-mx32/faccessat-P.c 2021-08-24 19:46:08.283554302 +0200
@@ -0,0 +1,4 @@
+#define PATH_TRACING
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests-mx32/faccessat-y.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-mx32/faccessat-y.c 2021-08-24 19:46:08.284554294 +0200
@@ -0,0 +1,4 @@
+#define FD_PATH "</dev/full>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests-mx32/faccessat-yy.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-mx32/faccessat-yy.c 2021-08-24 19:46:08.284554294 +0200
@@ -0,0 +1,4 @@
+#define FD_PATH "</dev/full<char 1:7>>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
+#include "faccessat.c"
Index: strace-5.7/tests-mx32/faccessat.c
===================================================================
--- strace-5.7.orig/tests-mx32/faccessat.c 2019-09-25 03:02:03.000000000 +0200
+++ strace-5.7/tests-mx32/faccessat.c 2021-08-24 19:46:08.285554285 +0200
@@ -1,4 +1,6 @@
/*
+ * Check decoding of faccessat syscall.
+ *
* Copyright (c) 2016-2019 The strace developers.
* All rights reserved.
*
@@ -10,18 +12,133 @@
#ifdef __NR_faccessat
+# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
+# ifndef FD_PATH
+# define FD_PATH ""
+# endif
+# ifndef SKIP_IF_PROC_IS_UNAVAILABLE
+# define SKIP_IF_PROC_IS_UNAVAILABLE
+# endif
+
+static const char *errstr;
+
+static long
+k_faccessat(const unsigned int dirfd,
+ const void *const pathname,
+ const unsigned int mode)
+{
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+
+ const kernel_ulong_t arg1 = fill | dirfd;
+ const kernel_ulong_t arg2 = (uintptr_t) pathname;
+ const kernel_ulong_t arg3 = fill | mode;
+ const long rc = syscall(__NR_faccessat,
+ arg1, arg2, arg3, bad, bad, bad);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
int
main(void)
{
- static const char sample[] = "faccessat.sample";
- const long int fd = (long int) 0xdeadbeefffffffffULL;
+ SKIP_IF_PROC_IS_UNAVAILABLE;
- long rc = syscall(__NR_faccessat, fd, sample, F_OK);
- printf("faccessat(%d, \"%s\", F_OK) = %ld %s (%m)\n",
- (int) fd, sample, rc, errno2name());
+ TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
+ char *unterminated_str;
+ if (asprintf(&unterminated_str, "%p", unterminated) < 0)
+ perror_msg_and_fail("asprintf");
+ const void *const efault = unterminated + 1;
+ char *efault_str;
+ if (asprintf(&efault_str, "%p", efault) < 0)
+ perror_msg_and_fail("asprintf");
+
+ typedef struct {
+ char sym;
+ char null;
+ } sym_null;
+
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, dot);
+ dot->sym = '.';
+ dot->null = '\0';
+ const char *const null = &dot->null;
+
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, slash);
+ slash->sym = '/';
+ slash->null = '\0';
+
+ static const char path[] = "/dev/full";
+ const char *const fd_path = tail_memdup(path, sizeof(path));
+ int fd = open(path, O_WRONLY);
+ if (fd < 0)
+ perror_msg_and_fail("open: %s", path);
+ char *fd_str;
+ if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
+ perror_msg_and_fail("asprintf");
+ char *path_quoted;
+ if (asprintf(&path_quoted, "\"%s\"", path) < 0)
+ perror_msg_and_fail("asprintf");
+
+ struct {
+ int val;
+ const char *str;
+ } dirfds[] = {
+ { ARG_STR(-1) },
+ { -100, "AT_FDCWD" },
+ { fd, fd_str },
+ }, modes[] = {
+ { ARG_STR(F_OK) },
+ { ARG_STR(R_OK) },
+ { ARG_STR(W_OK) },
+ { ARG_STR(X_OK) },
+ { ARG_STR(R_OK|W_OK) },
+ { ARG_STR(R_OK|X_OK) },
+ { ARG_STR(W_OK|X_OK) },
+ { ARG_STR(R_OK|W_OK|X_OK) },
+ { 8, "0x8 /* ?_OK */" },
+ { -1, "R_OK|W_OK|X_OK|0xfffffff8" },
+ };
+
+ struct {
+ const void *val;
+ const char *str;
+ } paths[] = {
+ { 0, "NULL" },
+ { efault, efault_str },
+ { unterminated, unterminated_str },
+ { null, "\"\"" },
+ { &dot->sym, "\".\"" },
+ { &slash->sym, "\"/\"" },
+ { fd_path, path_quoted },
+ };
+
+ for (unsigned int dirfd_i = 0;
+ dirfd_i < ARRAY_SIZE(dirfds);
+ ++dirfd_i) {
+ for (unsigned int path_i = 0;
+ path_i < ARRAY_SIZE(paths);
+ ++path_i) {
+ for (unsigned int mode_i = 0;
+ mode_i < ARRAY_SIZE(modes);
+ ++mode_i) {
+ k_faccessat(dirfds[dirfd_i].val,
+ paths[path_i].val,
+ modes[mode_i].val);
+# ifdef PATH_TRACING
+ if (dirfds[dirfd_i].val == fd ||
+ paths[path_i].val == fd_path)
+# endif
+ printf("faccessat(%s, %s, %s) = %s\n",
+ dirfds[dirfd_i].str,
+ paths[path_i].str,
+ modes[mode_i].str,
+ errstr);
+ }
+ }
+ }
puts("+++ exited with 0 +++");
return 0;
Index: strace-5.7/tests-mx32/faccessat.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/tests-mx32/faccessat.test 2021-08-24 19:46:08.285554285 +0200
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Check decoding of faccessat syscall.
+#
+# Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. "${srcdir=.}/init.sh"
+
+check_prog sed
+
+run_prog > /dev/null
+run_strace -a23 --trace=faccessat "$@" $args > "$EXP"
+
+# Filter out faccessat() calls made by ld.so and libc.
+sed -n '/^faccessat(-1, NULL,/,$p' < "$LOG" > "$OUT"
+match_diff "$OUT" "$EXP"
Index: strace-5.7/tests-mx32/gen_tests.in
===================================================================
--- strace-5.7.orig/tests-mx32/gen_tests.in 2021-08-24 19:37:43.194829339 +0200
+++ strace-5.7/tests-mx32/gen_tests.in 2021-08-24 19:46:08.286554277 +0200
@@ -73,7 +73,9 @@
erestartsys -a34 -e signal=none -e trace=recvfrom
execveat
execveat-v -v -e trace=execveat
-faccessat -P $NAME.sample
+faccessat-P -a23 --trace=faccessat -P /dev/full
+faccessat-y +faccessat.test -a24 -y
+faccessat-yy +faccessat.test -a24 -yy
fadvise64_64 +fadvise64.test
fallocate -a18
fanotify_init
Index: strace-5.7/tests-mx32/pure_executables.list
===================================================================
--- strace-5.7.orig/tests-mx32/pure_executables.list 2021-08-24 19:37:43.195829330 +0200
+++ strace-5.7/tests-mx32/pure_executables.list 2021-08-24 19:46:08.286554277 +0200
@@ -61,6 +61,9 @@
execve
execveat
faccessat
+faccessat-P
+faccessat-y
+faccessat-yy
fadvise64
fadvise64_64
fallocate
Index: strace-5.7/tests/Makefile.in
===================================================================
--- strace-5.7.orig/tests/Makefile.in 2021-08-24 19:42:54.720192609 +0200
+++ strace-5.7/tests/Makefile.in 2021-08-24 19:46:08.292554226 +0200
@@ -6523,6 +6523,7 @@
execve-v.test \
execve.test \
fadvise64.test \
+ faccessat.test \
futex.test \
getuid.test \
int_0x80.test \
Index: strace-5.7/tests-m32/Makefile.in
===================================================================
--- strace-5.7.orig/tests-m32/Makefile.in 2021-08-24 19:43:13.669032228 +0200
+++ strace-5.7/tests-m32/Makefile.in 2021-08-24 19:46:08.296554192 +0200
@@ -6523,6 +6523,7 @@
execve-v.test \
execve.test \
fadvise64.test \
+ faccessat.test \
futex.test \
getuid.test \
int_0x80.test \
Index: strace-5.7/tests-mx32/Makefile.in
===================================================================
--- strace-5.7.orig/tests-mx32/Makefile.in 2021-08-24 19:43:32.469873099 +0200
+++ strace-5.7/tests-mx32/Makefile.in 2021-08-24 19:46:08.299554167 +0200
@@ -6523,6 +6523,7 @@
execve-v.test \
execve.test \
fadvise64.test \
+ faccessat.test \
futex.test \
getuid.test \
int_0x80.test \

View File

@ -1,65 +0,0 @@
From f2b8769e4a9aa99cd5e0aef41a0408c34de3cc8e Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Mon, 15 Mar 2021 08:00:00 +0000
Subject: [PATCH 145/149] xmalloc: introduce xasprintf
xasprintf is a trivial wrapper around vasprintf,
the primary purpose of adding it is to simplify tests.
* xmalloc.h (xasprintf): New function declaration.
* xmalloc.c: Include <stdarg.h> and <stdio.h>
(xasprintf): New function.
---
xmalloc.c | 16 ++++++++++++++++
xmalloc.h | 6 ++++++
2 files changed, 22 insertions(+)
diff --git a/xmalloc.c b/xmalloc.c
index 8688f91..75019e9 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -10,6 +10,8 @@
# include "config.h"
#endif
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -146,3 +148,17 @@ xstrndup(const char *str, size_t n)
return p;
}
+
+char *
+xasprintf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+
+ char *res;
+ if (vasprintf(&res, fmt, ap) < 0)
+ die_out_of_memory();
+
+ va_end(ap);
+ return res;
+}
diff --git a/xmalloc.h b/xmalloc.h
index 4bf1e2c..1305a1e 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -77,4 +77,10 @@ void *xgrowarray(void *ptr, size_t *nmemb, size_t memb_size);
char *xstrdup(const char *str) ATTRIBUTE_MALLOC;
char *xstrndup(const char *str, size_t n) ATTRIBUTE_MALLOC;
+/**
+ * Analogous to asprintf, die in case of an error.
+ */
+char *xasprintf(const char *fmt, ...)
+ ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_MALLOC;
+
#endif /* !STRACE_XMALLOC_H */
--
2.1.4

View File

@ -1,891 +0,0 @@
From bcd0f3ef964aead4b9e95c10f4c5c75f58ba102c Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Mon, 15 Mar 2021 08:00:00 +0000
Subject: [PATCH 146/149] tests: use xasprintf instead of asprintf
* tests/clone-flags.c: Include "xmalloc.h", replace all asprintf
invocations followed by perror_msg_and_fail with xasprintf.
* tests/epoll_pwait2.c: Likewise.
* tests/faccessat.c: Likewise.
* tests/faccessat2.c: Likewise.
* tests/ioctl_kvm_run_common.c: Likewise.
* tests/keyctl.c: Likewise.
* tests/lock_file.c: Likewise.
* tests/mq.c: Likewise.
* tests/mq_sendrecv.c: Likewise.
* tests/netlink_protocol.c: Likewise.
* tests/old_mmap.c: Likewise.
* tests/tracer_ppid_pgid_sid.c: Likewise.
Conflicts:
tests/epoll_pwait2.c
tests/faccessat2.c
tests/mq_sendrecv.c
---
tests/clone-flags.c | 5 ++---
tests/faccessat.c | 17 +++++------------
tests/ioctl_kvm_run_common.c | 6 ++----
tests/keyctl.c | 29 +++++++++++++----------------
tests/lock_file.c | 5 ++---
tests/mq.c | 5 ++---
tests/mq_sendrecv.c | 4 ++--
tests/netlink_protocol.c | 5 ++---
tests/old_mmap.c | 5 ++---
tests/tracer_ppid_pgid_sid.c | 6 ++----
10 files changed, 34 insertions(+), 53 deletions(-)
diff --git a/tests/clone-flags.c b/tests/clone-flags.c
index 04bb2c7..aa7d48c 100644
--- a/tests/clone-flags.c
+++ b/tests/clone-flags.c
@@ -8,6 +8,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <errno.h>
#include <limits.h>
@@ -134,9 +135,7 @@ main(void)
*ptid = 0;
pid = do_clone(child, child_stack, child_stack_size,
CLONE_PIDFD|SIGCHLD, 0, ptid);
- char *fname = 0;
- if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
- perror_msg_and_fail("asprintf");
+ char *fname = xasprintf("/proc/self/fd/%d", *ptid);
int rc = readlink(fname, buf, sizeof(buf) - 1);
if ((unsigned int) rc >= sizeof(buf))
perror_msg_and_fail("readlink");
diff --git a/tests/faccessat.c b/tests/faccessat.c
index c42aa2d..8cda6f3 100644
--- a/tests/faccessat.c
+++ b/tests/faccessat.c
@@ -12,6 +12,7 @@
#ifdef __NR_faccessat
+# include "xmalloc.h"
# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
@@ -48,13 +49,9 @@ main(void)
SKIP_IF_PROC_IS_UNAVAILABLE;
TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
- char *unterminated_str;
- if (asprintf(&unterminated_str, "%p", unterminated) < 0)
- perror_msg_and_fail("asprintf");
+ char *unterminated_str = xasprintf("%p", unterminated);
const void *const efault = unterminated + 1;
- char *efault_str;
- if (asprintf(&efault_str, "%p", efault) < 0)
- perror_msg_and_fail("asprintf");
+ char *efault_str = xasprintf("%p", efault);
typedef struct {
char sym;
@@ -75,12 +72,8 @@ main(void)
int fd = open(path, O_WRONLY);
if (fd < 0)
perror_msg_and_fail("open: %s", path);
- char *fd_str;
- if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
- perror_msg_and_fail("asprintf");
- char *path_quoted;
- if (asprintf(&path_quoted, "\"%s\"", path) < 0)
- perror_msg_and_fail("asprintf");
+ char *fd_str = xasprintf("%d%s", fd, FD_PATH);
+ char *path_quoted = xasprintf("\"%s\"", path);
struct {
int val;
diff --git a/tests/ioctl_kvm_run_common.c b/tests/ioctl_kvm_run_common.c
index 9107c30..be1190e 100644
--- a/tests/ioctl_kvm_run_common.c
+++ b/tests/ioctl_kvm_run_common.c
@@ -48,6 +48,7 @@
# define KVM_MAX_CPUID_ENTRIES 80
# endif
+# include "xmalloc.h"
# include "xlat.h"
# include "xlat/kvm_cpuid_flags.h"
@@ -254,12 +255,9 @@ static int
vcpu_dev_should_have_cpuid(int fd)
{
int r = 0;
- char *filename = NULL;
+ char *filename = xasprintf("/proc/%d/fd/%d", getpid(), fd);
char buf[sizeof(vcpu_dev)];
- if (asprintf(&filename, "/proc/%d/fd/%d", getpid(), fd) < 0)
- error_msg_and_fail("asprintf");
-
if (readlink(filename, buf, sizeof(buf)) == sizeof(buf) - 1
&& (memcmp(buf, vcpu_dev, sizeof(buf) - 1) == 0))
r = 1;
diff --git a/tests/keyctl.c b/tests/keyctl.c
index 6dc30fb..96ac197 100644
--- a/tests/keyctl.c
+++ b/tests/keyctl.c
@@ -11,6 +11,7 @@
#include "tests.h"
#include "scno.h"
+#include "xmalloc.h"
#ifdef __NR_keyctl
@@ -445,7 +446,6 @@ main(void)
struct iovec *key_iov = tail_alloc(sizeof(*key_iov) * IOV_SIZE);
char *bogus_buf1 = tail_alloc(9);
char *bogus_buf2 = tail_alloc(256);
- char *key_iov_str1;
char *key_iov_str2 = tail_alloc(4096);
const char *errstr;
ssize_t ret;
@@ -472,21 +472,18 @@ main(void)
0x100000001ULL * i);
}
- ret = asprintf(&key_iov_str1, "[{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}]",
- key_iov[IOV_SIZE - 4].iov_base,
- key_iov[IOV_SIZE - 4].iov_len,
- key_iov[IOV_SIZE - 3].iov_base,
- key_iov[IOV_SIZE - 3].iov_len,
- key_iov[IOV_SIZE - 2].iov_base,
- key_iov[IOV_SIZE - 2].iov_len,
- key_iov[IOV_SIZE - 1].iov_base,
- key_iov[IOV_SIZE - 1].iov_len);
-
- if (ret < 0)
- error_msg_and_fail("asprintf");
+ char *key_iov_str1 = xasprintf("[{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}]",
+ key_iov[IOV_SIZE - 4].iov_base,
+ key_iov[IOV_SIZE - 4].iov_len,
+ key_iov[IOV_SIZE - 3].iov_base,
+ key_iov[IOV_SIZE - 3].iov_len,
+ key_iov[IOV_SIZE - 2].iov_base,
+ key_iov[IOV_SIZE - 2].iov_len,
+ key_iov[IOV_SIZE - 1].iov_base,
+ key_iov[IOV_SIZE - 1].iov_len);
ret = snprintf(key_iov_str2, IOV_STR_SIZE,
"[{iov_base=\"%s\\0\", iov_len=%zu}, "
diff --git a/tests/lock_file.c b/tests/lock_file.c
index 56cf112..7618552 100644
--- a/tests/lock_file.c
+++ b/tests/lock_file.c
@@ -6,6 +6,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <fcntl.h>
#include <stdio.h>
@@ -21,9 +22,7 @@ lock_file_by_dirname(const char *path_name, const char *lock_name)
const char *slash = path_name ? strrchr(path_name, '/') : NULL;
const int plen = slash ? (int) (slash - path_name) + 1 : 0;
- char *lock_file = NULL;
- if (asprintf(&lock_file, "%.*s%s", plen, path_name, lock_name) < 0)
- perror_msg_and_fail("asprintf");
+ char *lock_file = xasprintf("%.*s%s", plen, path_name, lock_name);
int lock_fd = open(lock_file, O_RDONLY);
if (lock_fd < 0)
diff --git a/tests/mq.c b/tests/mq.c
index a083e5a..7aa0914 100644
--- a/tests/mq.c
+++ b/tests/mq.c
@@ -17,6 +17,7 @@
# include <stdlib.h>
# include <unistd.h>
# include <sys/stat.h>
+# include "xmalloc.h"
int
main(void)
@@ -24,9 +25,7 @@ main(void)
struct mq_attr attr;
(void) close(0);
- char *name;
- if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
- perror_msg_and_fail("asprintf");
+ char *name = xasprintf("/strace-mq-%u.sample", getpid());
if (mq_open(name, O_CREAT, 0700, NULL))
perror_msg_and_skip("mq_open");
diff --git a/tests/mq_sendrecv.c b/tests/mq_sendrecv.c
index 45ddf5e..5a919c4 100644
--- a/tests/mq_sendrecv.c
+++ b/tests/mq_sendrecv.c
@@ -27,6 +27,7 @@
# include <time.h>
# include <unistd.h>
+# include "xmalloc.h"
# include "sigevent.h"
# ifndef DUMPIO_READ
@@ -407,8 +408,7 @@ main(void)
/* Sending and receiving test */
- if (asprintf(&mq_name, "strace-mq_sendrecv-%u.sample", getpid()) < 0)
- perror_msg_and_fail("asprintf");
+ mq_name = xasprintf("strace-mq_sendrecv-%u.sample", getpid());
# if DUMPIO_READ || DUMPIO_WRITE
close(0);
diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c
index e632ba3..c37489f 100644
--- a/tests/netlink_protocol.c
+++ b/tests/netlink_protocol.c
@@ -22,6 +22,7 @@
# include "netlink.h"
# include <linux/sock_diag.h>
# include <linux/netlink_diag.h>
+# include "xmalloc.h"
static void
send_query(const int fd)
@@ -388,9 +389,7 @@ int main(void)
{
const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
- char *path;
- if (asprintf(&path, "/proc/self/fd/%u", fd) < 0)
- perror_msg_and_fail("asprintf");
+ char *path = xasprintf("/proc/self/fd/%u", fd);
char buf[256];
if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0)
perror_msg_and_skip("getxattr");
diff --git a/tests/old_mmap.c b/tests/old_mmap.c
index f095bc4..bb70359 100644
--- a/tests/old_mmap.c
+++ b/tests/old_mmap.c
@@ -27,6 +27,7 @@
# include <string.h>
# include <sys/mman.h>
# include <unistd.h>
+# include "xmalloc.h"
# ifndef TEST_FD
# define TEST_FD -2LU
@@ -82,9 +83,7 @@ main(void)
# ifndef PATH_TRACING
const char *errstr;
if (implemented) {
- char *str;
- if (asprintf(&str, "%#lx", rc) < 0)
- perror_msg_and_fail("asprintf");
+ char *str = xasprintf("%#lx", rc);
errstr = str;
} else {
errstr = sprintrc(rc);
diff --git a/tests/tracer_ppid_pgid_sid.c b/tests/tracer_ppid_pgid_sid.c
index 69687fa..ce9936d 100644
--- a/tests/tracer_ppid_pgid_sid.c
+++ b/tests/tracer_ppid_pgid_sid.c
@@ -8,6 +8,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,10 +56,7 @@ get_tracer_pid(void)
static void
get_ppid_pgid_sid(int pid, int *ppid, int *pgid, int *sid)
{
- char *stat;
- if (asprintf(&stat, "/proc/%d/stat", pid) < 0)
- perror_msg_and_fail("asprintf");
-
+ char *stat = xasprintf("/proc/%d/stat", pid);
FILE *fp = fopen(stat, "r");
if (!fp)
perror_msg_and_fail("fopen: %s", stat);
diff --git a/tests-m32/clone-flags.c b/tests-m32/clone-flags.c
index 04bb2c7..aa7d48c 100644
--- a/tests-m32/clone-flags.c
+++ b/tests-m32/clone-flags.c
@@ -8,6 +8,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <errno.h>
#include <limits.h>
@@ -134,9 +135,7 @@ main(void)
*ptid = 0;
pid = do_clone(child, child_stack, child_stack_size,
CLONE_PIDFD|SIGCHLD, 0, ptid);
- char *fname = 0;
- if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
- perror_msg_and_fail("asprintf");
+ char *fname = xasprintf("/proc/self/fd/%d", *ptid);
int rc = readlink(fname, buf, sizeof(buf) - 1);
if ((unsigned int) rc >= sizeof(buf))
perror_msg_and_fail("readlink");
diff --git a/tests-m32/faccessat.c b/tests-m32/faccessat.c
index c42aa2d..8cda6f3 100644
--- a/tests-m32/faccessat.c
+++ b/tests-m32/faccessat.c
@@ -12,6 +12,7 @@
#ifdef __NR_faccessat
+# include "xmalloc.h"
# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
@@ -48,13 +49,9 @@ main(void)
SKIP_IF_PROC_IS_UNAVAILABLE;
TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
- char *unterminated_str;
- if (asprintf(&unterminated_str, "%p", unterminated) < 0)
- perror_msg_and_fail("asprintf");
+ char *unterminated_str = xasprintf("%p", unterminated);
const void *const efault = unterminated + 1;
- char *efault_str;
- if (asprintf(&efault_str, "%p", efault) < 0)
- perror_msg_and_fail("asprintf");
+ char *efault_str = xasprintf("%p", efault);
typedef struct {
char sym;
@@ -75,12 +72,8 @@ main(void)
int fd = open(path, O_WRONLY);
if (fd < 0)
perror_msg_and_fail("open: %s", path);
- char *fd_str;
- if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
- perror_msg_and_fail("asprintf");
- char *path_quoted;
- if (asprintf(&path_quoted, "\"%s\"", path) < 0)
- perror_msg_and_fail("asprintf");
+ char *fd_str = xasprintf("%d%s", fd, FD_PATH);
+ char *path_quoted = xasprintf("\"%s\"", path);
struct {
int val;
diff --git a/tests-m32/ioctl_kvm_run_common.c b/tests-m32/ioctl_kvm_run_common.c
index 9107c30..be1190e 100644
--- a/tests-m32/ioctl_kvm_run_common.c
+++ b/tests-m32/ioctl_kvm_run_common.c
@@ -48,6 +48,7 @@
# define KVM_MAX_CPUID_ENTRIES 80
# endif
+# include "xmalloc.h"
# include "xlat.h"
# include "xlat/kvm_cpuid_flags.h"
@@ -254,12 +255,9 @@ static int
vcpu_dev_should_have_cpuid(int fd)
{
int r = 0;
- char *filename = NULL;
+ char *filename = xasprintf("/proc/%d/fd/%d", getpid(), fd);
char buf[sizeof(vcpu_dev)];
- if (asprintf(&filename, "/proc/%d/fd/%d", getpid(), fd) < 0)
- error_msg_and_fail("asprintf");
-
if (readlink(filename, buf, sizeof(buf)) == sizeof(buf) - 1
&& (memcmp(buf, vcpu_dev, sizeof(buf) - 1) == 0))
r = 1;
diff --git a/tests-m32/keyctl.c b/tests-m32/keyctl.c
index 6dc30fb..96ac197 100644
--- a/tests-m32/keyctl.c
+++ b/tests-m32/keyctl.c
@@ -11,6 +11,7 @@
#include "tests.h"
#include "scno.h"
+#include "xmalloc.h"
#ifdef __NR_keyctl
@@ -445,7 +446,6 @@ main(void)
struct iovec *key_iov = tail_alloc(sizeof(*key_iov) * IOV_SIZE);
char *bogus_buf1 = tail_alloc(9);
char *bogus_buf2 = tail_alloc(256);
- char *key_iov_str1;
char *key_iov_str2 = tail_alloc(4096);
const char *errstr;
ssize_t ret;
@@ -472,21 +472,18 @@ main(void)
0x100000001ULL * i);
}
- ret = asprintf(&key_iov_str1, "[{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}]",
- key_iov[IOV_SIZE - 4].iov_base,
- key_iov[IOV_SIZE - 4].iov_len,
- key_iov[IOV_SIZE - 3].iov_base,
- key_iov[IOV_SIZE - 3].iov_len,
- key_iov[IOV_SIZE - 2].iov_base,
- key_iov[IOV_SIZE - 2].iov_len,
- key_iov[IOV_SIZE - 1].iov_base,
- key_iov[IOV_SIZE - 1].iov_len);
-
- if (ret < 0)
- error_msg_and_fail("asprintf");
+ char *key_iov_str1 = xasprintf("[{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}]",
+ key_iov[IOV_SIZE - 4].iov_base,
+ key_iov[IOV_SIZE - 4].iov_len,
+ key_iov[IOV_SIZE - 3].iov_base,
+ key_iov[IOV_SIZE - 3].iov_len,
+ key_iov[IOV_SIZE - 2].iov_base,
+ key_iov[IOV_SIZE - 2].iov_len,
+ key_iov[IOV_SIZE - 1].iov_base,
+ key_iov[IOV_SIZE - 1].iov_len);
ret = snprintf(key_iov_str2, IOV_STR_SIZE,
"[{iov_base=\"%s\\0\", iov_len=%zu}, "
diff --git a/tests-m32/lock_file.c b/tests-m32/lock_file.c
index 56cf112..7618552 100644
--- a/tests-m32/lock_file.c
+++ b/tests-m32/lock_file.c
@@ -6,6 +6,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <fcntl.h>
#include <stdio.h>
@@ -21,9 +22,7 @@ lock_file_by_dirname(const char *path_name, const char *lock_name)
const char *slash = path_name ? strrchr(path_name, '/') : NULL;
const int plen = slash ? (int) (slash - path_name) + 1 : 0;
- char *lock_file = NULL;
- if (asprintf(&lock_file, "%.*s%s", plen, path_name, lock_name) < 0)
- perror_msg_and_fail("asprintf");
+ char *lock_file = xasprintf("%.*s%s", plen, path_name, lock_name);
int lock_fd = open(lock_file, O_RDONLY);
if (lock_fd < 0)
diff --git a/tests-m32/mq.c b/tests-m32/mq.c
index a083e5a..7aa0914 100644
--- a/tests-m32/mq.c
+++ b/tests-m32/mq.c
@@ -17,6 +17,7 @@
# include <stdlib.h>
# include <unistd.h>
# include <sys/stat.h>
+# include "xmalloc.h"
int
main(void)
@@ -24,9 +25,7 @@ main(void)
struct mq_attr attr;
(void) close(0);
- char *name;
- if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
- perror_msg_and_fail("asprintf");
+ char *name = xasprintf("/strace-mq-%u.sample", getpid());
if (mq_open(name, O_CREAT, 0700, NULL))
perror_msg_and_skip("mq_open");
diff --git a/tests-m32/mq_sendrecv.c b/tests-m32/mq_sendrecv.c
index 45ddf5e..5a919c4 100644
--- a/tests-m32/mq_sendrecv.c
+++ b/tests-m32/mq_sendrecv.c
@@ -27,6 +27,7 @@
# include <time.h>
# include <unistd.h>
+# include "xmalloc.h"
# include "sigevent.h"
# ifndef DUMPIO_READ
@@ -407,8 +408,7 @@ main(void)
/* Sending and receiving test */
- if (asprintf(&mq_name, "strace-mq_sendrecv-%u.sample", getpid()) < 0)
- perror_msg_and_fail("asprintf");
+ mq_name = xasprintf("strace-mq_sendrecv-%u.sample", getpid());
# if DUMPIO_READ || DUMPIO_WRITE
close(0);
diff --git a/tests-m32/netlink_protocol.c b/tests-m32/netlink_protocol.c
index e632ba3..c37489f 100644
--- a/tests-m32/netlink_protocol.c
+++ b/tests-m32/netlink_protocol.c
@@ -22,6 +22,7 @@
# include "netlink.h"
# include <linux/sock_diag.h>
# include <linux/netlink_diag.h>
+# include "xmalloc.h"
static void
send_query(const int fd)
@@ -388,9 +389,7 @@ int main(void)
{
const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
- char *path;
- if (asprintf(&path, "/proc/self/fd/%u", fd) < 0)
- perror_msg_and_fail("asprintf");
+ char *path = xasprintf("/proc/self/fd/%u", fd);
char buf[256];
if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0)
perror_msg_and_skip("getxattr");
diff --git a/tests-m32/old_mmap.c b/tests-m32/old_mmap.c
index f095bc4..bb70359 100644
--- a/tests-m32/old_mmap.c
+++ b/tests-m32/old_mmap.c
@@ -27,6 +27,7 @@
# include <string.h>
# include <sys/mman.h>
# include <unistd.h>
+# include "xmalloc.h"
# ifndef TEST_FD
# define TEST_FD -2LU
@@ -82,9 +83,7 @@ main(void)
# ifndef PATH_TRACING
const char *errstr;
if (implemented) {
- char *str;
- if (asprintf(&str, "%#lx", rc) < 0)
- perror_msg_and_fail("asprintf");
+ char *str = xasprintf("%#lx", rc);
errstr = str;
} else {
errstr = sprintrc(rc);
diff --git a/tests-m32/tracer_ppid_pgid_sid.c b/tests-m32/tracer_ppid_pgid_sid.c
index 69687fa..ce9936d 100644
--- a/tests-m32/tracer_ppid_pgid_sid.c
+++ b/tests-m32/tracer_ppid_pgid_sid.c
@@ -8,6 +8,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,10 +56,7 @@ get_tracer_pid(void)
static void
get_ppid_pgid_sid(int pid, int *ppid, int *pgid, int *sid)
{
- char *stat;
- if (asprintf(&stat, "/proc/%d/stat", pid) < 0)
- perror_msg_and_fail("asprintf");
-
+ char *stat = xasprintf("/proc/%d/stat", pid);
FILE *fp = fopen(stat, "r");
if (!fp)
perror_msg_and_fail("fopen: %s", stat);
diff --git a/tests-mx32/clone-flags.c b/tests-mx32/clone-flags.c
index 04bb2c7..aa7d48c 100644
--- a/tests-mx32/clone-flags.c
+++ b/tests-mx32/clone-flags.c
@@ -8,6 +8,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <errno.h>
#include <limits.h>
@@ -134,9 +135,7 @@ main(void)
*ptid = 0;
pid = do_clone(child, child_stack, child_stack_size,
CLONE_PIDFD|SIGCHLD, 0, ptid);
- char *fname = 0;
- if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
- perror_msg_and_fail("asprintf");
+ char *fname = xasprintf("/proc/self/fd/%d", *ptid);
int rc = readlink(fname, buf, sizeof(buf) - 1);
if ((unsigned int) rc >= sizeof(buf))
perror_msg_and_fail("readlink");
diff --git a/tests-mx32/faccessat.c b/tests-mx32/faccessat.c
index c42aa2d..8cda6f3 100644
--- a/tests-mx32/faccessat.c
+++ b/tests-mx32/faccessat.c
@@ -12,6 +12,7 @@
#ifdef __NR_faccessat
+# include "xmalloc.h"
# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
@@ -48,13 +49,9 @@ main(void)
SKIP_IF_PROC_IS_UNAVAILABLE;
TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
- char *unterminated_str;
- if (asprintf(&unterminated_str, "%p", unterminated) < 0)
- perror_msg_and_fail("asprintf");
+ char *unterminated_str = xasprintf("%p", unterminated);
const void *const efault = unterminated + 1;
- char *efault_str;
- if (asprintf(&efault_str, "%p", efault) < 0)
- perror_msg_and_fail("asprintf");
+ char *efault_str = xasprintf("%p", efault);
typedef struct {
char sym;
@@ -75,12 +72,8 @@ main(void)
int fd = open(path, O_WRONLY);
if (fd < 0)
perror_msg_and_fail("open: %s", path);
- char *fd_str;
- if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
- perror_msg_and_fail("asprintf");
- char *path_quoted;
- if (asprintf(&path_quoted, "\"%s\"", path) < 0)
- perror_msg_and_fail("asprintf");
+ char *fd_str = xasprintf("%d%s", fd, FD_PATH);
+ char *path_quoted = xasprintf("\"%s\"", path);
struct {
int val;
diff --git a/tests-mx32/ioctl_kvm_run_common.c b/tests-mx32/ioctl_kvm_run_common.c
index 9107c30..be1190e 100644
--- a/tests-mx32/ioctl_kvm_run_common.c
+++ b/tests-mx32/ioctl_kvm_run_common.c
@@ -48,6 +48,7 @@
# define KVM_MAX_CPUID_ENTRIES 80
# endif
+# include "xmalloc.h"
# include "xlat.h"
# include "xlat/kvm_cpuid_flags.h"
@@ -254,12 +255,9 @@ static int
vcpu_dev_should_have_cpuid(int fd)
{
int r = 0;
- char *filename = NULL;
+ char *filename = xasprintf("/proc/%d/fd/%d", getpid(), fd);
char buf[sizeof(vcpu_dev)];
- if (asprintf(&filename, "/proc/%d/fd/%d", getpid(), fd) < 0)
- error_msg_and_fail("asprintf");
-
if (readlink(filename, buf, sizeof(buf)) == sizeof(buf) - 1
&& (memcmp(buf, vcpu_dev, sizeof(buf) - 1) == 0))
r = 1;
diff --git a/tests-mx32/keyctl.c b/tests-mx32/keyctl.c
index 6dc30fb..96ac197 100644
--- a/tests-mx32/keyctl.c
+++ b/tests-mx32/keyctl.c
@@ -11,6 +11,7 @@
#include "tests.h"
#include "scno.h"
+#include "xmalloc.h"
#ifdef __NR_keyctl
@@ -445,7 +446,6 @@ main(void)
struct iovec *key_iov = tail_alloc(sizeof(*key_iov) * IOV_SIZE);
char *bogus_buf1 = tail_alloc(9);
char *bogus_buf2 = tail_alloc(256);
- char *key_iov_str1;
char *key_iov_str2 = tail_alloc(4096);
const char *errstr;
ssize_t ret;
@@ -472,21 +472,18 @@ main(void)
0x100000001ULL * i);
}
- ret = asprintf(&key_iov_str1, "[{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}, "
- "{iov_base=%p, iov_len=%zu}]",
- key_iov[IOV_SIZE - 4].iov_base,
- key_iov[IOV_SIZE - 4].iov_len,
- key_iov[IOV_SIZE - 3].iov_base,
- key_iov[IOV_SIZE - 3].iov_len,
- key_iov[IOV_SIZE - 2].iov_base,
- key_iov[IOV_SIZE - 2].iov_len,
- key_iov[IOV_SIZE - 1].iov_base,
- key_iov[IOV_SIZE - 1].iov_len);
-
- if (ret < 0)
- error_msg_and_fail("asprintf");
+ char *key_iov_str1 = xasprintf("[{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}, "
+ "{iov_base=%p, iov_len=%zu}]",
+ key_iov[IOV_SIZE - 4].iov_base,
+ key_iov[IOV_SIZE - 4].iov_len,
+ key_iov[IOV_SIZE - 3].iov_base,
+ key_iov[IOV_SIZE - 3].iov_len,
+ key_iov[IOV_SIZE - 2].iov_base,
+ key_iov[IOV_SIZE - 2].iov_len,
+ key_iov[IOV_SIZE - 1].iov_base,
+ key_iov[IOV_SIZE - 1].iov_len);
ret = snprintf(key_iov_str2, IOV_STR_SIZE,
"[{iov_base=\"%s\\0\", iov_len=%zu}, "
diff --git a/tests-mx32/lock_file.c b/tests-mx32/lock_file.c
index 56cf112..7618552 100644
--- a/tests-mx32/lock_file.c
+++ b/tests-mx32/lock_file.c
@@ -6,6 +6,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <fcntl.h>
#include <stdio.h>
@@ -21,9 +22,7 @@ lock_file_by_dirname(const char *path_name, const char *lock_name)
const char *slash = path_name ? strrchr(path_name, '/') : NULL;
const int plen = slash ? (int) (slash - path_name) + 1 : 0;
- char *lock_file = NULL;
- if (asprintf(&lock_file, "%.*s%s", plen, path_name, lock_name) < 0)
- perror_msg_and_fail("asprintf");
+ char *lock_file = xasprintf("%.*s%s", plen, path_name, lock_name);
int lock_fd = open(lock_file, O_RDONLY);
if (lock_fd < 0)
diff --git a/tests-mx32/mq.c b/tests-mx32/mq.c
index a083e5a..7aa0914 100644
--- a/tests-mx32/mq.c
+++ b/tests-mx32/mq.c
@@ -17,6 +17,7 @@
# include <stdlib.h>
# include <unistd.h>
# include <sys/stat.h>
+# include "xmalloc.h"
int
main(void)
@@ -24,9 +25,7 @@ main(void)
struct mq_attr attr;
(void) close(0);
- char *name;
- if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
- perror_msg_and_fail("asprintf");
+ char *name = xasprintf("/strace-mq-%u.sample", getpid());
if (mq_open(name, O_CREAT, 0700, NULL))
perror_msg_and_skip("mq_open");
diff --git a/tests-mx32/mq_sendrecv.c b/tests-mx32/mq_sendrecv.c
index 45ddf5e..5a919c4 100644
--- a/tests-mx32/mq_sendrecv.c
+++ b/tests-mx32/mq_sendrecv.c
@@ -27,6 +27,7 @@
# include <time.h>
# include <unistd.h>
+# include "xmalloc.h"
# include "sigevent.h"
# ifndef DUMPIO_READ
@@ -407,8 +408,7 @@ main(void)
/* Sending and receiving test */
- if (asprintf(&mq_name, "strace-mq_sendrecv-%u.sample", getpid()) < 0)
- perror_msg_and_fail("asprintf");
+ mq_name = xasprintf("strace-mq_sendrecv-%u.sample", getpid());
# if DUMPIO_READ || DUMPIO_WRITE
close(0);
diff --git a/tests-mx32/netlink_protocol.c b/tests-mx32/netlink_protocol.c
index e632ba3..c37489f 100644
--- a/tests-mx32/netlink_protocol.c
+++ b/tests-mx32/netlink_protocol.c
@@ -22,6 +22,7 @@
# include "netlink.h"
# include <linux/sock_diag.h>
# include <linux/netlink_diag.h>
+# include "xmalloc.h"
static void
send_query(const int fd)
@@ -388,9 +389,7 @@ int main(void)
{
const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
- char *path;
- if (asprintf(&path, "/proc/self/fd/%u", fd) < 0)
- perror_msg_and_fail("asprintf");
+ char *path = xasprintf("/proc/self/fd/%u", fd);
char buf[256];
if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0)
perror_msg_and_skip("getxattr");
diff --git a/tests-mx32/old_mmap.c b/tests-mx32/old_mmap.c
index f095bc4..bb70359 100644
--- a/tests-mx32/old_mmap.c
+++ b/tests-mx32/old_mmap.c
@@ -27,6 +27,7 @@
# include <string.h>
# include <sys/mman.h>
# include <unistd.h>
+# include "xmalloc.h"
# ifndef TEST_FD
# define TEST_FD -2LU
@@ -82,9 +83,7 @@ main(void)
# ifndef PATH_TRACING
const char *errstr;
if (implemented) {
- char *str;
- if (asprintf(&str, "%#lx", rc) < 0)
- perror_msg_and_fail("asprintf");
+ char *str = xasprintf("%#lx", rc);
errstr = str;
} else {
errstr = sprintrc(rc);
diff --git a/tests-mx32/tracer_ppid_pgid_sid.c b/tests-mx32/tracer_ppid_pgid_sid.c
index 69687fa..ce9936d 100644
--- a/tests-mx32/tracer_ppid_pgid_sid.c
+++ b/tests-mx32/tracer_ppid_pgid_sid.c
@@ -8,6 +8,7 @@
*/
#include "tests.h"
+#include "xmalloc.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,10 +56,7 @@ get_tracer_pid(void)
static void
get_ppid_pgid_sid(int pid, int *ppid, int *pgid, int *sid)
{
- char *stat;
- if (asprintf(&stat, "/proc/%d/stat", pid) < 0)
- perror_msg_and_fail("asprintf");
-
+ char *stat = xasprintf("/proc/%d/stat", pid);
FILE *fp = fopen(stat, "r");
if (!fp)
perror_msg_and_fail("fopen: %s", stat);
--
2.1.4

View File

@ -1,276 +0,0 @@
From 5a8d3bab6f492b3932299d9e80fb247ab00b8102 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Sun, 7 Mar 2021 08:00:00 +0000
Subject: [PATCH 147/149] file_handle: print f_handle as a hexadecimal string
Printing the sequence of bytes as a hexadecimal number is misleading
because the latter depends on endianness.
* src/file_handle.c (print_f_handle): New function.
(SYS_FUNC(name_to_handle_at), SYS_FUNC(open_by_handle_at)): Use it
to print struct file_handle.f_handle.
* tests/file_handle.c (print_handle_data, do_open_by_handle_at, main):
Update expected output.
---
file_handle.c | 47 ++++++++++++++++++++++-------------------------
tests/file_handle.c | 26 +++++++++++---------------
2 files changed, 33 insertions(+), 40 deletions(-)
diff --git a/file_handle.c b/file_handle.c
index d82a1bc..343111f 100644
--- a/file_handle.c
+++ b/file_handle.c
@@ -19,6 +19,22 @@ typedef struct {
int handle_type;
} file_handle_header;
+static void
+print_f_handle(struct tcb *tcp, kernel_ulong_t addr, unsigned int handle_bytes)
+{
+ unsigned int len = MIN(handle_bytes, MAX_HANDLE_SZ);
+ char f_handle[MAX_HANDLE_SZ];
+ addr += sizeof(file_handle_header);
+ if (addr > sizeof(file_handle_header) &&
+ !umoven(tcp, addr, len, f_handle)) {
+ print_quoted_string(f_handle, len, QUOTE_FORCE_HEX);
+ if (handle_bytes > len)
+ tprints("...");
+ } else {
+ tprints("???");
+ }
+}
+
SYS_FUNC(name_to_handle_at)
{
file_handle_header h;
@@ -53,24 +69,15 @@ SYS_FUNC(name_to_handle_at)
return 0;
} else {
- unsigned int i = get_tcb_priv_ulong(tcp);
-
if ((!syserror(tcp) || EOVERFLOW == tcp->u_error)
&& !umove(tcp, addr, &h)) {
- unsigned char f_handle[MAX_HANDLE_SZ];
- if (i != h.handle_bytes)
+ if (h.handle_bytes != get_tcb_priv_ulong(tcp))
tprintf(" => %u", h.handle_bytes);
if (!syserror(tcp)) {
- tprintf(", handle_type=%d", h.handle_type);
- if (h.handle_bytes > MAX_HANDLE_SZ)
- h.handle_bytes = MAX_HANDLE_SZ;
- if (!umoven(tcp, addr + sizeof(h), h.handle_bytes,
- f_handle)) {
- tprints(", f_handle=0x");
- for (i = 0; i < h.handle_bytes; ++i)
- tprintf("%02x", f_handle[i]);
- }
+ tprintf(", handle_type=%d, f_handle=",
+ h.handle_type);
+ print_f_handle(tcp, addr, h.handle_bytes);
}
}
tprints("}, ");
@@ -96,19 +103,9 @@ SYS_FUNC(open_by_handle_at)
/* handle */
if (!umove_or_printaddr(tcp, addr, &h)) {
- unsigned char f_handle[MAX_HANDLE_SZ];
-
- tprintf("{handle_bytes=%u, handle_type=%d",
+ tprintf("{handle_bytes=%u, handle_type=%d, f_handle=",
h.handle_bytes, h.handle_type);
- if (h.handle_bytes > MAX_HANDLE_SZ)
- h.handle_bytes = MAX_HANDLE_SZ;
- if (!umoven(tcp, addr + sizeof(h), h.handle_bytes, &f_handle)) {
- unsigned int i;
-
- tprints(", f_handle=0x");
- for (i = 0; i < h.handle_bytes; ++i)
- tprintf("%02x", f_handle[i]);
- }
+ print_f_handle(tcp, addr, h.handle_bytes);
tprints("}");
}
tprints(", ");
diff --git a/tests/file_handle.c b/tests/file_handle.c
index edabde6..07af7ba 100644
--- a/tests/file_handle.c
+++ b/tests/file_handle.c
@@ -42,14 +42,10 @@ struct file_handle {
void
print_handle_data(unsigned char *bytes, unsigned int size)
{
- unsigned int i;
-
- if (size > MAX_HANDLE_SZ)
- size = MAX_HANDLE_SZ;
-
- printf("0x");
- for (i = 0; i < size; ++i)
- printf("%02x", bytes[i]);
+ unsigned int len = MIN(size, MAX_HANDLE_SZ);
+ print_quoted_hex(bytes, len);
+ if (size > len)
+ printf("...");
}
void
@@ -111,11 +107,13 @@ do_open_by_handle_at(kernel_ulong_t mount_fd,
printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
fh->handle_type);
+ printf(", f_handle=");
if (valid_data) {
- printf(", f_handle=");
print_handle_data((unsigned char *) fh +
sizeof(struct file_handle),
fh->handle_bytes);
+ } else {
+ printf("???");
}
printf("}");
@@ -275,16 +273,14 @@ main(void)
assert(syscall(__NR_name_to_handle_at, fdcwd, ".", handle, &mount_id,
flags) == 0);
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
- ", handle_type=%d, f_handle=0x",
+ ", handle_type=%d, f_handle=",
handle->handle_bytes, handle->handle_type);
- for (i = 0; i < handle->handle_bytes; ++i)
- printf("%02x", handle->f_handle[i]);
+ print_handle_data(handle->f_handle, handle->handle_bytes);
printf("}, [%d], AT_SYMLINK_FOLLOW) = 0\n", mount_id);
printf("open_by_handle_at(-1, {handle_bytes=%u, handle_type=%d"
- ", f_handle=0x", handle->handle_bytes, handle->handle_type);
- for (i = 0; i < handle->handle_bytes; ++i)
- printf("%02x", handle->f_handle[i]);
+ ", f_handle=", handle->handle_bytes, handle->handle_type);
+ print_handle_data(handle->f_handle, handle->handle_bytes);
int rc = syscall(__NR_open_by_handle_at, -1, handle,
O_RDONLY | O_DIRECTORY);
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
diff --git a/tests-m32/file_handle.c b/tests-m32/file_handle.c
index edabde6..07af7ba 100644
--- a/tests-m32/file_handle.c
+++ b/tests-m32/file_handle.c
@@ -42,14 +42,10 @@ struct file_handle {
void
print_handle_data(unsigned char *bytes, unsigned int size)
{
- unsigned int i;
-
- if (size > MAX_HANDLE_SZ)
- size = MAX_HANDLE_SZ;
-
- printf("0x");
- for (i = 0; i < size; ++i)
- printf("%02x", bytes[i]);
+ unsigned int len = MIN(size, MAX_HANDLE_SZ);
+ print_quoted_hex(bytes, len);
+ if (size > len)
+ printf("...");
}
void
@@ -111,11 +107,13 @@ do_open_by_handle_at(kernel_ulong_t mount_fd,
printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
fh->handle_type);
+ printf(", f_handle=");
if (valid_data) {
- printf(", f_handle=");
print_handle_data((unsigned char *) fh +
sizeof(struct file_handle),
fh->handle_bytes);
+ } else {
+ printf("???");
}
printf("}");
@@ -275,16 +273,14 @@ main(void)
assert(syscall(__NR_name_to_handle_at, fdcwd, ".", handle, &mount_id,
flags) == 0);
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
- ", handle_type=%d, f_handle=0x",
+ ", handle_type=%d, f_handle=",
handle->handle_bytes, handle->handle_type);
- for (i = 0; i < handle->handle_bytes; ++i)
- printf("%02x", handle->f_handle[i]);
+ print_handle_data(handle->f_handle, handle->handle_bytes);
printf("}, [%d], AT_SYMLINK_FOLLOW) = 0\n", mount_id);
printf("open_by_handle_at(-1, {handle_bytes=%u, handle_type=%d"
- ", f_handle=0x", handle->handle_bytes, handle->handle_type);
- for (i = 0; i < handle->handle_bytes; ++i)
- printf("%02x", handle->f_handle[i]);
+ ", f_handle=", handle->handle_bytes, handle->handle_type);
+ print_handle_data(handle->f_handle, handle->handle_bytes);
int rc = syscall(__NR_open_by_handle_at, -1, handle,
O_RDONLY | O_DIRECTORY);
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
diff --git a/tests-mx32/file_handle.c b/tests-mx32/file_handle.c
index edabde6..07af7ba 100644
--- a/tests-mx32/file_handle.c
+++ b/tests-mx32/file_handle.c
@@ -42,14 +42,10 @@ struct file_handle {
void
print_handle_data(unsigned char *bytes, unsigned int size)
{
- unsigned int i;
-
- if (size > MAX_HANDLE_SZ)
- size = MAX_HANDLE_SZ;
-
- printf("0x");
- for (i = 0; i < size; ++i)
- printf("%02x", bytes[i]);
+ unsigned int len = MIN(size, MAX_HANDLE_SZ);
+ print_quoted_hex(bytes, len);
+ if (size > len)
+ printf("...");
}
void
@@ -111,11 +107,13 @@ do_open_by_handle_at(kernel_ulong_t mount_fd,
printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
fh->handle_type);
+ printf(", f_handle=");
if (valid_data) {
- printf(", f_handle=");
print_handle_data((unsigned char *) fh +
sizeof(struct file_handle),
fh->handle_bytes);
+ } else {
+ printf("???");
}
printf("}");
@@ -275,16 +273,14 @@ main(void)
assert(syscall(__NR_name_to_handle_at, fdcwd, ".", handle, &mount_id,
flags) == 0);
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
- ", handle_type=%d, f_handle=0x",
+ ", handle_type=%d, f_handle=",
handle->handle_bytes, handle->handle_type);
- for (i = 0; i < handle->handle_bytes; ++i)
- printf("%02x", handle->f_handle[i]);
+ print_handle_data(handle->f_handle, handle->handle_bytes);
printf("}, [%d], AT_SYMLINK_FOLLOW) = 0\n", mount_id);
printf("open_by_handle_at(-1, {handle_bytes=%u, handle_type=%d"
- ", f_handle=0x", handle->handle_bytes, handle->handle_type);
- for (i = 0; i < handle->handle_bytes; ++i)
- printf("%02x", handle->f_handle[i]);
+ ", f_handle=", handle->handle_bytes, handle->handle_type);
+ print_handle_data(handle->f_handle, handle->handle_bytes);
int rc = syscall(__NR_open_by_handle_at, -1, handle,
O_RDONLY | O_DIRECTORY);
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
--
2.1.4

View File

@ -1,486 +0,0 @@
From 1ec648999d3bf01ae87cac65c810d5d8f19c71c0 Mon Sep 17 00:00:00 2001
From: Sven Schnelle <svens@stackframe.org>
Date: Tue, 10 Nov 2020 07:38:34 +0100
Subject: [PATCH 148/149] tests: fix execve test with fresh linux kernels
Starting with Linux commit v5.9-rc1~164^2^2~2, execve copies syscall
arguments before trying to find the executable, failing with EFAULT
in case of a faulty address. Adjust the test to handle both variants
of execve behaviour.
* tests/execve.c (errstr): New variable.
(call_execve): New function.
(main): Use it instead of execve. Do not hardcode ENOENT in expected
output of tests, use errstr instead.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
tests/execve.c | 54 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/tests/execve.c b/tests/execve.c
index 2f6ae52..961d284 100644
--- a/tests/execve.c
+++ b/tests/execve.c
@@ -12,6 +12,16 @@
#include <stdio.h>
#include <unistd.h>
+static const char *errstr;
+
+static int
+call_execve(const char *pathname, char *const *argv, char *const *envp)
+{
+ int rc = execve(pathname, argv, envp);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
#define FILENAME "test.execve\nfilename"
#define Q_FILENAME "test.execve\\nfilename"
@@ -43,7 +53,7 @@ main(void)
char ** const tail_argv = tail_memdup(argv, sizeof(argv));
char ** const tail_envp = tail_memdup(envp, sizeof(envp));
- execve(FILENAME, tail_argv, tail_envp);
+ call_execve(FILENAME, tail_argv, tail_envp);
printf("execve(\"%s\""
", [\"%s\", \"%s\", \"%s\", %p, %p, %p, ... /* %p */]"
#if VERBOSE
@@ -51,7 +61,7 @@ main(void)
#else
", %p /* 5 vars, unterminated */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
#if VERBOSE
@@ -60,60 +70,60 @@ main(void)
#else
, tail_envp
#endif
- );
+ , errstr);
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
(void) q_envp; /* workaround for clang bug #33068 */
- execve(FILENAME, tail_argv, tail_envp);
+ call_execve(FILENAME, tail_argv, tail_envp);
printf("execve(\"%s\", [\"%s\", \"%s\", \"%s\"]"
#if VERBOSE
", [\"%s\", \"%s\"]"
#else
", %p /* 2 vars */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
#if VERBOSE
, q_envp[0], q_envp[1]
#else
, tail_envp
#endif
- );
+ , errstr);
- execve(FILENAME, tail_argv + 2, tail_envp + 1);
+ call_execve(FILENAME, tail_argv + 2, tail_envp + 1);
printf("execve(\"%s\", [\"%s\"]"
#if VERBOSE
", [\"%s\"]"
#else
", %p /* 1 var */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[2]
#if VERBOSE
, q_envp[1]
#else
, tail_envp + 1
#endif
- );
+ , errstr);
TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
char **const efault = empty + 1;
*empty = NULL;
- execve(FILENAME, empty, empty);
+ call_execve(FILENAME, empty, empty);
printf("execve(\"%s\", []"
#if VERBOSE
", []"
#else
", %p /* 0 vars */"
#endif
- ") = -1 ENOENT (%m)\n", Q_FILENAME
+ ") = %s\n", Q_FILENAME
#if !VERBOSE
, empty
#endif
- );
+ , errstr);
char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
@@ -132,7 +142,7 @@ main(void)
}
a[i] = b[i] = NULL;
- execve(FILENAME, a, b);
+ call_execve(FILENAME, a, b);
printf("execve(\"%s\", [\"%.*s\"...", Q_FILENAME, DEFAULT_STRLEN, a[0]);
for (i = 1; i < DEFAULT_STRLEN; ++i)
printf(", \"%s\"", a[i]);
@@ -149,9 +159,9 @@ main(void)
#else
printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
#endif
- printf(") = -1 ENOENT (%m)\n");
+ printf(") = %s\n", errstr);
- execve(FILENAME, a + 1, b + 1);
+ call_execve(FILENAME, a + 1, b + 1);
printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
for (i = 2; i <= DEFAULT_STRLEN; ++i)
printf(", \"%s\"", a[i]);
@@ -163,15 +173,15 @@ main(void)
#else
printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
#endif
- printf(") = -1 ENOENT (%m)\n");
+ printf(") = %s\n", errstr);
- execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
- printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
- Q_FILENAME, efault);
+ call_execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
+ printf("execve(\"%s\", NULL, %p) = %s\n",
+ Q_FILENAME, efault, errstr);
- execve(FILENAME, efault, NULL);
- printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
- Q_FILENAME, efault);
+ call_execve(FILENAME, efault, NULL);
+ printf("execve(\"%s\", %p, NULL) = %s\n",
+ Q_FILENAME, efault, errstr);
leave_and_remove_subdir();
diff --git a/tests-m32/execve.c b/tests-m32/execve.c
index 2f6ae52..961d284 100644
--- a/tests-m32/execve.c
+++ b/tests-m32/execve.c
@@ -12,6 +12,16 @@
#include <stdio.h>
#include <unistd.h>
+static const char *errstr;
+
+static int
+call_execve(const char *pathname, char *const *argv, char *const *envp)
+{
+ int rc = execve(pathname, argv, envp);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
#define FILENAME "test.execve\nfilename"
#define Q_FILENAME "test.execve\\nfilename"
@@ -43,7 +53,7 @@ main(void)
char ** const tail_argv = tail_memdup(argv, sizeof(argv));
char ** const tail_envp = tail_memdup(envp, sizeof(envp));
- execve(FILENAME, tail_argv, tail_envp);
+ call_execve(FILENAME, tail_argv, tail_envp);
printf("execve(\"%s\""
", [\"%s\", \"%s\", \"%s\", %p, %p, %p, ... /* %p */]"
#if VERBOSE
@@ -51,7 +61,7 @@ main(void)
#else
", %p /* 5 vars, unterminated */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
#if VERBOSE
@@ -60,60 +70,60 @@ main(void)
#else
, tail_envp
#endif
- );
+ , errstr);
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
(void) q_envp; /* workaround for clang bug #33068 */
- execve(FILENAME, tail_argv, tail_envp);
+ call_execve(FILENAME, tail_argv, tail_envp);
printf("execve(\"%s\", [\"%s\", \"%s\", \"%s\"]"
#if VERBOSE
", [\"%s\", \"%s\"]"
#else
", %p /* 2 vars */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
#if VERBOSE
, q_envp[0], q_envp[1]
#else
, tail_envp
#endif
- );
+ , errstr);
- execve(FILENAME, tail_argv + 2, tail_envp + 1);
+ call_execve(FILENAME, tail_argv + 2, tail_envp + 1);
printf("execve(\"%s\", [\"%s\"]"
#if VERBOSE
", [\"%s\"]"
#else
", %p /* 1 var */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[2]
#if VERBOSE
, q_envp[1]
#else
, tail_envp + 1
#endif
- );
+ , errstr);
TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
char **const efault = empty + 1;
*empty = NULL;
- execve(FILENAME, empty, empty);
+ call_execve(FILENAME, empty, empty);
printf("execve(\"%s\", []"
#if VERBOSE
", []"
#else
", %p /* 0 vars */"
#endif
- ") = -1 ENOENT (%m)\n", Q_FILENAME
+ ") = %s\n", Q_FILENAME
#if !VERBOSE
, empty
#endif
- );
+ , errstr);
char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
@@ -132,7 +142,7 @@ main(void)
}
a[i] = b[i] = NULL;
- execve(FILENAME, a, b);
+ call_execve(FILENAME, a, b);
printf("execve(\"%s\", [\"%.*s\"...", Q_FILENAME, DEFAULT_STRLEN, a[0]);
for (i = 1; i < DEFAULT_STRLEN; ++i)
printf(", \"%s\"", a[i]);
@@ -149,9 +159,9 @@ main(void)
#else
printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
#endif
- printf(") = -1 ENOENT (%m)\n");
+ printf(") = %s\n", errstr);
- execve(FILENAME, a + 1, b + 1);
+ call_execve(FILENAME, a + 1, b + 1);
printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
for (i = 2; i <= DEFAULT_STRLEN; ++i)
printf(", \"%s\"", a[i]);
@@ -163,15 +173,15 @@ main(void)
#else
printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
#endif
- printf(") = -1 ENOENT (%m)\n");
+ printf(") = %s\n", errstr);
- execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
- printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
- Q_FILENAME, efault);
+ call_execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
+ printf("execve(\"%s\", NULL, %p) = %s\n",
+ Q_FILENAME, efault, errstr);
- execve(FILENAME, efault, NULL);
- printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
- Q_FILENAME, efault);
+ call_execve(FILENAME, efault, NULL);
+ printf("execve(\"%s\", %p, NULL) = %s\n",
+ Q_FILENAME, efault, errstr);
leave_and_remove_subdir();
diff --git a/tests-mx32/execve.c b/tests-mx32/execve.c
index 2f6ae52..961d284 100644
--- a/tests-mx32/execve.c
+++ b/tests-mx32/execve.c
@@ -12,6 +12,16 @@
#include <stdio.h>
#include <unistd.h>
+static const char *errstr;
+
+static int
+call_execve(const char *pathname, char *const *argv, char *const *envp)
+{
+ int rc = execve(pathname, argv, envp);
+ errstr = sprintrc(rc);
+ return rc;
+}
+
#define FILENAME "test.execve\nfilename"
#define Q_FILENAME "test.execve\\nfilename"
@@ -43,7 +53,7 @@ main(void)
char ** const tail_argv = tail_memdup(argv, sizeof(argv));
char ** const tail_envp = tail_memdup(envp, sizeof(envp));
- execve(FILENAME, tail_argv, tail_envp);
+ call_execve(FILENAME, tail_argv, tail_envp);
printf("execve(\"%s\""
", [\"%s\", \"%s\", \"%s\", %p, %p, %p, ... /* %p */]"
#if VERBOSE
@@ -51,7 +61,7 @@ main(void)
#else
", %p /* 5 vars, unterminated */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
#if VERBOSE
@@ -60,60 +70,60 @@ main(void)
#else
, tail_envp
#endif
- );
+ , errstr);
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
(void) q_envp; /* workaround for clang bug #33068 */
- execve(FILENAME, tail_argv, tail_envp);
+ call_execve(FILENAME, tail_argv, tail_envp);
printf("execve(\"%s\", [\"%s\", \"%s\", \"%s\"]"
#if VERBOSE
", [\"%s\", \"%s\"]"
#else
", %p /* 2 vars */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
#if VERBOSE
, q_envp[0], q_envp[1]
#else
, tail_envp
#endif
- );
+ , errstr);
- execve(FILENAME, tail_argv + 2, tail_envp + 1);
+ call_execve(FILENAME, tail_argv + 2, tail_envp + 1);
printf("execve(\"%s\", [\"%s\"]"
#if VERBOSE
", [\"%s\"]"
#else
", %p /* 1 var */"
#endif
- ") = -1 ENOENT (%m)\n",
+ ") = %s\n",
Q_FILENAME, q_argv[2]
#if VERBOSE
, q_envp[1]
#else
, tail_envp + 1
#endif
- );
+ , errstr);
TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
char **const efault = empty + 1;
*empty = NULL;
- execve(FILENAME, empty, empty);
+ call_execve(FILENAME, empty, empty);
printf("execve(\"%s\", []"
#if VERBOSE
", []"
#else
", %p /* 0 vars */"
#endif
- ") = -1 ENOENT (%m)\n", Q_FILENAME
+ ") = %s\n", Q_FILENAME
#if !VERBOSE
, empty
#endif
- );
+ , errstr);
char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
@@ -132,7 +142,7 @@ main(void)
}
a[i] = b[i] = NULL;
- execve(FILENAME, a, b);
+ call_execve(FILENAME, a, b);
printf("execve(\"%s\", [\"%.*s\"...", Q_FILENAME, DEFAULT_STRLEN, a[0]);
for (i = 1; i < DEFAULT_STRLEN; ++i)
printf(", \"%s\"", a[i]);
@@ -149,9 +159,9 @@ main(void)
#else
printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
#endif
- printf(") = -1 ENOENT (%m)\n");
+ printf(") = %s\n", errstr);
- execve(FILENAME, a + 1, b + 1);
+ call_execve(FILENAME, a + 1, b + 1);
printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
for (i = 2; i <= DEFAULT_STRLEN; ++i)
printf(", \"%s\"", a[i]);
@@ -163,15 +173,15 @@ main(void)
#else
printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
#endif
- printf(") = -1 ENOENT (%m)\n");
+ printf(") = %s\n", errstr);
- execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
- printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
- Q_FILENAME, efault);
+ call_execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
+ printf("execve(\"%s\", NULL, %p) = %s\n",
+ Q_FILENAME, efault, errstr);
- execve(FILENAME, efault, NULL);
- printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
- Q_FILENAME, efault);
+ call_execve(FILENAME, efault, NULL);
+ printf("execve(\"%s\", %p, NULL) = %s\n",
+ Q_FILENAME, efault, errstr);
leave_and_remove_subdir();
--
2.1.4

View File

@ -1,86 +0,0 @@
From bbe5eefaa928449de5994c5288a7c85fae54f716 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Sat, 31 Jul 2021 15:17:41 +0200
Subject: [PATCH] m4/mpers.m4: generate HAVE_*_SELINUX_RUNTIME config defines
While bootstrap has some provisions for mangling HAVE_SELINUX_RUNTIME
into HAVE_{M32,MX32}_SELINUX_RUNTIME, and there is logic for checking
SELinux runtime presence in non-native personalities, the relevant
configuration definition is not ultimately generated, as it has to be
defined explicitly, similarly to HAVE_*_MPERS.
* m4/mpers.m4 (st_MPERS) [$st_cv_selinux_runtime == yes]: AC_DEFINE
HAVE_SELINUX_RUNTIME.
Complements: v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
---
m4/mpers.m4 | 4 ++++
1 file changed, 4 insertions(+)
Index: strace-5.7/m4/mpers.m4
===================================================================
--- strace-5.7.orig/m4/mpers.m4 2021-08-24 21:08:43.252246052 +0200
+++ strace-5.7/m4/mpers.m4 2021-08-24 21:26:07.436408149 +0200
@@ -179,6 +179,10 @@
popdef([SIZEOF_STRUCT_MSQID64_DS])
fi
fi
+ if test "x$st_cv_selinux_runtime" = xyes; then
+ AC_DEFINE([HAVE_SELINUX_RUNTIME], [1],
+ [Define to enable SELinux security contexts testing for ]mpers_name[ personality])
+ fi
fi
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
Index: strace-5.7/config.h.in
===================================================================
--- strace-5.7.orig/config.h.in 2021-08-24 21:08:43.304245612 +0200
+++ strace-5.7/config.h.in 2021-08-24 21:26:07.437408141 +0200
@@ -2181,6 +2181,9 @@
/* Define to 1 if you have mpers_name mpers support */
#undef HAVE_M32_MPERS
+/* Define to enable SELinux security contexts testing for m32 personality */
+#undef HAVE_M32_SELINUX_RUNTIME
+
/* Define to 1 if m32 has the type 'struct stat'. */
#undef HAVE_M32_STRUCT_STAT
@@ -2202,6 +2205,9 @@
/* Define to 1 if you have mpers_name mpers support */
#undef HAVE_MX32_MPERS
+/* Define to enable SELinux security contexts testing for mx32 personality */
+#undef HAVE_MX32_SELINUX_RUNTIME
+
/* Define to 1 if mx32 has the type 'struct stat'. */
#undef HAVE_MX32_STRUCT_STAT
Index: strace-5.7/configure
===================================================================
--- strace-5.7.orig/configure 2021-08-24 21:08:43.315245519 +0200
+++ strace-5.7/configure 2021-08-24 21:26:07.439408124 +0200
@@ -23632,6 +23632,11 @@
fi
fi
+ if test "x$st_cv_m32_selinux_runtime" = xyes; then
+
+$as_echo "#define HAVE_M32_SELINUX_RUNTIME 1" >>confdefs.h
+
+ fi
fi
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
@@ -24314,6 +24319,11 @@
fi
fi
+ if test "x$st_cv_mx32_selinux_runtime" = xyes; then
+
+$as_echo "#define HAVE_MX32_SELINUX_RUNTIME 1" >>confdefs.h
+
+ fi
fi
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"

View File

@ -1,209 +0,0 @@
From 21bbf3a53b8be9b3fe90bcdb66c7ded35bc3e344 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 12 Sep 2020 08:00:00 +0000
Subject: [PATCH 156/162] Introduce GLIBC_PREREQ_GE and GLIBC_PREREQ_LT macros
* gcc_compat.h (GLIBC_PREREQ_GE, GLIBC_PREREQ_LT): New macros.
* tests/ipc_msg.c: Use GLIBC_PREREQ_LT instead of manual checking
for __GLIBC__ and __GLIBC_MINOR__.
* tests/readahead.c: Likewise.
---
gcc_compat.h | 15 +++++++++++++++
tests/ipc_msg.c | 9 +++------
tests/readahead.c | 16 ++++++----------
3 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/gcc_compat.h b/gcc_compat.h
index 0525b5e..4c23ebc 100644
--- a/gcc_compat.h
+++ b/gcc_compat.h
@@ -23,6 +23,21 @@
# define CLANG_PREREQ(maj, min) 0
# endif
+# ifdef __GLIBC__
+# ifdef __GLIBC_MINOR__
+# define GLIBC_PREREQ_GE(maj, min) \
+ ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
+# define GLIBC_PREREQ_LT(maj, min) \
+ ((__GLIBC__ << 16) + __GLIBC_MINOR__ < ((maj) << 16) + (min))
+# else /* !__GLIBC_MINOR__ */
+# define GLIBC_PREREQ_GE(maj, min) 0
+# define GLIBC_PREREQ_LT(maj, min) 1
+# endif
+# else /* !__GLIBC__ */
+# define GLIBC_PREREQ_GE(maj, min) 0
+# define GLIBC_PREREQ_LT(maj, min) 0
+# endif
+
# if !(GNUC_PREREQ(2, 0) || CLANG_PREREQ(1, 0))
# define __attribute__(x) /* empty */
# endif
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
index 63bdd77..dd0f303 100644
--- a/tests/ipc_msg.c
+++ b/tests/ipc_msg.c
@@ -26,12 +26,9 @@
* which led to segmentation fault.
*/
#undef TEST_MSGCTL_BOGUS_ADDR
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
-# if !(defined __GLIBC_MINOR__) \
- || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
-# define TEST_MSGCTL_BOGUS_ADDR 0
-# endif
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
#ifndef TEST_MSGCTL_BOGUS_ADDR
# define TEST_MSGCTL_BOGUS_ADDR 1
diff --git a/tests/readahead.c b/tests/readahead.c
index 86d09b0..6f4b81e 100644
--- a/tests/readahead.c
+++ b/tests/readahead.c
@@ -11,24 +11,20 @@
#ifdef HAVE_READAHEAD
/* Check for glibc readahead argument passing bugs. */
-# ifdef __GLIBC__
/*
* glibc < 2.8 had an incorrect order of higher and lower parts of offset,
* see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
*/
-# if !(defined __GLIBC_MINOR__ && \
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
-# undef HAVE_READAHEAD
-# endif /* glibc < 2.8 */
+# if GLIBC_PREREQ_LT(2, 8)
+# undef HAVE_READAHEAD
+# endif /* glibc < 2.8 */
/*
* glibc < 2.25 had an incorrect implementation on mips n64,
* see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
*/
-# if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
-# undef HAVE_READAHEAD
-# endif /* LINUX_MIPSN64 && glibc < 2.25 */
-# endif /* __GLIBC__ */
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
+# undef HAVE_READAHEAD
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
#endif /* HAVE_READAHEAD */
#ifdef HAVE_READAHEAD
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
index 63bdd77..dd0f303 100644
--- a/tests-m32/ipc_msg.c
+++ b/tests-m32/ipc_msg.c
@@ -26,12 +26,9 @@
* which led to segmentation fault.
*/
#undef TEST_MSGCTL_BOGUS_ADDR
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
-# if !(defined __GLIBC_MINOR__) \
- || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
-# define TEST_MSGCTL_BOGUS_ADDR 0
-# endif
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
#ifndef TEST_MSGCTL_BOGUS_ADDR
# define TEST_MSGCTL_BOGUS_ADDR 1
diff --git a/tests-m32/readahead.c b/tests-m32/readahead.c
index 86d09b0..6f4b81e 100644
--- a/tests-m32/readahead.c
+++ b/tests-m32/readahead.c
@@ -11,24 +11,20 @@
#ifdef HAVE_READAHEAD
/* Check for glibc readahead argument passing bugs. */
-# ifdef __GLIBC__
/*
* glibc < 2.8 had an incorrect order of higher and lower parts of offset,
* see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
*/
-# if !(defined __GLIBC_MINOR__ && \
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
-# undef HAVE_READAHEAD
-# endif /* glibc < 2.8 */
+# if GLIBC_PREREQ_LT(2, 8)
+# undef HAVE_READAHEAD
+# endif /* glibc < 2.8 */
/*
* glibc < 2.25 had an incorrect implementation on mips n64,
* see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
*/
-# if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
-# undef HAVE_READAHEAD
-# endif /* LINUX_MIPSN64 && glibc < 2.25 */
-# endif /* __GLIBC__ */
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
+# undef HAVE_READAHEAD
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
#endif /* HAVE_READAHEAD */
#ifdef HAVE_READAHEAD
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
index 63bdd77..dd0f303 100644
--- a/tests-mx32/ipc_msg.c
+++ b/tests-mx32/ipc_msg.c
@@ -26,12 +26,9 @@
* which led to segmentation fault.
*/
#undef TEST_MSGCTL_BOGUS_ADDR
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
-# if !(defined __GLIBC_MINOR__) \
- || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
-# define TEST_MSGCTL_BOGUS_ADDR 0
-# endif
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
#ifndef TEST_MSGCTL_BOGUS_ADDR
# define TEST_MSGCTL_BOGUS_ADDR 1
diff --git a/tests-mx32/readahead.c b/tests-mx32/readahead.c
index 86d09b0..6f4b81e 100644
--- a/tests-mx32/readahead.c
+++ b/tests-mx32/readahead.c
@@ -11,24 +11,20 @@
#ifdef HAVE_READAHEAD
/* Check for glibc readahead argument passing bugs. */
-# ifdef __GLIBC__
/*
* glibc < 2.8 had an incorrect order of higher and lower parts of offset,
* see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
*/
-# if !(defined __GLIBC_MINOR__ && \
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
-# undef HAVE_READAHEAD
-# endif /* glibc < 2.8 */
+# if GLIBC_PREREQ_LT(2, 8)
+# undef HAVE_READAHEAD
+# endif /* glibc < 2.8 */
/*
* glibc < 2.25 had an incorrect implementation on mips n64,
* see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
*/
-# if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
-# undef HAVE_READAHEAD
-# endif /* LINUX_MIPSN64 && glibc < 2.25 */
-# endif /* __GLIBC__ */
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
+# undef HAVE_READAHEAD
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
#endif /* HAVE_READAHEAD */
#ifdef HAVE_READAHEAD
--
2.1.4

View File

@ -1,103 +0,0 @@
From af1e2888699afc985d7f354b875c517531dff4ea Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 12 Sep 2020 08:00:00 +0000
Subject: [PATCH 157/162] tests/ipc_msg.c: disable TEST_MSGCTL_BOGUS_ADDR on
glibc >= 2.32
Starting with commit glibc-2.32~83, on every 32-bit architecture where
32-bit time_t support is enabled, glibc tries to retrieve the data
provided in the third argument of msgctl call. This results to
segfaults inside glibc if TEST_MSGCTL_BOGUS_ADDR is enabled.
* tests/ipc_msg.c [GLIBC_PREREQ_GE(2, 32) && __TIMESIZE != 64]
(TEST_MSGCTL_BOGUS_ADDR): Define to 0.
Reported-by: Ruinland ChuanTzu Tsai <ruinland@andestech.com>
---
tests/ipc_msg.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
index dd0f303..3ab8b90 100644
--- a/tests/ipc_msg.c
+++ b/tests/ipc_msg.c
@@ -20,12 +20,21 @@
# define MSG_STAT_ANY 13
#endif
+#undef TEST_MSGCTL_BOGUS_ADDR
+
+/*
+ * Starting with commit glibc-2.32~83, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of msgctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
/*
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
* provided in third argument of msgctl call (in case of IPC_SET cmd)
* which led to segmentation fault.
*/
-#undef TEST_MSGCTL_BOGUS_ADDR
#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
index dd0f303..3ab8b90 100644
--- a/tests-m32/ipc_msg.c
+++ b/tests-m32/ipc_msg.c
@@ -20,12 +20,21 @@
# define MSG_STAT_ANY 13
#endif
+#undef TEST_MSGCTL_BOGUS_ADDR
+
+/*
+ * Starting with commit glibc-2.32~83, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of msgctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
/*
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
* provided in third argument of msgctl call (in case of IPC_SET cmd)
* which led to segmentation fault.
*/
-#undef TEST_MSGCTL_BOGUS_ADDR
#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
index dd0f303..3ab8b90 100644
--- a/tests-mx32/ipc_msg.c
+++ b/tests-mx32/ipc_msg.c
@@ -20,12 +20,21 @@
# define MSG_STAT_ANY 13
#endif
+#undef TEST_MSGCTL_BOGUS_ADDR
+
+/*
+ * Starting with commit glibc-2.32~83, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of msgctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
/*
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
* provided in third argument of msgctl call (in case of IPC_SET cmd)
* which led to segmentation fault.
*/
-#undef TEST_MSGCTL_BOGUS_ADDR
#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
--
2.1.4

View File

@ -1,89 +0,0 @@
From b4623939316807928680913ece9a6cefc23a73b2 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Tue, 10 Nov 2020 08:00:00 +0000
Subject: [PATCH 158/162] tests: disable TEST_MSGCTL_BOGUS_ADDR in ipc_msg test
on glibc >= 2.31
Starting with commit glibc-2.31~358, on every architecture where
__ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify the
data provided in the third argument of msgctl call. This results
to segfaults inside glibc if TEST_MSGCTL_BOGUS_ADDR is enabled.
* tests/ipc_msg.c [GLIBC_PREREQ_GE(2, 31) && (__m68k__ || __s390__ ||
(WORDS_BIGENDIAN && (__arm__ || __microblaze__ || __sh__)))]
(TEST_MSGCTL_BOGUS_ADDR): Define to 0.
Reported-by: Sven Schnelle <svens@linux.ibm.com>
---
tests/ipc_msg.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
index 3ab8b90..f7c36cd 100644
--- a/tests/ipc_msg.c
+++ b/tests/ipc_msg.c
@@ -31,6 +31,17 @@
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
/*
+ * Starting with commit glibc-2.31~358, on every architecture where
+ * __ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify
+ * the data provided in the third argument of msgctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 31) && \
+ (defined __m68k__ || defined __s390__ || \
+ (WORDS_BIGENDIAN && \
+ (defined __arm__ || defined __microblaze__ || defined __sh__)))
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
+/*
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
* provided in third argument of msgctl call (in case of IPC_SET cmd)
* which led to segmentation fault.
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
index 3ab8b90..f7c36cd 100644
--- a/tests-m32/ipc_msg.c
+++ b/tests-m32/ipc_msg.c
@@ -31,6 +31,17 @@
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
/*
+ * Starting with commit glibc-2.31~358, on every architecture where
+ * __ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify
+ * the data provided in the third argument of msgctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 31) && \
+ (defined __m68k__ || defined __s390__ || \
+ (WORDS_BIGENDIAN && \
+ (defined __arm__ || defined __microblaze__ || defined __sh__)))
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
+/*
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
* provided in third argument of msgctl call (in case of IPC_SET cmd)
* which led to segmentation fault.
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
index 3ab8b90..f7c36cd 100644
--- a/tests-mx32/ipc_msg.c
+++ b/tests-mx32/ipc_msg.c
@@ -31,6 +31,17 @@
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
/*
+ * Starting with commit glibc-2.31~358, on every architecture where
+ * __ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify
+ * the data provided in the third argument of msgctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 31) && \
+ (defined __m68k__ || defined __s390__ || \
+ (WORDS_BIGENDIAN && \
+ (defined __arm__ || defined __microblaze__ || defined __sh__)))
+# define TEST_MSGCTL_BOGUS_ADDR 0
+#endif
+/*
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
* provided in third argument of msgctl call (in case of IPC_SET cmd)
* which led to segmentation fault.
--
2.1.4

View File

@ -1,214 +0,0 @@
From b702ddfd448794f3ac5033c897a07da3de8f5fc7 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sun, 6 Dec 2020 08:00:00 +0000
Subject: [PATCH 159/162] tests: disable tests for invalid msgctl commands on
glibc >= 2.32
Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
glibc skips msgctl syscall invocations and returns EINVAL
for invalid msgctl commands.
* tests/ipc_msg.c [GLIBC_PREREQ_GE(2, 32)] (TEST_MSGCTL_BOGUS_CMD):
Define to 0.
[!TEST_MSGCTL_BOGUS_CMD] (TEST_MSGCTL_BOGUS_CMD): Define to 1.
(main) [!TEST_MSGCTL_BOGUS_CMD] (bogus_cmd): Do not define and do not
use.
---
tests/ipc_msg.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
index f7c36cd..6a96a5f 100644
--- a/tests/ipc_msg.c
+++ b/tests/ipc_msg.c
@@ -21,6 +21,7 @@
#endif
#undef TEST_MSGCTL_BOGUS_ADDR
+#undef TEST_MSGCTL_BOGUS_CMD
/*
* Starting with commit glibc-2.32~83, on every 32-bit architecture
@@ -50,9 +51,21 @@
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
+/*
+ * Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
+ * glibc skips msgctl syscall invocations and returns EINVAL
+ * for invalid msgctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_MSGCTL_BOGUS_CMD 0
+#endif
+
#ifndef TEST_MSGCTL_BOGUS_ADDR
# define TEST_MSGCTL_BOGUS_ADDR 1
#endif
+#ifndef TEST_MSGCTL_BOGUS_CMD
+# define TEST_MSGCTL_BOGUS_CMD 1
+#endif
#if XLAT_RAW
# define str_ipc_excl_nowait "0xface1c00"
@@ -107,12 +120,16 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb9f531ULL;
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
+#if TEST_MSGCTL_BOGUS_CMD || TEST_MSGCTL_BOGUS_ADDR
static const int bogus_msgid = 0xfdb97531;
+#endif
+#if TEST_MSGCTL_BOGUS_CMD
static const int bogus_cmd = 0xdeadbeef;
+#endif
#if TEST_MSGCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
- static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
int rc;
struct msqid_ds ds;
@@ -129,9 +146,11 @@ main(void)
printf("msgget\\(%s, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_MSGCTL_BOGUS_CMD
rc = msgctl(bogus_msgid, bogus_cmd, NULL);
printf("msgctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_msgid, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_MSGCTL_BOGUS_ADDR
rc = msgctl(bogus_msgid, IPC_SET, bogus_addr);
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
index f7c36cd..6a96a5f 100644
--- a/tests-m32/ipc_msg.c
+++ b/tests-m32/ipc_msg.c
@@ -21,6 +21,7 @@
#endif
#undef TEST_MSGCTL_BOGUS_ADDR
+#undef TEST_MSGCTL_BOGUS_CMD
/*
* Starting with commit glibc-2.32~83, on every 32-bit architecture
@@ -50,9 +51,21 @@
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
+/*
+ * Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
+ * glibc skips msgctl syscall invocations and returns EINVAL
+ * for invalid msgctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_MSGCTL_BOGUS_CMD 0
+#endif
+
#ifndef TEST_MSGCTL_BOGUS_ADDR
# define TEST_MSGCTL_BOGUS_ADDR 1
#endif
+#ifndef TEST_MSGCTL_BOGUS_CMD
+# define TEST_MSGCTL_BOGUS_CMD 1
+#endif
#if XLAT_RAW
# define str_ipc_excl_nowait "0xface1c00"
@@ -107,12 +120,16 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb9f531ULL;
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
+#if TEST_MSGCTL_BOGUS_CMD || TEST_MSGCTL_BOGUS_ADDR
static const int bogus_msgid = 0xfdb97531;
+#endif
+#if TEST_MSGCTL_BOGUS_CMD
static const int bogus_cmd = 0xdeadbeef;
+#endif
#if TEST_MSGCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
- static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
int rc;
struct msqid_ds ds;
@@ -129,9 +146,11 @@ main(void)
printf("msgget\\(%s, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_MSGCTL_BOGUS_CMD
rc = msgctl(bogus_msgid, bogus_cmd, NULL);
printf("msgctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_msgid, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_MSGCTL_BOGUS_ADDR
rc = msgctl(bogus_msgid, IPC_SET, bogus_addr);
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
index f7c36cd..6a96a5f 100644
--- a/tests-mx32/ipc_msg.c
+++ b/tests-mx32/ipc_msg.c
@@ -21,6 +21,7 @@
#endif
#undef TEST_MSGCTL_BOGUS_ADDR
+#undef TEST_MSGCTL_BOGUS_CMD
/*
* Starting with commit glibc-2.32~83, on every 32-bit architecture
@@ -50,9 +51,21 @@
# define TEST_MSGCTL_BOGUS_ADDR 0
#endif
+/*
+ * Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
+ * glibc skips msgctl syscall invocations and returns EINVAL
+ * for invalid msgctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_MSGCTL_BOGUS_CMD 0
+#endif
+
#ifndef TEST_MSGCTL_BOGUS_ADDR
# define TEST_MSGCTL_BOGUS_ADDR 1
#endif
+#ifndef TEST_MSGCTL_BOGUS_CMD
+# define TEST_MSGCTL_BOGUS_CMD 1
+#endif
#if XLAT_RAW
# define str_ipc_excl_nowait "0xface1c00"
@@ -107,12 +120,16 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb9f531ULL;
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
+#if TEST_MSGCTL_BOGUS_CMD || TEST_MSGCTL_BOGUS_ADDR
static const int bogus_msgid = 0xfdb97531;
+#endif
+#if TEST_MSGCTL_BOGUS_CMD
static const int bogus_cmd = 0xdeadbeef;
+#endif
#if TEST_MSGCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
- static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
int rc;
struct msqid_ds ds;
@@ -129,9 +146,11 @@ main(void)
printf("msgget\\(%s, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_MSGCTL_BOGUS_CMD
rc = msgctl(bogus_msgid, bogus_cmd, NULL);
printf("msgctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_msgid, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_MSGCTL_BOGUS_ADDR
rc = msgctl(bogus_msgid, IPC_SET, bogus_addr);
--
2.1.4

View File

@ -1,169 +0,0 @@
From 8c1a84778bb05a3becc493698b215681bf7249b3 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sat, 19 Sep 2020 08:00:00 +0000
Subject: [PATCH 160/162] tests: disable shmctl IPC_STAT test with a bogus
address on glibc >= 2.32
Starting with commit glibc-2.32~80, on every 32-bit architecture where
32-bit time_t support is enabled, glibc tries to retrieve the data
provided in the third argument of shmctl call. This results to
segfaults inside glibc when shmctl is called with a bogus address.
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32) && __TIMESIZE != 64]
(TEST_SHMCTL_BOGUS_ADDR): Define to 0.
(main): Conditionalize on TEST_SHMCTL_BOGUS_ADDR the shmctl IPC_STAT
invocation with a bogus address.
---
tests/ipc_shm.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
index 5cd414e..695fd94 100644
--- a/tests/ipc_shm.c
+++ b/tests/ipc_shm.c
@@ -73,6 +73,21 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+
static int id = -1;
static void
@@ -92,7 +107,9 @@ main(void)
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
static const int bogus_id = 0xdefaced1;
static const int bogus_cmd = 0xdefaced2;
+#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
+#endif
static const size_t bogus_size =
/*
* musl sets size to SIZE_MAX if size argument is greater than
@@ -160,10 +177,12 @@ main(void)
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
sprintrc_grep(rc));
+#endif
if (shmctl(id, IPC_STAT, &ds))
perror_msg_and_skip("shmctl IPC_STAT");
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
index 5cd414e..695fd94 100644
--- a/tests-m32/ipc_shm.c
+++ b/tests-m32/ipc_shm.c
@@ -73,6 +73,21 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+
static int id = -1;
static void
@@ -92,7 +107,9 @@ main(void)
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
static const int bogus_id = 0xdefaced1;
static const int bogus_cmd = 0xdefaced2;
+#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
+#endif
static const size_t bogus_size =
/*
* musl sets size to SIZE_MAX if size argument is greater than
@@ -160,10 +177,12 @@ main(void)
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
sprintrc_grep(rc));
+#endif
if (shmctl(id, IPC_STAT, &ds))
perror_msg_and_skip("shmctl IPC_STAT");
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
index 5cd414e..695fd94 100644
--- a/tests-mx32/ipc_shm.c
+++ b/tests-mx32/ipc_shm.c
@@ -73,6 +73,21 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+
static int id = -1;
static void
@@ -92,7 +107,9 @@ main(void)
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
static const int bogus_id = 0xdefaced1;
static const int bogus_cmd = 0xdefaced2;
+#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
+#endif
static const size_t bogus_size =
/*
* musl sets size to SIZE_MAX if size argument is greater than
@@ -160,10 +177,12 @@ main(void)
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
sprintrc_grep(rc));
+#endif
if (shmctl(id, IPC_STAT, &ds))
perror_msg_and_skip("shmctl IPC_STAT");
--
2.1.4

View File

@ -1,280 +0,0 @@
From 268b9341ef6397cc337f612563af88ccb5752ca7 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sun, 6 Dec 2020 08:00:00 +0000
Subject: [PATCH 161/162] tests: disable tests for invalid shmctl commands on
glibc >= 2.32
Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
glibc skips shmctl syscall invocations and returns EINVAL
for invalid shmctl commands.
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SHMCTL_BOGUS_CMD):
Define to 0.
[!TEST_SHMCTL_BOGUS_CMD] (TEST_SHMCTL_BOGUS_CMD): Define to 1.
(main) [!TEST_SHMCTL_BOGUS_CMD] (bogus_cmd): Do not define and do not
use.
---
tests/ipc_shm.c | 49 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 15 deletions(-)
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
index 695fd94..350bde5 100644
--- a/tests/ipc_shm.c
+++ b/tests/ipc_shm.c
@@ -29,6 +29,34 @@
# define SHM_NORESERVE 010000
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+#undef TEST_SHMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+/*
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
+ * glibc skips shmctl syscall invocations and returns EINVAL
+ * for invalid shmctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SHMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+#ifndef TEST_SHMCTL_BOGUS_CMD
+# define TEST_SHMCTL_BOGUS_CMD 1
+#endif
+
#include "xlat.h"
#include "xlat/shm_resource_flags.h"
@@ -73,21 +101,6 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
-#undef TEST_SHMCTL_BOGUS_ADDR
-
-/*
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
- * where 32-bit time_t support is enabled, glibc tries to retrieve
- * the data provided in the third argument of shmctl call.
- */
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
-# define TEST_SHMCTL_BOGUS_ADDR 0
-#endif
-
-#ifndef TEST_SHMCTL_BOGUS_ADDR
-# define TEST_SHMCTL_BOGUS_ADDR 1
-#endif
-
static int id = -1;
static void
@@ -105,8 +118,12 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
static const int bogus_id = 0xdefaced1;
+#endif
+#if TEST_SHMCTL_BOGUS_CMD
static const int bogus_cmd = 0xdefaced2;
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
@@ -173,9 +190,11 @@ main(void)
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SHMCTL_BOGUS_CMD
rc = shmctl(bogus_id, bogus_cmd, NULL);
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
index 695fd94..350bde5 100644
--- a/tests-m32/ipc_shm.c
+++ b/tests-m32/ipc_shm.c
@@ -29,6 +29,34 @@
# define SHM_NORESERVE 010000
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+#undef TEST_SHMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+/*
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
+ * glibc skips shmctl syscall invocations and returns EINVAL
+ * for invalid shmctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SHMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+#ifndef TEST_SHMCTL_BOGUS_CMD
+# define TEST_SHMCTL_BOGUS_CMD 1
+#endif
+
#include "xlat.h"
#include "xlat/shm_resource_flags.h"
@@ -73,21 +101,6 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
-#undef TEST_SHMCTL_BOGUS_ADDR
-
-/*
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
- * where 32-bit time_t support is enabled, glibc tries to retrieve
- * the data provided in the third argument of shmctl call.
- */
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
-# define TEST_SHMCTL_BOGUS_ADDR 0
-#endif
-
-#ifndef TEST_SHMCTL_BOGUS_ADDR
-# define TEST_SHMCTL_BOGUS_ADDR 1
-#endif
-
static int id = -1;
static void
@@ -105,8 +118,12 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
static const int bogus_id = 0xdefaced1;
+#endif
+#if TEST_SHMCTL_BOGUS_CMD
static const int bogus_cmd = 0xdefaced2;
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
@@ -173,9 +190,11 @@ main(void)
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SHMCTL_BOGUS_CMD
rc = shmctl(bogus_id, bogus_cmd, NULL);
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
index 695fd94..350bde5 100644
--- a/tests-mx32/ipc_shm.c
+++ b/tests-mx32/ipc_shm.c
@@ -29,6 +29,34 @@
# define SHM_NORESERVE 010000
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+#undef TEST_SHMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+/*
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
+ * glibc skips shmctl syscall invocations and returns EINVAL
+ * for invalid shmctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SHMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+#ifndef TEST_SHMCTL_BOGUS_CMD
+# define TEST_SHMCTL_BOGUS_CMD 1
+#endif
+
#include "xlat.h"
#include "xlat/shm_resource_flags.h"
@@ -73,21 +101,6 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
-#undef TEST_SHMCTL_BOGUS_ADDR
-
-/*
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
- * where 32-bit time_t support is enabled, glibc tries to retrieve
- * the data provided in the third argument of shmctl call.
- */
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
-# define TEST_SHMCTL_BOGUS_ADDR 0
-#endif
-
-#ifndef TEST_SHMCTL_BOGUS_ADDR
-# define TEST_SHMCTL_BOGUS_ADDR 1
-#endif
-
static int id = -1;
static void
@@ -105,8 +118,12 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
static const int bogus_id = 0xdefaced1;
+#endif
+#if TEST_SHMCTL_BOGUS_CMD
static const int bogus_cmd = 0xdefaced2;
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
@@ -173,9 +190,11 @@ main(void)
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SHMCTL_BOGUS_CMD
rc = shmctl(bogus_id, bogus_cmd, NULL);
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
--
2.1.4

View File

@ -1,199 +0,0 @@
From dd8d558394b2b8cb7f743a2a4bf763974d6c2dd9 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sun, 6 Dec 2020 08:00:00 +0000
Subject: [PATCH 162/162] tests: disable tests for invalid semctl commands on
glibc >= 2.32
Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
glibc skips semctl syscall invocations and returns EINVAL
for invalid semctl commands.
* tests/ipc_sem.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SEMCTL_BOGUS_CMD):
Define to 0.
[!TEST_SEMCTL_BOGUS_CMD] (TEST_SEMCTL_BOGUS_CMD): Define to 1.
(main) [!TEST_SEMCTL_BOGUS_CMD] (bogus_semid, bogus_semnum, bogus_cmd,
bogus_arg): Do not define and do not use.
---
tests/ipc_sem.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c
index 7341f72..0351e53 100644
--- a/tests/ipc_sem.c
+++ b/tests/ipc_sem.c
@@ -20,6 +20,21 @@
# define SEM_STAT_ANY 20
#endif
+#undef TEST_SEMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
+ * glibc skips semctl syscall invocations and returns EINVAL
+ * for invalid semctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SEMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SEMCTL_BOGUS_CMD
+# define TEST_SEMCTL_BOGUS_CMD 1
+#endif
+
#if XLAT_RAW
# define str_ipc_flags "0xface1e00"
# define str_ipc_private "0"
@@ -78,13 +93,15 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
- static const int bogus_semid = 0xfdb97531;
- static const int bogus_semnum = 0xeca86420;
static const int bogus_size = 0xdec0ded1;
static const int bogus_flags = 0xface1e55;
+#if TEST_SEMCTL_BOGUS_CMD
+ static const int bogus_semid = 0xfdb97531;
+ static const int bogus_semnum = 0xeca86420;
static const int bogus_cmd = 0xdeadbeef;
static const unsigned long bogus_arg =
(unsigned long) 0xbadc0dedfffffaceULL;
+#endif
int rc;
union semun un;
@@ -102,11 +119,13 @@ main(void)
printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SEMCTL_BOGUS_CMD
rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg);
-#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
+# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n",
bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd,
bogus_arg, bogus_arg, sprintrc_grep(rc));
+#endif
un.buf = &ds;
if (semctl(id, 0, IPC_STAT, un))
diff --git a/tests-m32/ipc_sem.c b/tests-m32/ipc_sem.c
index 7341f72..0351e53 100644
--- a/tests-m32/ipc_sem.c
+++ b/tests-m32/ipc_sem.c
@@ -20,6 +20,21 @@
# define SEM_STAT_ANY 20
#endif
+#undef TEST_SEMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
+ * glibc skips semctl syscall invocations and returns EINVAL
+ * for invalid semctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SEMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SEMCTL_BOGUS_CMD
+# define TEST_SEMCTL_BOGUS_CMD 1
+#endif
+
#if XLAT_RAW
# define str_ipc_flags "0xface1e00"
# define str_ipc_private "0"
@@ -78,13 +93,15 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
- static const int bogus_semid = 0xfdb97531;
- static const int bogus_semnum = 0xeca86420;
static const int bogus_size = 0xdec0ded1;
static const int bogus_flags = 0xface1e55;
+#if TEST_SEMCTL_BOGUS_CMD
+ static const int bogus_semid = 0xfdb97531;
+ static const int bogus_semnum = 0xeca86420;
static const int bogus_cmd = 0xdeadbeef;
static const unsigned long bogus_arg =
(unsigned long) 0xbadc0dedfffffaceULL;
+#endif
int rc;
union semun un;
@@ -102,11 +119,13 @@ main(void)
printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SEMCTL_BOGUS_CMD
rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg);
-#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
+# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n",
bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd,
bogus_arg, bogus_arg, sprintrc_grep(rc));
+#endif
un.buf = &ds;
if (semctl(id, 0, IPC_STAT, un))
diff --git a/tests-mx32/ipc_sem.c b/tests-mx32/ipc_sem.c
index 7341f72..0351e53 100644
--- a/tests-mx32/ipc_sem.c
+++ b/tests-mx32/ipc_sem.c
@@ -20,6 +20,21 @@
# define SEM_STAT_ANY 20
#endif
+#undef TEST_SEMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
+ * glibc skips semctl syscall invocations and returns EINVAL
+ * for invalid semctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SEMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SEMCTL_BOGUS_CMD
+# define TEST_SEMCTL_BOGUS_CMD 1
+#endif
+
#if XLAT_RAW
# define str_ipc_flags "0xface1e00"
# define str_ipc_private "0"
@@ -78,13 +93,15 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
- static const int bogus_semid = 0xfdb97531;
- static const int bogus_semnum = 0xeca86420;
static const int bogus_size = 0xdec0ded1;
static const int bogus_flags = 0xface1e55;
+#if TEST_SEMCTL_BOGUS_CMD
+ static const int bogus_semid = 0xfdb97531;
+ static const int bogus_semnum = 0xeca86420;
static const int bogus_cmd = 0xdeadbeef;
static const unsigned long bogus_arg =
(unsigned long) 0xbadc0dedfffffaceULL;
+#endif
int rc;
union semun un;
@@ -102,11 +119,13 @@ main(void)
printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SEMCTL_BOGUS_CMD
rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg);
-#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
+# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n",
bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd,
bogus_arg, bogus_arg, sprintrc_grep(rc));
+#endif
un.buf = &ds;
if (semctl(id, 0, IPC_STAT, un))
--
2.1.4

View File

@ -0,0 +1,58 @@
From 2bf069698a384ff2bc62d2a10544d49d766b4d7f Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Mon, 27 Jun 2022 18:00:17 +0200
Subject: [PATCH] src/xlat: remove remnants of unnecessary idx usage in xlookup
As there is no idx saving between calls anymore, there's no need to use
(and update) idx in the XT_SORTED case. Reported by clang as a dead store:
Error: CLANG_WARNING:
strace-5.18/src/xlat.c:84:4: warning[deadcode.DeadStores]: Value stored to 'idx' is never read
* src/xlat.c (xlookup): Remove idx declaration; declare idx inside
of the for loop in the XT_NORMAL case; do not offset x->data and x->size
by offs in the XT_SORTED case and do not update idx upon successful
lookup.
Complements: v5.15~164 "xlat: no longer interpret NULL xlat as continuation"
---
src/xlat.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
Index: strace-5.18/src/xlat.c
===================================================================
--- strace-5.18.orig/src/xlat.c 2022-07-12 17:11:52.660927011 +0200
+++ strace-5.18/src/xlat.c 2022-07-12 17:16:18.116794139 +0200
@@ -61,7 +61,6 @@
const char *
xlookup(const struct xlat *x, const uint64_t val)
{
- size_t idx = 0;
const struct xlat_data *e;
if (!x || !x->data)
@@ -69,21 +68,18 @@
switch (x->type) {
case XT_NORMAL:
- for (; idx < x->size; idx++)
+ for (size_t idx = 0; idx < x->size; idx++)
if (x->data[idx].val == val)
return x->data[idx].str;
break;
case XT_SORTED:
e = bsearch((const void *) &val,
- x->data + idx,
- x->size - idx,
+ x->data, x->size,
sizeof(x->data[0]),
xlat_bsearch_compare);
- if (e) {
- idx = e - x->data;
+ if (e)
return e->str;
- }
break;
case XT_INDEXED:

View File

@ -0,0 +1,56 @@
From e604d7bfd18cf5f29e6723091cc1db2945c918c9 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 28 Jun 2022 16:46:53 +0200
Subject: [PATCH] strauss: tips whitespace and phrasing cleanups
* src/strauss.c (tips_tricks_tweaks): Fix some whitespace and phrasing
issues.
---
src/strauss.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
Index: strace-5.18/src/strauss.c
===================================================================
--- strace-5.18.orig/src/strauss.c 2022-07-12 17:17:08.712197019 +0200
+++ strace-5.18/src/strauss.c 2022-07-12 17:17:20.685055717 +0200
@@ -128,8 +128,8 @@
{ "strace is about as old as the Linux kernel.",
"It has been originally written for SunOS",
"by Paul Kranenburg in 1991. The support",
- "for all OSes except Linux has been dropped",
- "since 2012, though, in strace 4.7." },
+ "for all OSes except Linux was dropped"
+ "in 2012, though, in strace 4.7." },
{ "strace is able to decode netlink messages.",
"It does so automatically for I/O performed",
"on netlink sockets. Try it yourself:", "",
@@ -187,7 +187,7 @@
"want to try --seccomp-bpf option, maybe you",
"will feel better." },
{ "-v is a shorthand for -e abbrev=none and not",
- " for -e verbose=all. It is idiosyncratic,",
+ "for -e verbose=all. It is idiosyncratic,",
"but it is the historic behaviour." },
{ "strace uses netlink for printing",
"protocol-specific information about socket",
@@ -254,7 +254,7 @@
"by invoking it with the following options:", "",
" strace -DDDqqq -enone --signal=none" },
{ "Historically, supplying -o option to strace",
- "led to silencing of messages about tracee",
+ "leads to silencing of messages about tracee",
"attach/detach and personality changes.",
"It can be now overridden with --quiet=none",
"option." },
@@ -285,8 +285,9 @@
"will trace all syscalls related to accessing",
"and modifying process's user/group IDs",
"and capability sets. Other pre-defined",
- "syscall classes include %clock, %desc,%file,",
- "%ipc,%memory, %net,%process, and %signal." },
+ "syscall classes include %clock, %desc,"
+ "%file, %ipc, %memory, %net, %process,"
+ "and %signal." },
{ "Trying to figure out communication between",
"tracees inside a different PID namespace",
"(in so-called \"containers\", for example)?",

View File

@ -0,0 +1,48 @@
From 968789d5426442ac43b96eabd65f3e5c0c141e62 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 28 Jun 2022 16:47:56 +0200
Subject: [PATCH] strauss: fix off-by-one error in strauss array access
It has to be limited with strauss_lines - 1, not strauss_lines.
Reported by covscan:
Error: OVERRUN (CWE-119):
strace-5.18/src/strauss.c:380: cond_at_least: Checking "4UL + i < 37UL"
implies that "i" is at least 33 on the false branch.
strace-5.18/src/strauss.c:380: overrun-local: Overrunning array "strauss"
of 37 8-byte elements at element index 37 (byte offset 303) using index
"(4UL + i < 37UL) ? 4UL + i : 37UL" (which evaluates to 37).
* src/strauss.c (print_totd): Limit strauss array accesses to
strauss_lines - 1 instead of strauss_lines.
---
src/strauss.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/strauss.c b/src/strauss.c
index 98af183..b22ab6a 100644
--- a/src/strauss.c
+++ b/src/strauss.c
@@ -373,16 +373,16 @@ print_totd(void)
tip_left[MIN(i + 1, ARRAY_SIZE(tip_left) - 1)],
w, w, tips_tricks_tweaks[id][i] ?: "",
tip_right[MIN(i + 1, ARRAY_SIZE(tip_right) - 1)],
- strauss[MIN(3 + i, strauss_lines)]);
+ strauss[MIN(3 + i, strauss_lines - 1)]);
}
fprintf(stderr, "%s%s\n",
- tip_bottom, strauss[MIN(3 + i, strauss_lines)]);
+ tip_bottom, strauss[MIN(3 + i, strauss_lines - 1)]);
do {
fprintf(stderr, "%*s%*s%*s%s\n",
(int) strlen(tip_left[0]), "",
w, "",
(int) strlen(tip_right[0]), "",
- strauss[MIN(4 + i, strauss_lines)]);
+ strauss[MIN(4 + i, strauss_lines - 1)]);
} while ((show_tips == TIPS_FULL) && (4 + ++i < strauss_lines));
printed = true;
--
2.1.4

View File

@ -0,0 +1,62 @@
From 6d3e97e83a7d61cbb2f5109efb4b519383a55712 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 28 Jun 2022 16:55:49 +0200
Subject: [PATCH] util: add offs sanity check to print_clock_t
While it is not strictly needed right now, the code that uses
the calculated offs value lacks any checks for possible buf overruns,
which is not defensive enough, so let's add them. Reported by covscan:
Error: OVERRUN (CWE-119):
strace-5.18/src/util.c:248: assignment: Assigning:
"offs" = "ilog10(val / clk_tck)". The value of "offs" is now between
16 and 31 (inclusive).
strace-5.18/src/util.c:249: overrun-local: Overrunning array of 30 bytes
at byte offset 31 by dereferencing pointer "buf + offs". [Note: The source
code implementation of the function has been overridden by a builtin model.]
Error: OVERRUN (CWE-119):
strace-5.18/src/util.c:248: assignment: Assigning:
"offs" = "ilog10(val / clk_tck)". The value of "offs" is now between
16 and 31 (inclusive).
strace-5.18/src/util.c:253: overrun-buffer-arg: Overrunning array "buf"
of 30 bytes by passing it to a function which accesses it at byte offset
32 using argument "offs + 2UL" (which evaluates to 33). [Note: The source
code implementation of the function has been overridden by a builtin model.]
Error: OVERRUN (CWE-119):
strace-5.18/src/util.c:248: assignment: Assigning:
"offs" = "ilog10(val / clk_tck)". The value of "offs" is now between
16 and 31 (inclusive).
strace-5.18/src/util.c:254: overrun-local: Overrunning array "buf"
of 30 bytes at byte offset 32 using index "offs + 1UL" (which evaluates
to 32).
* src/util.c (print_clock_t): Add check that offs is small enough
for it and "offs + 2" not to overrun buf.
---
src/util.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/util.c b/src/util.c
index 5f87acb..93aa7b3 100644
--- a/src/util.c
+++ b/src/util.c
@@ -246,6 +246,14 @@ print_clock_t(uint64_t val)
*/
char buf[sizeof(uint64_t) * 3 + sizeof("0.0 s")];
size_t offs = ilog10(val / clk_tck);
+ /*
+ * This check is mostly to appease covscan, which thinks
+ * that offs can go as high as 31 (it cannot), but since
+ * there is no proper sanity checks against offs overrunning
+ * buf down the code, it may as well be here.
+ */
+ if (offs > (sizeof(buf) - sizeof("0.0 s")))
+ return;
int ret = snprintf(buf + offs, sizeof(buf) - offs, "%.*f s",
frac_width,
(double) (val % clk_tck) / clk_tck);
--
2.1.4

View File

@ -0,0 +1,882 @@
From 960e78f208b4f6d48962bbc9cad45588cc8c90ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
Date: Tue, 21 Jun 2022 08:43:00 +0200
Subject: [PATCH] secontext: print context of Unix socket's sun_path field
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
* src/sockaddr.c: Include "secontext.h".
(print_sockaddr_data_un): Print the SELinux context of sun_path field
using selinux_printfilecon.
* NEWS: Mention this change.
* tests/secontext.c (raw_secontext_full_fd, get_secontext_field_fd,
raw_secontext_short_fd, secontext_full_fd, secontext_short_fd): New
functions.
* tests/secontext.h (secontext_full_fd, secontext_short_fd,
get_secontext_field_fd): New prototypes.
(SECONTEXT_FD): New macro.
* tests/sockname.c: Include "secontext.h".
(test_sockname_syscall): Update expected output.
* tests/gen_tests.in (getsockname--secontext,
getsockname--secontext_full, getsockname--secontext_full_mismatch,
getsockname--secontext_mismatch): New tests.
Resolves: https://github.com/strace/strace/pull/214
---
NEWS | 1 +
src/sockaddr.c | 3 +++
tests/gen_tests.in | 4 ++++
tests/secontext.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/secontext.h | 12 ++++++++++++
tests/sockname.c | 54 +++++++++++++++++++++++++++++++++++-------------------
6 files changed, 104 insertions(+), 19 deletions(-)
Index: strace-5.18/NEWS
===================================================================
--- strace-5.18.orig/NEWS 2022-07-12 18:20:18.495470531 +0200
+++ strace-5.18/NEWS 2022-07-12 18:20:44.531163262 +0200
@@ -5,6 +5,7 @@
* Added an interface of raising des Strausses awareness.
* Added --tips option to print strace tips, tricks, and tweaks
at the end of the tracing session.
+ * Implemented printing of Unix socket sun_path field's SELinux context.
* Enhanced decoding of bpf and io_uring_register syscalls.
* Implemented decoding of COUNTER_*, RTC_PARAM_GET, and RTC_PARAM_SET ioctl
commands.
Index: strace-5.18/src/sockaddr.c
===================================================================
--- strace-5.18.orig/src/sockaddr.c 2022-07-12 18:17:36.745379483 +0200
+++ strace-5.18/src/sockaddr.c 2022-07-12 18:20:18.495470531 +0200
@@ -63,6 +63,8 @@
#include "xlat/mctp_addrs.h"
#include "xlat/mctp_nets.h"
+#include "secontext.h"
+
#define SIZEOF_SA_FAMILY sizeof_field(struct sockaddr, sa_family)
struct sockaddr_rxrpc {
@@ -115,6 +117,7 @@
if (sa_un->sun_path[0]) {
print_quoted_string(sa_un->sun_path, path_len + 1,
QUOTE_0_TERMINATED);
+ selinux_printfilecon(tcp, sa_un->sun_path);
} else {
tprints("@");
print_quoted_string(sa_un->sun_path + 1, path_len - 1, 0);
Index: strace-5.18/tests/gen_tests.in
===================================================================
--- strace-5.18.orig/tests/gen_tests.in 2022-07-12 18:17:36.746379471 +0200
+++ strace-5.18/tests/gen_tests.in 2022-07-12 18:20:18.496470519 +0200
@@ -225,6 +225,10 @@
getsid -a10
getsid--pidns-translation test_pidns -e trace=getsid -a10
getsockname -a27
+getsockname--secontext -a27 --secontext -e trace=getsockname
+getsockname--secontext_full -a27 --secontext=full -e trace=getsockname
+getsockname--secontext_full_mismatch -a27 --secontext=full,mismatch -e trace=getsockname
+getsockname--secontext_mismatch -a27 --secontext=mismatch -e trace=getsockname
gettid -a9
getuid-creds +getuid.test
getuid32 +getuid.test
Index: strace-5.18/tests/secontext.c
===================================================================
--- strace-5.18.orig/tests/secontext.c 2022-07-12 18:17:36.747379459 +0200
+++ strace-5.18/tests/secontext.c 2022-07-12 18:20:18.496470519 +0200
@@ -141,6 +141,21 @@
return full_secontext;
}
+static char *
+raw_secontext_full_fd(int fd)
+{
+ int saved_errno = errno;
+ char *full_secontext = NULL;
+ char *secontext;
+
+ if (fgetfilecon(fd, &secontext) >= 0) {
+ full_secontext = strip_trailing_newlines(xstrdup(secontext));
+ freecon(secontext);
+ }
+ errno = saved_errno;
+ return full_secontext;
+}
+
char *
get_secontext_field_file(const char *file, enum secontext_field field)
{
@@ -151,6 +166,16 @@
return type;
}
+char *
+get_secontext_field_fd(int fd, enum secontext_field field)
+{
+ char *ctx = raw_secontext_full_fd(fd);
+ char *type = get_secontext_field(ctx, field);
+ free(ctx);
+
+ return type;
+}
+
static char *
raw_secontext_short_file(const char *filename)
{
@@ -158,6 +183,12 @@
}
static char *
+raw_secontext_short_fd(int fd)
+{
+ return get_secontext_field_fd(fd, SECONTEXT_TYPE);
+}
+
+static char *
raw_secontext_full_pid(pid_t pid)
{
int saved_errno = errno;
@@ -205,6 +236,15 @@
}
char *
+secontext_full_fd(int fd)
+{
+ int saved_errno = errno;
+ char *context = raw_secontext_full_fd(fd);
+ errno = saved_errno;
+ return FORMAT_SPACE_BEFORE(context);
+}
+
+char *
secontext_full_pid(pid_t pid)
{
return FORMAT_SPACE_AFTER(raw_secontext_full_pid(pid));
@@ -228,6 +268,15 @@
errno = saved_errno;
return FORMAT_SPACE_BEFORE(context);
}
+
+char *
+secontext_short_fd(int fd)
+{
+ int saved_errno = errno;
+ char *context = raw_secontext_short_fd(fd);
+ errno = saved_errno;
+ return FORMAT_SPACE_BEFORE(context);
+}
char *
secontext_short_pid(pid_t pid)
Index: strace-5.18/tests/secontext.h
===================================================================
--- strace-5.18.orig/tests/secontext.h 2022-07-12 18:17:36.747379459 +0200
+++ strace-5.18/tests/secontext.h 2022-07-12 18:20:18.496470519 +0200
@@ -9,9 +9,11 @@
#include "xmalloc.h"
#include <unistd.h>
+char *secontext_full_fd(int) ATTRIBUTE_MALLOC;
char *secontext_full_file(const char *, bool) ATTRIBUTE_MALLOC;
char *secontext_full_pid(pid_t) ATTRIBUTE_MALLOC;
+char *secontext_short_fd(int) ATTRIBUTE_MALLOC;
char *secontext_short_file(const char *, bool) ATTRIBUTE_MALLOC;
char *secontext_short_pid(pid_t) ATTRIBUTE_MALLOC;
@@ -30,6 +32,7 @@
*/
char *get_secontext_field(const char *full_context, enum secontext_field field);
+char *get_secontext_field_fd(int fd, enum secontext_field field);
char *get_secontext_field_file(const char *file, enum secontext_field field);
void reset_secontext_file(const char *file);
@@ -44,6 +47,7 @@
# else
# define SECONTEXT_FILE(filename) secontext_full_file(filename, false)
# endif
+# define SECONTEXT_FD(fd) secontext_full_fd(fd)
# define SECONTEXT_PID(pid) secontext_full_pid(pid)
# else
@@ -53,6 +57,7 @@
# else
# define SECONTEXT_FILE(filename) secontext_short_file(filename, false)
# endif
+# define SECONTEXT_FD(fd) secontext_short_fd(fd)
# define SECONTEXT_PID(pid) secontext_short_pid(pid)
# endif
@@ -65,6 +70,12 @@
return NULL;
}
static inline char *
+get_secontext_field_fd(int fd, enum secontext_field field)
+{
+ return NULL;
+}
+
+static inline char *
get_secontext_field_file(const char *file, enum secontext_field field)
{
return NULL;
@@ -81,6 +92,7 @@
{
}
+# define SECONTEXT_FD(fd) xstrdup("")
# define SECONTEXT_FILE(filename) xstrdup("")
# define SECONTEXT_PID(pid) xstrdup("")
Index: strace-5.18/tests/sockname.c
===================================================================
--- strace-5.18.orig/tests/sockname.c 2022-07-12 18:17:36.748379448 +0200
+++ strace-5.18/tests/sockname.c 2022-07-12 18:20:18.496470519 +0200
@@ -18,6 +18,8 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include "secontext.h"
+
#ifndef TEST_SYSCALL_NAME
# error TEST_SYSCALL_NAME must be defined
#endif
@@ -59,14 +61,19 @@
*plen = sizeof(struct sockaddr_un);
struct sockaddr_un *addr = tail_alloc(*plen);
+ char *my_secontext = SECONTEXT_PID_MY();
+ char *fd_secontext = SECONTEXT_FD(fd);
+
PREPARE_TEST_SYSCALL_INVOCATION;
int rc = TEST_SYSCALL_NAME(fd PREFIX_S_ARGS, (void *) addr,
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%s\"%s}"
", [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR, addr->sun_path,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
(int) sizeof(struct sockaddr_un), (int) *plen, SUFFIX_STR, rc);
memset(addr, 0, sizeof(*addr));
@@ -75,28 +82,34 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%s\"%s}"
", [%d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR, addr->sun_path,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
(int) *plen, SUFFIX_STR, rc);
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr, 0 SUFFIX_ARGS);
- printf("%s(%d%s, %p, NULL%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr, SUFFIX_STR,
- sprintrc(rc));
+ printf("%s%s(%d%s%s, %p, NULL%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR,
+ addr, SUFFIX_STR, sprintrc(rc));
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_S_ARGS, 0, 0 SUFFIX_ARGS);
- printf("%s(%d%s, NULL, NULL%s) = %s\n",
- TEST_SYSCALL_STR, fd, rc == -1 ? PREFIX_F_STR : PREFIX_S_STR,
+ printf("%s%s(%d%s%s, NULL, NULL%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext,
+ rc == -1 ? PREFIX_F_STR : PREFIX_S_STR,
SUFFIX_STR, sprintrc(rc));
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr,
plen + 1 SUFFIX_ARGS);
- printf("%s(%d%s, %p, %p%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr,
+ printf("%s%s(%d%s%s, %p, %p%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR, addr,
plen + 1, SUFFIX_STR, sprintrc(rc));
const size_t offsetof_sun_path = offsetof(struct sockaddr_un, sun_path);
@@ -108,8 +121,9 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX}, [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR,
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX}, [%d => %d]%s) = %d\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
(int) offsetof_sun_path, (int) *plen, SUFFIX_STR, rc);
++addr;
@@ -121,17 +135,19 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%.*s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%.*s\"%s}"
", [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
(int) (sizeof(struct sockaddr) - offsetof_sun_path),
- addr->sun_path, (int) sizeof(struct sockaddr),
- (int) *plen, SUFFIX_STR, rc);
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
+ (int) sizeof(struct sockaddr), (int) *plen, SUFFIX_STR, rc);
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr,
plen SUFFIX_ARGS);
- printf("%s(%d%s, %p, [%d]%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr,
+ printf("%s%s(%d%s%s, %p, [%d]%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR, addr,
*plen, SUFFIX_STR, sprintrc(rc));
}
Index: strace-5.18/tests-m32/secontext.c
===================================================================
--- strace-5.18.orig/tests-m32/secontext.c 2022-07-12 18:17:36.747379459 +0200
+++ strace-5.18/tests-m32/secontext.c 2022-07-12 18:20:18.496470519 +0200
@@ -141,6 +141,21 @@
return full_secontext;
}
+static char *
+raw_secontext_full_fd(int fd)
+{
+ int saved_errno = errno;
+ char *full_secontext = NULL;
+ char *secontext;
+
+ if (fgetfilecon(fd, &secontext) >= 0) {
+ full_secontext = strip_trailing_newlines(xstrdup(secontext));
+ freecon(secontext);
+ }
+ errno = saved_errno;
+ return full_secontext;
+}
+
char *
get_secontext_field_file(const char *file, enum secontext_field field)
{
@@ -151,6 +166,16 @@
return type;
}
+char *
+get_secontext_field_fd(int fd, enum secontext_field field)
+{
+ char *ctx = raw_secontext_full_fd(fd);
+ char *type = get_secontext_field(ctx, field);
+ free(ctx);
+
+ return type;
+}
+
static char *
raw_secontext_short_file(const char *filename)
{
@@ -158,6 +183,12 @@
}
static char *
+raw_secontext_short_fd(int fd)
+{
+ return get_secontext_field_fd(fd, SECONTEXT_TYPE);
+}
+
+static char *
raw_secontext_full_pid(pid_t pid)
{
int saved_errno = errno;
@@ -205,6 +236,15 @@
}
char *
+secontext_full_fd(int fd)
+{
+ int saved_errno = errno;
+ char *context = raw_secontext_full_fd(fd);
+ errno = saved_errno;
+ return FORMAT_SPACE_BEFORE(context);
+}
+
+char *
secontext_full_pid(pid_t pid)
{
return FORMAT_SPACE_AFTER(raw_secontext_full_pid(pid));
@@ -228,6 +268,15 @@
errno = saved_errno;
return FORMAT_SPACE_BEFORE(context);
}
+
+char *
+secontext_short_fd(int fd)
+{
+ int saved_errno = errno;
+ char *context = raw_secontext_short_fd(fd);
+ errno = saved_errno;
+ return FORMAT_SPACE_BEFORE(context);
+}
char *
secontext_short_pid(pid_t pid)
Index: strace-5.18/tests-m32/secontext.h
===================================================================
--- strace-5.18.orig/tests-m32/secontext.h 2022-07-12 18:17:36.747379459 +0200
+++ strace-5.18/tests-m32/secontext.h 2022-07-12 18:20:18.496470519 +0200
@@ -9,9 +9,11 @@
#include "xmalloc.h"
#include <unistd.h>
+char *secontext_full_fd(int) ATTRIBUTE_MALLOC;
char *secontext_full_file(const char *, bool) ATTRIBUTE_MALLOC;
char *secontext_full_pid(pid_t) ATTRIBUTE_MALLOC;
+char *secontext_short_fd(int) ATTRIBUTE_MALLOC;
char *secontext_short_file(const char *, bool) ATTRIBUTE_MALLOC;
char *secontext_short_pid(pid_t) ATTRIBUTE_MALLOC;
@@ -30,6 +32,7 @@
*/
char *get_secontext_field(const char *full_context, enum secontext_field field);
+char *get_secontext_field_fd(int fd, enum secontext_field field);
char *get_secontext_field_file(const char *file, enum secontext_field field);
void reset_secontext_file(const char *file);
@@ -44,6 +47,7 @@
# else
# define SECONTEXT_FILE(filename) secontext_full_file(filename, false)
# endif
+# define SECONTEXT_FD(fd) secontext_full_fd(fd)
# define SECONTEXT_PID(pid) secontext_full_pid(pid)
# else
@@ -53,6 +57,7 @@
# else
# define SECONTEXT_FILE(filename) secontext_short_file(filename, false)
# endif
+# define SECONTEXT_FD(fd) secontext_short_fd(fd)
# define SECONTEXT_PID(pid) secontext_short_pid(pid)
# endif
@@ -65,6 +70,12 @@
return NULL;
}
static inline char *
+get_secontext_field_fd(int fd, enum secontext_field field)
+{
+ return NULL;
+}
+
+static inline char *
get_secontext_field_file(const char *file, enum secontext_field field)
{
return NULL;
@@ -81,6 +92,7 @@
{
}
+# define SECONTEXT_FD(fd) xstrdup("")
# define SECONTEXT_FILE(filename) xstrdup("")
# define SECONTEXT_PID(pid) xstrdup("")
Index: strace-5.18/tests-m32/sockname.c
===================================================================
--- strace-5.18.orig/tests-m32/sockname.c 2022-07-12 18:17:36.748379448 +0200
+++ strace-5.18/tests-m32/sockname.c 2022-07-12 18:20:18.496470519 +0200
@@ -18,6 +18,8 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include "secontext.h"
+
#ifndef TEST_SYSCALL_NAME
# error TEST_SYSCALL_NAME must be defined
#endif
@@ -59,14 +61,19 @@
*plen = sizeof(struct sockaddr_un);
struct sockaddr_un *addr = tail_alloc(*plen);
+ char *my_secontext = SECONTEXT_PID_MY();
+ char *fd_secontext = SECONTEXT_FD(fd);
+
PREPARE_TEST_SYSCALL_INVOCATION;
int rc = TEST_SYSCALL_NAME(fd PREFIX_S_ARGS, (void *) addr,
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%s\"%s}"
", [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR, addr->sun_path,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
(int) sizeof(struct sockaddr_un), (int) *plen, SUFFIX_STR, rc);
memset(addr, 0, sizeof(*addr));
@@ -75,28 +82,34 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%s\"%s}"
", [%d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR, addr->sun_path,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
(int) *plen, SUFFIX_STR, rc);
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr, 0 SUFFIX_ARGS);
- printf("%s(%d%s, %p, NULL%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr, SUFFIX_STR,
- sprintrc(rc));
+ printf("%s%s(%d%s%s, %p, NULL%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR,
+ addr, SUFFIX_STR, sprintrc(rc));
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_S_ARGS, 0, 0 SUFFIX_ARGS);
- printf("%s(%d%s, NULL, NULL%s) = %s\n",
- TEST_SYSCALL_STR, fd, rc == -1 ? PREFIX_F_STR : PREFIX_S_STR,
+ printf("%s%s(%d%s%s, NULL, NULL%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext,
+ rc == -1 ? PREFIX_F_STR : PREFIX_S_STR,
SUFFIX_STR, sprintrc(rc));
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr,
plen + 1 SUFFIX_ARGS);
- printf("%s(%d%s, %p, %p%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr,
+ printf("%s%s(%d%s%s, %p, %p%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR, addr,
plen + 1, SUFFIX_STR, sprintrc(rc));
const size_t offsetof_sun_path = offsetof(struct sockaddr_un, sun_path);
@@ -108,8 +121,9 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX}, [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR,
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX}, [%d => %d]%s) = %d\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
(int) offsetof_sun_path, (int) *plen, SUFFIX_STR, rc);
++addr;
@@ -121,17 +135,19 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%.*s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%.*s\"%s}"
", [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
(int) (sizeof(struct sockaddr) - offsetof_sun_path),
- addr->sun_path, (int) sizeof(struct sockaddr),
- (int) *plen, SUFFIX_STR, rc);
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
+ (int) sizeof(struct sockaddr), (int) *plen, SUFFIX_STR, rc);
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr,
plen SUFFIX_ARGS);
- printf("%s(%d%s, %p, [%d]%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr,
+ printf("%s%s(%d%s%s, %p, [%d]%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR, addr,
*plen, SUFFIX_STR, sprintrc(rc));
}
Index: strace-5.18/tests-mx32/secontext.c
===================================================================
--- strace-5.18.orig/tests-mx32/secontext.c 2022-07-12 18:17:36.747379459 +0200
+++ strace-5.18/tests-mx32/secontext.c 2022-07-12 18:20:18.496470519 +0200
@@ -141,6 +141,21 @@
return full_secontext;
}
+static char *
+raw_secontext_full_fd(int fd)
+{
+ int saved_errno = errno;
+ char *full_secontext = NULL;
+ char *secontext;
+
+ if (fgetfilecon(fd, &secontext) >= 0) {
+ full_secontext = strip_trailing_newlines(xstrdup(secontext));
+ freecon(secontext);
+ }
+ errno = saved_errno;
+ return full_secontext;
+}
+
char *
get_secontext_field_file(const char *file, enum secontext_field field)
{
@@ -151,6 +166,16 @@
return type;
}
+char *
+get_secontext_field_fd(int fd, enum secontext_field field)
+{
+ char *ctx = raw_secontext_full_fd(fd);
+ char *type = get_secontext_field(ctx, field);
+ free(ctx);
+
+ return type;
+}
+
static char *
raw_secontext_short_file(const char *filename)
{
@@ -158,6 +183,12 @@
}
static char *
+raw_secontext_short_fd(int fd)
+{
+ return get_secontext_field_fd(fd, SECONTEXT_TYPE);
+}
+
+static char *
raw_secontext_full_pid(pid_t pid)
{
int saved_errno = errno;
@@ -205,6 +236,15 @@
}
char *
+secontext_full_fd(int fd)
+{
+ int saved_errno = errno;
+ char *context = raw_secontext_full_fd(fd);
+ errno = saved_errno;
+ return FORMAT_SPACE_BEFORE(context);
+}
+
+char *
secontext_full_pid(pid_t pid)
{
return FORMAT_SPACE_AFTER(raw_secontext_full_pid(pid));
@@ -228,6 +268,15 @@
errno = saved_errno;
return FORMAT_SPACE_BEFORE(context);
}
+
+char *
+secontext_short_fd(int fd)
+{
+ int saved_errno = errno;
+ char *context = raw_secontext_short_fd(fd);
+ errno = saved_errno;
+ return FORMAT_SPACE_BEFORE(context);
+}
char *
secontext_short_pid(pid_t pid)
Index: strace-5.18/tests-mx32/secontext.h
===================================================================
--- strace-5.18.orig/tests-mx32/secontext.h 2022-07-12 18:17:36.747379459 +0200
+++ strace-5.18/tests-mx32/secontext.h 2022-07-12 18:20:18.496470519 +0200
@@ -9,9 +9,11 @@
#include "xmalloc.h"
#include <unistd.h>
+char *secontext_full_fd(int) ATTRIBUTE_MALLOC;
char *secontext_full_file(const char *, bool) ATTRIBUTE_MALLOC;
char *secontext_full_pid(pid_t) ATTRIBUTE_MALLOC;
+char *secontext_short_fd(int) ATTRIBUTE_MALLOC;
char *secontext_short_file(const char *, bool) ATTRIBUTE_MALLOC;
char *secontext_short_pid(pid_t) ATTRIBUTE_MALLOC;
@@ -30,6 +32,7 @@
*/
char *get_secontext_field(const char *full_context, enum secontext_field field);
+char *get_secontext_field_fd(int fd, enum secontext_field field);
char *get_secontext_field_file(const char *file, enum secontext_field field);
void reset_secontext_file(const char *file);
@@ -44,6 +47,7 @@
# else
# define SECONTEXT_FILE(filename) secontext_full_file(filename, false)
# endif
+# define SECONTEXT_FD(fd) secontext_full_fd(fd)
# define SECONTEXT_PID(pid) secontext_full_pid(pid)
# else
@@ -53,6 +57,7 @@
# else
# define SECONTEXT_FILE(filename) secontext_short_file(filename, false)
# endif
+# define SECONTEXT_FD(fd) secontext_short_fd(fd)
# define SECONTEXT_PID(pid) secontext_short_pid(pid)
# endif
@@ -65,6 +70,12 @@
return NULL;
}
static inline char *
+get_secontext_field_fd(int fd, enum secontext_field field)
+{
+ return NULL;
+}
+
+static inline char *
get_secontext_field_file(const char *file, enum secontext_field field)
{
return NULL;
@@ -81,6 +92,7 @@
{
}
+# define SECONTEXT_FD(fd) xstrdup("")
# define SECONTEXT_FILE(filename) xstrdup("")
# define SECONTEXT_PID(pid) xstrdup("")
Index: strace-5.18/tests-mx32/sockname.c
===================================================================
--- strace-5.18.orig/tests-mx32/sockname.c 2022-07-12 18:17:36.748379448 +0200
+++ strace-5.18/tests-mx32/sockname.c 2022-07-12 18:20:18.496470519 +0200
@@ -18,6 +18,8 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include "secontext.h"
+
#ifndef TEST_SYSCALL_NAME
# error TEST_SYSCALL_NAME must be defined
#endif
@@ -59,14 +61,19 @@
*plen = sizeof(struct sockaddr_un);
struct sockaddr_un *addr = tail_alloc(*plen);
+ char *my_secontext = SECONTEXT_PID_MY();
+ char *fd_secontext = SECONTEXT_FD(fd);
+
PREPARE_TEST_SYSCALL_INVOCATION;
int rc = TEST_SYSCALL_NAME(fd PREFIX_S_ARGS, (void *) addr,
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%s\"%s}"
", [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR, addr->sun_path,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
(int) sizeof(struct sockaddr_un), (int) *plen, SUFFIX_STR, rc);
memset(addr, 0, sizeof(*addr));
@@ -75,28 +82,34 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%s\"%s}"
", [%d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR, addr->sun_path,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
(int) *plen, SUFFIX_STR, rc);
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr, 0 SUFFIX_ARGS);
- printf("%s(%d%s, %p, NULL%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr, SUFFIX_STR,
- sprintrc(rc));
+ printf("%s%s(%d%s%s, %p, NULL%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR,
+ addr, SUFFIX_STR, sprintrc(rc));
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_S_ARGS, 0, 0 SUFFIX_ARGS);
- printf("%s(%d%s, NULL, NULL%s) = %s\n",
- TEST_SYSCALL_STR, fd, rc == -1 ? PREFIX_F_STR : PREFIX_S_STR,
+ printf("%s%s(%d%s%s, NULL, NULL%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext,
+ rc == -1 ? PREFIX_F_STR : PREFIX_S_STR,
SUFFIX_STR, sprintrc(rc));
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr,
plen + 1 SUFFIX_ARGS);
- printf("%s(%d%s, %p, %p%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr,
+ printf("%s%s(%d%s%s, %p, %p%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR, addr,
plen + 1, SUFFIX_STR, sprintrc(rc));
const size_t offsetof_sun_path = offsetof(struct sockaddr_un, sun_path);
@@ -108,8 +121,9 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX}, [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR,
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX}, [%d => %d]%s) = %d\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
(int) offsetof_sun_path, (int) *plen, SUFFIX_STR, rc);
++addr;
@@ -121,17 +135,19 @@
plen SUFFIX_ARGS);
if (rc < 0)
perror_msg_and_skip(TEST_SYSCALL_STR);
- printf("%s(%d%s, {sa_family=AF_UNIX, sun_path=\"%.*s\"}"
+ printf("%s%s(%d%s%s, {sa_family=AF_UNIX, sun_path=\"%.*s\"%s}"
", [%d => %d]%s) = %d\n",
- TEST_SYSCALL_STR, fd, PREFIX_S_STR,
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_S_STR,
(int) (sizeof(struct sockaddr) - offsetof_sun_path),
- addr->sun_path, (int) sizeof(struct sockaddr),
- (int) *plen, SUFFIX_STR, rc);
+ addr->sun_path, SECONTEXT_FILE(addr->sun_path),
+ (int) sizeof(struct sockaddr), (int) *plen, SUFFIX_STR, rc);
PREPARE_TEST_SYSCALL_INVOCATION;
rc = TEST_SYSCALL_NAME(fd PREFIX_F_ARGS, (void *) addr,
plen SUFFIX_ARGS);
- printf("%s(%d%s, %p, [%d]%s) = %s\n",
- TEST_SYSCALL_STR, fd, PREFIX_F_STR, addr,
+ printf("%s%s(%d%s%s, %p, [%d]%s) = %s\n",
+ my_secontext,
+ TEST_SYSCALL_STR, fd, fd_secontext, PREFIX_F_STR, addr,
*plen, SUFFIX_STR, sprintrc(rc));
}

View File

@ -0,0 +1,374 @@
From 676979fa9cc7920e5e4d547814f9c0edb597fa0d Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Thu, 30 Jun 2022 16:01:05 +0200
Subject: [PATCH] pathtrace, util: do not print " (deleted)" as part of the
path
In order to allow to discern the unlinked paths from the paths that
do indeed end with " (deleted)".
* src/defs.h (getfdpath_pid): Add deleted parameter.
(getfdpath): Pass NULL as deleted parameter to getfdpath_pid.
* src/largefile_wrappers.h (lstat_file): New macro.
* src/pathtrace.c: Include <sys/stat.h>, <sys/types.h>, <unistd.h>,
and "largefile_wrappers.h".
(getfdpath_pid): Add deleted parameter, check if path ends with
" (deleted)", and if it is, try to figure out if it is a part
of the path by comparing device/inode numbers of the file procfs
link resolves into and the file pointed by the path read; strip
" (deleted)"; set deleted (if it is non-NULL) to true if the fd
is turned out to be deleted and to false otherwise.
* src/util.c (print_quoted_string_in_angle_brackets): Add deleted
parameter, print "(deleted)" after the closing angle bracket if it is
non-NULL.
(printfd_pid): Add deleted local variable, pass it to getfdpath_pid
and print_quoted_string_in_angle_brackets calls.
* tests/fchmod.c: Add checks for a file with " (deleted)" in the path,
update expected output.
* NEWS: Mention the change.
---
NEWS | 5 +++++
src/defs.h | 5 +++--
src/largefile_wrappers.h | 2 ++
src/pathtrace.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
src/util.c | 10 +++++++---
tests/fchmod.c | 47 +++++++++++++++++++++++++++++++++++++++++++----
6 files changed, 105 insertions(+), 12 deletions(-)
Index: strace-5.18/NEWS
===================================================================
--- strace-5.18.orig/NEWS 2022-07-13 12:52:48.219784860 +0200
+++ strace-5.18/NEWS 2022-07-13 12:52:48.451782122 +0200
@@ -1,6 +1,11 @@
Noteworthy changes in release 5.18 (2022-06-18)
===============================================
+* Changes in behaviour
+ * The "(deleted)" marker for unlinked paths of file descriptors is now printed
+ outside angle brackets; the matching of unlinked paths of file descriptors
+ no longer includes the " (deleted)" part into consideration.
+
* Improvements
* Added an interface of raising des Strausses awareness.
* Added --tips option to print strace tips, tricks, and tweaks
Index: strace-5.18/src/defs.h
===================================================================
--- strace-5.18.orig/src/defs.h 2022-07-13 12:52:29.405006910 +0200
+++ strace-5.18/src/defs.h 2022-07-13 12:52:54.532710356 +0200
@@ -785,12 +785,13 @@
return pathtrace_match_set(tcp, &global_path_set);
}
-extern int getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize);
+extern int getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize,
+ bool *deleted);
static inline int
getfdpath(struct tcb *tcp, int fd, char *buf, unsigned bufsize)
{
- return getfdpath_pid(tcp->pid, fd, buf, bufsize);
+ return getfdpath_pid(tcp->pid, fd, buf, bufsize, NULL);
}
extern unsigned long getfdinode(struct tcb *, int);
Index: strace-5.18/src/largefile_wrappers.h
===================================================================
--- strace-5.18.orig/src/largefile_wrappers.h 2022-07-13 12:52:29.405006910 +0200
+++ strace-5.18/src/largefile_wrappers.h 2022-07-13 12:52:48.451782122 +0200
@@ -31,6 +31,7 @@
# endif
# define fstat_fd fstat64
# define strace_stat_t struct stat64
+# define lstat_file lstat64
# define stat_file stat64
# define struct_dirent struct dirent64
# define read_dir readdir64
@@ -42,6 +43,7 @@
# define fcntl_fd fcntl
# define fstat_fd fstat
# define strace_stat_t struct stat
+# define lstat_file lstat
# define stat_file stat
# define struct_dirent struct dirent
# define read_dir readdir
Index: strace-5.18/src/pathtrace.c
===================================================================
--- strace-5.18.orig/src/pathtrace.c 2022-07-13 12:52:29.405006910 +0200
+++ strace-5.18/src/pathtrace.c 2022-07-13 12:52:54.532710356 +0200
@@ -10,7 +10,11 @@
#include "defs.h"
#include <limits.h>
#include <poll.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "largefile_wrappers.h"
#include "number_set.h"
#include "sen.h"
#include "xstring.h"
@@ -77,7 +81,7 @@
* Get path associated with fd of a process with pid.
*/
int
-getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize)
+getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize, bool *deleted)
{
char linkpath[sizeof("/proc/%u/fd/%u") + 2 * sizeof(int)*3];
ssize_t n;
@@ -91,12 +95,50 @@
xsprintf(linkpath, "/proc/%u/fd/%u", proc_pid, fd);
n = readlink(linkpath, buf, bufsize - 1);
+ if (n < 0)
+ goto end;
+
/*
* NB: if buf is too small, readlink doesn't fail,
* it returns truncated result (IOW: n == bufsize - 1).
*/
- if (n >= 0)
- buf[n] = '\0';
+ buf[n] = '\0';
+ if (deleted)
+ *deleted = false;
+
+ /*
+ * Try to figure out if the kernel has appended " (deleted)"
+ * to the end of a potentially unlinked path and set deleted
+ * if it is the case.
+ */
+ static const char del_sfx[] = " (deleted)";
+ if ((size_t) n <= sizeof(del_sfx))
+ goto end;
+
+ char *del = buf + n + 1 - sizeof(del_sfx);
+
+ if (memcmp(del, del_sfx, sizeof(del_sfx)))
+ goto end;
+
+ strace_stat_t st_link;
+ strace_stat_t st_path;
+ int rc = stat_file(linkpath, &st_link);
+
+ if (rc)
+ goto end;
+
+ rc = lstat_file(buf, &st_path);
+
+ if (rc ||
+ (st_link.st_ino != st_path.st_ino) ||
+ (st_link.st_dev != st_path.st_dev)) {
+ *del = '\0';
+ n = del - buf + 1;
+ if (deleted)
+ *deleted = true;
+ }
+
+end:
return n;
}
Index: strace-5.18/src/util.c
===================================================================
--- strace-5.18.orig/src/util.c 2022-07-13 12:52:47.989787575 +0200
+++ strace-5.18/src/util.c 2022-07-13 12:52:48.452782111 +0200
@@ -735,12 +735,15 @@
}
static void
-print_quoted_string_in_angle_brackets(const char *str)
+print_quoted_string_in_angle_brackets(const char *str, const bool deleted)
{
tprints("<");
print_quoted_string_ex(str, strlen(str),
QUOTE_OMIT_LEADING_TRAILING_QUOTES, "<>");
tprints(">");
+
+ if (deleted)
+ tprints("(deleted)");
}
void
@@ -749,8 +752,9 @@
PRINT_VAL_D(fd);
char path[PATH_MAX + 1];
+ bool deleted;
if (pid > 0 && !number_set_array_is_empty(decode_fd_set, 0)
- && getfdpath_pid(pid, fd, path, sizeof(path)) >= 0) {
+ && getfdpath_pid(pid, fd, path, sizeof(path), &deleted) >= 0) {
if (is_number_in_set(DECODE_FD_SOCKET, decode_fd_set) &&
printsocket(tcp, fd, path))
goto printed;
@@ -761,7 +765,7 @@
printpidfd(pid, fd, path))
goto printed;
if (is_number_in_set(DECODE_FD_PATH, decode_fd_set))
- print_quoted_string_in_angle_brackets(path);
+ print_quoted_string_in_angle_brackets(path, deleted);
printed: ;
}
Index: strace-5.18/tests/fchmod.c
===================================================================
--- strace-5.18.orig/tests/fchmod.c 2022-07-13 12:52:29.405006910 +0200
+++ strace-5.18/tests/fchmod.c 2022-07-13 12:52:48.452782111 +0200
@@ -35,10 +35,17 @@
(void) unlink(sample);
int fd = open(sample, O_CREAT|O_RDONLY, 0400);
if (fd == -1)
- perror_msg_and_fail("open");
+ perror_msg_and_fail("open(\"%s\")", sample);
+
+ static const char sample_del[] = "fchmod_sample_file (deleted)";
+ (void) unlink(sample_del);
+ int fd_del = open(sample_del, O_CREAT|O_RDONLY, 0400);
+ if (fd_del == -1)
+ perror_msg_and_fail("open(\"%s\")", sample);
# ifdef YFLAG
char *sample_realpath = get_fd_path(fd);
+ char *sample_del_realpath = get_fd_path(fd_del);
# endif
const char *sample_secontext = SECONTEXT_FILE(sample);
@@ -56,12 +63,27 @@
sample_secontext,
sprintrc(rc));
+ const char *sample_del_secontext = SECONTEXT_FILE(sample_del);
+ rc = syscall(__NR_fchmod, fd_del, 0600);
+# ifdef YFLAG
+ printf("%s%s(%d<%s>%s, 0600) = %s\n",
+# else
+ printf("%s%s(%d%s, 0600) = %s\n",
+# endif
+ my_secontext, "fchmod",
+ fd_del,
+# ifdef YFLAG
+ sample_del_realpath,
+# endif
+ sample_del_secontext,
+ sprintrc(rc));
+
if (unlink(sample))
- perror_msg_and_fail("unlink");
+ perror_msg_and_fail("unlink(\"%s\")", sample);
rc = syscall(__NR_fchmod, fd, 051);
# ifdef YFLAG
- printf("%s%s(%d<%s (deleted)>%s, 051) = %s\n",
+ printf("%s%s(%d<%s>(deleted)%s, 051) = %s\n",
# else
printf("%s%s(%d%s, 051) = %s\n",
# endif
@@ -73,9 +95,26 @@
sample_secontext,
sprintrc(rc));
+ if (unlink(sample_del))
+ perror_msg_and_fail("unlink(\"%s\")", sample_del);
+
+ rc = syscall(__NR_fchmod, fd_del, 051);
+# ifdef YFLAG
+ printf("%s%s(%d<%s>(deleted)%s, 051) = %s\n",
+# else
+ printf("%s%s(%d%s, 051) = %s\n",
+# endif
+ my_secontext, "fchmod",
+ fd_del,
+# ifdef YFLAG
+ sample_del_realpath,
+# endif
+ sample_del_secontext,
+ sprintrc(rc));
+
rc = syscall(__NR_fchmod, fd, 004);
# ifdef YFLAG
- printf("%s%s(%d<%s (deleted)>%s, 004) = %s\n",
+ printf("%s%s(%d<%s>(deleted)%s, 004) = %s\n",
# else
printf("%s%s(%d%s, 004) = %s\n",
# endif
Index: strace-5.18/tests-m32/fchmod.c
===================================================================
--- strace-5.18.orig/tests-m32/fchmod.c 2022-07-13 12:52:29.405006910 +0200
+++ strace-5.18/tests-m32/fchmod.c 2022-07-13 12:52:48.452782111 +0200
@@ -35,10 +35,17 @@
(void) unlink(sample);
int fd = open(sample, O_CREAT|O_RDONLY, 0400);
if (fd == -1)
- perror_msg_and_fail("open");
+ perror_msg_and_fail("open(\"%s\")", sample);
+
+ static const char sample_del[] = "fchmod_sample_file (deleted)";
+ (void) unlink(sample_del);
+ int fd_del = open(sample_del, O_CREAT|O_RDONLY, 0400);
+ if (fd_del == -1)
+ perror_msg_and_fail("open(\"%s\")", sample);
# ifdef YFLAG
char *sample_realpath = get_fd_path(fd);
+ char *sample_del_realpath = get_fd_path(fd_del);
# endif
const char *sample_secontext = SECONTEXT_FILE(sample);
@@ -56,12 +63,27 @@
sample_secontext,
sprintrc(rc));
+ const char *sample_del_secontext = SECONTEXT_FILE(sample_del);
+ rc = syscall(__NR_fchmod, fd_del, 0600);
+# ifdef YFLAG
+ printf("%s%s(%d<%s>%s, 0600) = %s\n",
+# else
+ printf("%s%s(%d%s, 0600) = %s\n",
+# endif
+ my_secontext, "fchmod",
+ fd_del,
+# ifdef YFLAG
+ sample_del_realpath,
+# endif
+ sample_del_secontext,
+ sprintrc(rc));
+
if (unlink(sample))
- perror_msg_and_fail("unlink");
+ perror_msg_and_fail("unlink(\"%s\")", sample);
rc = syscall(__NR_fchmod, fd, 051);
# ifdef YFLAG
- printf("%s%s(%d<%s (deleted)>%s, 051) = %s\n",
+ printf("%s%s(%d<%s>(deleted)%s, 051) = %s\n",
# else
printf("%s%s(%d%s, 051) = %s\n",
# endif
@@ -73,9 +95,26 @@
sample_secontext,
sprintrc(rc));
+ if (unlink(sample_del))
+ perror_msg_and_fail("unlink(\"%s\")", sample_del);
+
+ rc = syscall(__NR_fchmod, fd_del, 051);
+# ifdef YFLAG
+ printf("%s%s(%d<%s>(deleted)%s, 051) = %s\n",
+# else
+ printf("%s%s(%d%s, 051) = %s\n",
+# endif
+ my_secontext, "fchmod",
+ fd_del,
+# ifdef YFLAG
+ sample_del_realpath,
+# endif
+ sample_del_secontext,
+ sprintrc(rc));
+
rc = syscall(__NR_fchmod, fd, 004);
# ifdef YFLAG
- printf("%s%s(%d<%s (deleted)>%s, 004) = %s\n",
+ printf("%s%s(%d<%s>(deleted)%s, 004) = %s\n",
# else
printf("%s%s(%d%s, 004) = %s\n",
# endif

View File

@ -0,0 +1,209 @@
From 3f0e5340b651da98251a58cc7923525d69f96032 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Fri, 1 Jul 2022 10:45:48 +0200
Subject: [PATCH] secontext: fix expected SELinux context check for unlinked
FDs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
selinux_getfdcon open-coded a part of getfdpath_pid since it tries
to do the same job, figure out a path associated with an FD, for slightly
different purpose: to get the expected SELinux context for it. As the previous
commit shows, it's a bit more complicated in cases when the path ends
with the " (deleted)" string, which is also used for designated unlinked paths
in procfs. Otherwise, it may manifest in test failures such as this:
[unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023] fchmod(4</root/rpmbuild/BUILD/strace-5.13/tests/fchmod-y--secontext_full_mismatch.dir/fchmod_subdir/fchmod_sample_file> [unconfined_u:object_r:admin_home_t:s0!!system_u:object_r:admin_home_t:s0], 0600) = 0
-[unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023] fchmod(4</root/rpmbuild/BUILD/strace-5.13/tests/fchmod-y--secontext_full_mismatch.dir/fchmod_subdir/fchmod_sample_file (deleted)> [unconfined_u:object_r:admin_home_t:s0!!system_u:object_r:admin_home_t:s0], 051) = 0
-[unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023] fchmod(4</root/rpmbuild/BUILD/strace-5.13/tests/fchmod-y--secontext_full_mismatch.dir/fchmod_subdir/fchmod_sample_file (deleted)> [unconfined_u:object_r:admin_home_t:s0!!system_u:object_r:admin_home_t:s0], 004) = 0
+[unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023] fchmod(4</root/rpmbuild/BUILD/strace-5.13/tests/fchmod-y--secontext_full_mismatch.dir/fchmod_subdir/fchmod_sample_file (deleted)> [unconfined_u:object_r:admin_home_t:s0], 051) = 0
+[unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023] fchmod(4</root/rpmbuild/BUILD/strace-5.13/tests/fchmod-y--secontext_full_mismatch.dir/fchmod_subdir/fchmod_sample_file (deleted)> [unconfined_u:object_r:admin_home_t:s0], 004) = 0
+++ exited with 0 +++
+ fail_ '../../src/strace -a15 -y --secontext=full,mismatch -e trace=fchmod ../fchmod-y--secontext_full_mismatch output mismatch'
+ warn_ 'fchmod-y--secontext_full_mismatch.gen.test: failed test: ../../src/strace -a15 -y --secontext=full,mismatch -e trace=fchmod ../fchmod-y--secontext_full_mismatch output mismatch'
+ printf '%s\n' 'fchmod-y--secontext_full_mismatch.gen.test: failed test: ../../src/strace -a15 -y --secontext=full,mismatch -e trace=fchmod ../fchmod-y--secontext_full_mismatch output mismatch'
fchmod-y--secontext_full_mismatch.gen.test: failed test: ../../src/strace -a15 -y --secontext=full,mismatch -e trace=fchmod ../fchmod-y--secontext_full_mismatch output mismatch
+ exit 1
FAIL fchmod-y--secontext_full_mismatch.gen.test (exit status: 1)
that happens due to the fact that the get_expected_filecontext() call
is made against the path with the " (deleted)" part, which is wrong (it
is more wrong than shown above when a file with the path that ends with
" (deleted)" exists). Moreover, it would be incorrect to call stat()
on that path.
Let's factor out the common part of the code and simply call it
from selinux_getfdcon, then use the st_mode from the procfs link.
* src/defs.h (get_proc_pid_fd_path): New declaration.
* src/pathtrace.c (get)proc_pid_fd_path): New function, part
of getfdpath_pid that performs link resolution and processing
of the result.
(getfdpath_pid): Call get_proc_pid_fd_path after PID resolution.
* src/secontext.c (get_expected_filecontext): Add mode parameter, use
it in selabel_lookup call instead of retrieveing file mode using stat()
if it is not -1.
(selinux_getfdcon): Call get_proc_pid_fd_path instead
of open-coding path resolution code, call stat() on the procfs link
and pass the retrieved st_mode to the get_expected_filecontext call.
(selinux_getfilecon): Pass -1 as mode in the get_expected_filecontext
call.
Reported-by: Václav Kadlčík <vkadlcik@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2087693
---
src/defs.h | 15 +++++++++++++++
src/pathtrace.c | 26 ++++++++++++++++++--------
src/secontext.c | 35 +++++++++++++++++++++--------------
3 files changed, 54 insertions(+), 22 deletions(-)
Index: strace-5.18/src/defs.h
===================================================================
--- strace-5.18.orig/src/defs.h 2022-07-12 18:22:01.563254140 +0200
+++ strace-5.18/src/defs.h 2022-07-12 18:22:06.202199392 +0200
@@ -785,6 +785,21 @@
return pathtrace_match_set(tcp, &global_path_set);
}
+/**
+ * Resolves a path for a fd procfs PID proc_pid (the one got from
+ * get_proc_pid()).
+ *
+ * @param proc_pid PID number in /proc, obtained with get_proc_pid().
+ * @param fd FD to resolve path for.
+ * @param buf Buffer to store the resolved path in.
+ * @param bufsize The size of buf.
+ * @param deleted If non-NULL, set to true if the path associated with the FD
+ * seems to have been unlinked and to false otherwise.
+ * @return Number of bytes written including terminating '\0'.
+ */
+extern int get_proc_pid_fd_path(int proc_pid, int fd, char *buf,
+ unsigned bufsize, bool *deleted);
+
extern int getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize,
bool *deleted);
Index: strace-5.18/src/pathtrace.c
===================================================================
--- strace-5.18.orig/src/pathtrace.c 2022-07-12 18:22:01.532254506 +0200
+++ strace-5.18/src/pathtrace.c 2022-07-12 18:22:06.202199392 +0200
@@ -77,11 +77,9 @@
set->paths_selected[set->num_selected++] = path;
}
-/*
- * Get path associated with fd of a process with pid.
- */
int
-getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize, bool *deleted)
+get_proc_pid_fd_path(int proc_pid, int fd, char *buf, unsigned bufsize,
+ bool *deleted)
{
char linkpath[sizeof("/proc/%u/fd/%u") + 2 * sizeof(int)*3];
ssize_t n;
@@ -89,10 +87,6 @@
if (fd < 0)
return -1;
- int proc_pid = get_proc_pid(pid);
- if (!proc_pid)
- return -1;
-
xsprintf(linkpath, "/proc/%u/fd/%u", proc_pid, fd);
n = readlink(linkpath, buf, bufsize - 1);
if (n < 0)
@@ -143,6 +137,22 @@
}
/*
+ * Get path associated with fd of a process with pid.
+ */
+int
+getfdpath_pid(pid_t pid, int fd, char *buf, unsigned bufsize, bool *deleted)
+{
+ if (fd < 0)
+ return -1;
+
+ int proc_pid = get_proc_pid(pid);
+ if (!proc_pid)
+ return -1;
+
+ return get_proc_pid_fd_path(proc_pid, fd, buf, bufsize, deleted);
+}
+
+/*
* Add a path to the set we're tracing. Also add the canonicalized
* version of the path. Specifying NULL will delete all paths.
*/
Index: strace-5.18/src/secontext.c
===================================================================
--- strace-5.18.orig/src/secontext.c 2022-07-12 18:22:01.564254128 +0200
+++ strace-5.18/src/secontext.c 2022-07-12 18:22:06.203199380 +0200
@@ -62,7 +62,7 @@
}
static int
-get_expected_filecontext(const char *path, char **secontext)
+get_expected_filecontext(const char *path, char **secontext, int mode)
{
static struct selabel_handle *hdl;
@@ -80,12 +80,7 @@
}
}
- strace_stat_t stb;
- if (stat_file(path, &stb) < 0) {
- return -1;
- }
-
- return selabel_lookup(hdl, secontext, path, stb.st_mode);
+ return selabel_lookup(hdl, secontext, path, mode);
}
/*
@@ -130,16 +125,22 @@
/*
* We need to resolve the path, because selabel_lookup() doesn't
- * resolve anything. Using readlink() is sufficient here.
+ * resolve anything.
*/
+ char buf[PATH_MAX + 1];
+ ssize_t n = get_proc_pid_fd_path(proc_pid, fd, buf, sizeof(buf), NULL);
+ if ((size_t) n >= (sizeof(buf) - 1))
+ return 0;
- char buf[PATH_MAX];
- ssize_t n = readlink(linkpath, buf, sizeof(buf));
- if ((size_t) n >= sizeof(buf))
+ /*
+ * We retrieve stat() here since the path the procfs link resolves into
+ * may be reused by a different file with different context.
+ */
+ strace_stat_t st;
+ if (stat_file(linkpath, &st))
return 0;
- buf[n] = '\0';
- get_expected_filecontext(buf, expected);
+ get_expected_filecontext(buf, expected, st.st_mode);
return 0;
}
@@ -190,7 +191,13 @@
if (!resolved)
return 0;
- get_expected_filecontext(resolved, expected);
+ strace_stat_t st;
+ if (stat_file(resolved, &st) < 0)
+ goto out;
+
+ get_expected_filecontext(resolved, expected, st.st_mode);
+
+out:
free(resolved);
return 0;

View File

@ -0,0 +1,70 @@
From 5338636cd9ae7f53ed73f1a7909db03189ea2ff3 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Mon, 4 Jul 2022 12:29:22 +0200
Subject: [PATCH] tests/bpf: fix sloppy low FD number usage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
FD 42 can already be opened, so close it. Otherwise, it may lead
to the following test failure:
-bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}], iter_info_len=5}}, 28) = 841540765612359407 (INJECTED)
+bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42</var/tmp/restraintd/logs/146893626/task.log>}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}], iter_info_len=5}}, 28) = 841540765612359407 (INJECTED)
bpf(BPF_LINK_CREATE, 0x3ff95574fe5, 28) = 841540765612359407 (INJECTED)
-bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}, ... /* 0x3ff9555d000 */], iter_info_len=6}}, 28) = 841540765612359407 (INJECTED)
+bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42</var/tmp/restraintd/logs/146893626/task.log>}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}, ... /* 0x3ff9555d000 */], iter_info_len=6}}, 28) = 841540765612359407 (INJECTED)
[...]
FAIL bpf-success-long-y.test (exit status: 1)
* tests/bpf.c (init_BPF_LINK_CREATE_attr7): Close iter_info_data[1] fd.
Fixes: v5.18~18 "bpf: improve bpf(BPF_LINK_CREATE) decoding"
Reported-by: Lenka Špačková <lkuprova@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103137
---
tests/bpf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/bpf.c b/tests/bpf.c
index 82d870e..6c1ffd4 100644
--- a/tests/bpf.c
+++ b/tests/bpf.c
@@ -1557,6 +1557,8 @@ init_BPF_LINK_CREATE_attr7(struct bpf_attr_check *check, size_t idx)
{
struct BPF_LINK_CREATE_struct *attr = &check->data.BPF_LINK_CREATE_data;
+ close(iter_info_data[1]);
+
if (!iter_info_data_p) {
iter_info_data_p = tail_memdup(iter_info_data,
sizeof(iter_info_data));
diff --git a/tests-m32/bpf.c b/tests-m32/bpf.c
index 82d870e..6c1ffd4 100644
--- a/tests-m32/bpf.c
+++ b/tests-m32/bpf.c
@@ -1557,6 +1557,8 @@ init_BPF_LINK_CREATE_attr7(struct bpf_attr_check *check, size_t idx)
{
struct BPF_LINK_CREATE_struct *attr = &check->data.BPF_LINK_CREATE_data;
+ close(iter_info_data[1]);
+
if (!iter_info_data_p) {
iter_info_data_p = tail_memdup(iter_info_data,
sizeof(iter_info_data));
diff --git a/tests-mx32/bpf.c b/tests-mx32/bpf.c
index 82d870e..6c1ffd4 100644
--- a/tests-mx32/bpf.c
+++ b/tests-mx32/bpf.c
@@ -1557,6 +1557,8 @@ init_BPF_LINK_CREATE_attr7(struct bpf_attr_check *check, size_t idx)
{
struct BPF_LINK_CREATE_struct *attr = &check->data.BPF_LINK_CREATE_data;
+ close(iter_info_data[1]);
+
if (!iter_info_data_p) {
iter_info_data_p = tail_memdup(iter_info_data,
sizeof(iter_info_data));
--
2.1.4

View File

@ -1,27 +1,26 @@
Limit the scope of qual_fault.tests on aarch64 as otherwise it takes
unacceptable amount of time on available builders (more than an hour).
Index: strace-5.7/tests/qual_fault.test
Index: strace-5.17/tests/qual_fault.test
===================================================================
--- strace-5.7.orig/tests/qual_fault.test 2020-06-02 10:41:25.870177356 +0200
+++ strace-5.7/tests/qual_fault.test 2020-06-02 10:48:33.284302800 +0200
@@ -83,19 +83,35 @@
--- strace-5.17.orig/tests/qual_fault.test 2022-06-09 15:47:28.871554186 +0200
+++ strace-5.17/tests/qual_fault.test 2022-06-09 15:50:50.016108370 +0200
@@ -83,19 +83,36 @@
done
}
-for err in '' ENOSYS 22 einval; do
+
+case "$STRACE_ARCH" in
+ aarch64)
+ ERRS='EnoSys 22'
+ NUMBERS1='2'
+ NUMBERS2='3'
+ NUMBERS3='5'
+ NUMBERS4='7'
+ ;;
+ *)
+ ERRS='ENOSYS 22 einval'
+ NUMBERS1='1 2 3 5 7 11'
+ NUMBERS2='1 2 3 5 7 11'
+ NUMBERS3='1 2 3 5 7 11'
+ NUMBERS1='1 2 3 7'
+ NUMBERS2='1 2 5 11'
+ NUMBERS3='1 2 3 7'
+ NUMBERS4='1 2 7 11'
+ ;;
+esac
+
@ -31,30 +30,30 @@ Index: strace-5.7/tests/qual_fault.test
writev $fault "$err" '' '' '' 1 -efault=chdir
check_fault_injection \
writev $fault "$err" '' '' '' 1 -efault=chdir -efault=none
- for F in 1 2 3 5 7 11; do
- for F in 1 2 3 7; do
+ for F in $(echo $NUMBERS1); do
check_fault_injection \
writev $fault "$err" $F '' '' 1
check_fault_injection \
writev $fault "$err" $F '' + 1
- for L in 1 2 3 5 7 11; do
- for L in 1 2 5 11; do
+ for L in $(echo $NUMBERS2); do
[ "$L" -ge "$F" ] ||
continue
check_fault_injection \
@@ -104,12 +119,12 @@
@@ -104,12 +121,12 @@
writev $fault "$err" $F $L + 1
done
- for S in 1 2 3 5 7 11; do
+ for S in $(echo $NUMBERS2); do
- for S in 1 2 3 7; do
+ for S in $(echo $NUMBERS3); do
check_fault_injection \
writev $fault "$err" $F '' $S 1
check_fault_injection \
writev $fault "$err" $F '' $S 4
- for L in 1 2 3 5 7 11; do
+ for L in $(echo $NUMBERS3); do
- for L in 1 2 7 11; do
+ for L in $(echo $NUMBERS4); do
[ "$L" -ge "$F" ] ||
continue
check_fault_injection \

View File

@ -1,17 +0,0 @@
Index: strace-5.7/unwind.c
===================================================================
--- strace-5.7.orig/unwind.c 2018-12-10 01:00:00.000000000 +0100
+++ strace-5.7/unwind.c 2020-06-02 11:13:42.777871147 +0200
@@ -9,6 +9,12 @@
#include "unwind.h"
#ifdef USE_DEMANGLE
+/*
+ * demangle.h defines ARRAY_SIZE without proper guard, and its definition
+ * is "good enough" for us.
+ */
+#undef ARRAY_SIZE
+
# if defined HAVE_DEMANGLE_H
# include <demangle.h>
# elif defined HAVE_LIBIBERTY_DEMANGLE_H

View File

@ -1,135 +0,0 @@
Index: strace-5.7/tests/ipc_msg.c
===================================================================
--- strace-5.7.orig/tests/ipc_msg.c 2021-08-24 21:39:53.102419769 +0200
+++ strace-5.7/tests/ipc_msg.c 2021-08-24 21:43:00.670841489 +0200
@@ -55,8 +55,9 @@
* Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
* glibc skips msgctl syscall invocations and returns EINVAL
* for invalid msgctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_MSGCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests/ipc_shm.c
===================================================================
--- strace-5.7.orig/tests/ipc_shm.c 2021-08-24 21:39:53.124419583 +0200
+++ strace-5.7/tests/ipc_shm.c 2021-08-24 21:43:00.670841489 +0200
@@ -45,8 +45,9 @@
* Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
* glibc skips shmctl syscall invocations and returns EINVAL
* for invalid shmctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_SHMCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests/ipc_sem.c
===================================================================
--- strace-5.7.orig/tests/ipc_sem.c 2021-08-24 21:39:53.135419490 +0200
+++ strace-5.7/tests/ipc_sem.c 2021-08-24 21:43:00.670841489 +0200
@@ -26,8 +26,9 @@
* Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
* glibc skips semctl syscall invocations and returns EINVAL
* for invalid semctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_SEMCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests-m32/ipc_msg.c
===================================================================
--- strace-5.7.orig/tests-m32/ipc_msg.c 2021-08-24 21:39:53.102419769 +0200
+++ strace-5.7/tests-m32/ipc_msg.c 2021-08-24 21:43:00.670841489 +0200
@@ -55,8 +55,9 @@
* Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
* glibc skips msgctl syscall invocations and returns EINVAL
* for invalid msgctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_MSGCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests-m32/ipc_shm.c
===================================================================
--- strace-5.7.orig/tests-m32/ipc_shm.c 2021-08-24 21:39:53.124419583 +0200
+++ strace-5.7/tests-m32/ipc_shm.c 2021-08-24 21:43:00.671841481 +0200
@@ -45,8 +45,9 @@
* Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
* glibc skips shmctl syscall invocations and returns EINVAL
* for invalid shmctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_SHMCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests-m32/ipc_sem.c
===================================================================
--- strace-5.7.orig/tests-m32/ipc_sem.c 2021-08-24 21:39:53.135419490 +0200
+++ strace-5.7/tests-m32/ipc_sem.c 2021-08-24 21:43:00.671841481 +0200
@@ -26,8 +26,9 @@
* Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
* glibc skips semctl syscall invocations and returns EINVAL
* for invalid semctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_SEMCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests-mx32/ipc_msg.c
===================================================================
--- strace-5.7.orig/tests-mx32/ipc_msg.c 2021-08-24 21:39:53.102419769 +0200
+++ strace-5.7/tests-mx32/ipc_msg.c 2021-08-24 21:43:00.671841481 +0200
@@ -55,8 +55,9 @@
* Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
* glibc skips msgctl syscall invocations and returns EINVAL
* for invalid msgctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_MSGCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests-mx32/ipc_shm.c
===================================================================
--- strace-5.7.orig/tests-mx32/ipc_shm.c 2021-08-24 21:39:53.124419583 +0200
+++ strace-5.7/tests-mx32/ipc_shm.c 2021-08-24 21:43:00.671841481 +0200
@@ -45,8 +45,9 @@
* Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
* glibc skips shmctl syscall invocations and returns EINVAL
* for invalid shmctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_SHMCTL_BOGUS_CMD 0
#endif
Index: strace-5.7/tests-mx32/ipc_sem.c
===================================================================
--- strace-5.7.orig/tests-mx32/ipc_sem.c 2021-08-24 21:39:53.136419481 +0200
+++ strace-5.7/tests-mx32/ipc_sem.c 2021-08-24 21:43:00.672841472 +0200
@@ -26,8 +26,9 @@
* Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
* glibc skips semctl syscall invocations and returns EINVAL
* for invalid semctl commands.
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
*/
-#if GLIBC_PREREQ_GE(2, 32)
+#if GLIBC_PREREQ_GE(2, 28)
# define TEST_SEMCTL_BOGUS_CMD 0
#endif

View File

@ -1,14 +1,14 @@
Summary: Tracks and displays system calls associated with a running process
Name: strace
Version: 5.7
Release: 3%{?dist}
Version: 5.18
Release: 2%{?dist}
# The test suite is GPLv2+, all the rest is LGPLv2.1+.
License: LGPL-2.1+ and GPL-2.0+
Group: Development/Debuggers
URL: https://strace.io/
Source: https://strace.io/files/%{version}/%{name}-%{version}.tar.xz
BuildRequires: libacl-devel time gcc gzip
BuildRequires: libacl-devel time gcc gzip make
BuildRequires: pkgconfig(bluez)
BuildRequires: elfutils-devel binutils-devel
BuildRequires: libselinux-devel
@ -144,97 +144,141 @@ BuildRequires: libselinux-devel
#Patch111: 0111-xlat-update-uring_ops.patch
## v5.7~68 "tests: correct error message in io_uring_register test"
#Patch112: 0112-tests-correct-error-message-in-io_uring_register-tes.patch
# v5.8~58 "io_uring: Remove struct io_cqring_offsets compile time asserts"
Patch113: 0113-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
# v5.8~57 "io_uring: Add io_cqring_offset flags"
Patch114: 0114-io_uring-Add-io_cqring_offset-flags.patch
# v5.8~47 "xlat: update IORING_* constants"
Patch115: 0115-xlat-update-IORING_-constants.patch
## v5.8~58 "io_uring: Remove struct io_cqring_offsets compile time asserts"
#Patch113: 0113-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
## v5.8~57 "io_uring: Add io_cqring_offset flags"
#Patch114: 0114-io_uring-Add-io_cqring_offset-flags.patch
## v5.8~47 "xlat: update IORING_* constants"
#Patch115: 0115-xlat-update-IORING_-constants.patch
## v5.5~71 "macros.h: introduce sizeof_field macro"
#Patch116: 0116-macros.h-introduce-sizeof_field-macro.patch
## v5.5~49 "types: new infrastructure for automatic checking of structure types"
#Patch117: 0117-types-new-infrastructure-for-automatic-checking-of-s.patch
# v5.8~59 "types: skip field lines that start with comments"
Patch118: 0118-types-skip-field-lines-that-start-with-comments.patch
## v5.8~59 "types: skip field lines that start with comments"
#Patch118: 0118-types-skip-field-lines-that-start-with-comments.patch
## PID namespace translation support
## https://bugzilla.redhat.com/1035434
## https://bugzilla.redhat.com/1725113 https://bugzilla.redhat.com/1790836
## https://bugzilla.redhat.com/1804334 https://bugzilla.redhat.com/1807458
# v5.8~62 "print_fields.h: add PRINT_FIELD_LEN macro"
Patch119: 0119-print_fields.h-add-PRINT_FIELD_LEN-macro.patch
# v5.8~61 "Move ilog* functions from util.c to defs.h"
Patch120: 0120-Move-ilog-functions-from-util.c-to-defs.h.patch
#Patch119: 0119-print_fields.h-add-PRINT_FIELD_LEN-macro.patch
## v5.8~61 "Move ilog* functions from util.c to defs.h"
#Patch120: 0120-Move-ilog-functions-from-util.c-to-defs.h.patch
## v5.8~59 "types: skip field lines that start with comments"
#Patch121: 0121-types-skip-field-lines-that-start-with-comments.patch
# v5.8~54 "tests/inject-nf.test: replace getpid with geteuid"
Patch122: 0122-tests-inject-nf.test-replace-getpid-with-geteuid.patch
# v5.8~18 "fcntl: use print_fields.h macros"
Patch123: 0123-fcntl-use-print_fields.h-macros.patch
# v5.8~17 "kcmp: fix KCMP_FILE decoding"
Patch124: 0124-kcmp-fix-KCMP_FILE-decoding.patch
# v5.8~15 "printsiginfo: fix printing of siginfo_t.si_pid and siginfo_t.si_uid"
Patch125: 0125-printsiginfo-fix-printing-of-siginfo_t.si_pid-and-si.patch
# v5.8~14 "Use PRINT_FIELD_UID instead of printuid where appropriate"
Patch126: 0126-Use-PRINT_FIELD_UID-instead-of-printuid-where-approp.patch
# v5.8~10 "Consistently print process ids as signed integers"
Patch127: 0127-Consistently-print-process-ids-as-signed-integers.patch
# v5.8~9 "Remove tcb parameter of read_int_from_file"
Patch128: 0128-Remove-tcb-parameter-of-read_int_from_file.patch
# v5.8~6 "Add "struct tcb *" parameters to various functions"
Patch129: 0129-Add-struct-tcb-parameters-to-various-functions.patch
# v5.8~53 "Modify %process class: trace syscalls associated with process lifecycle"
Patch130: 0130-Modify-process-class-trace-syscalls-associated-with-.patch
# v5.8~5 "Introduce SYS_FUNC(tkill)"
Patch131: 0131-Introduce-SYS_FUNC-tkill.patch
# v5.8~4 "tests: check decoding of tkill syscall"
Patch132: 0132-tests-check-decoding-of-tkill-syscall.patch
# v5.8~3 "tests: check decoding of tgkill syscall"
Patch133: 0133-tests-check-decoding-of-tgkill-syscall.patch
# v5.8-5-gdea0284 "PID namespace translation support"
Patch134: 0134-PID-namespace-translation-support.patch
# v5.8-6-g173257d "Use printpid in decoders"
Patch135: 0135-Use-printpid-in-decoders.patch
# v5.8-7-g18c2208 "Use get_proc_pid for /proc paths"
Patch136: 0136-Use-get_proc_pid-for-proc-paths.patch
# v5.8-8-g7ecee07 "Implement testing framework for pidns"
Patch137: 0137-Implement-testing-framework-for-pidns.patch
# v5.8-9-gf350ce0 "Add tests for PID namespace translation"
Patch138: 0138-Add-tests-for-PID-namespace-translation.patch
## v5.8~54 "tests/inject-nf.test: replace getpid with geteuid"
#Patch122: 0122-tests-inject-nf.test-replace-getpid-with-geteuid.patch
## v5.8~18 "fcntl: use print_fields.h macros"
#Patch123: 0123-fcntl-use-print_fields.h-macros.patch
## v5.8~17 "kcmp: fix KCMP_FILE decoding"
#Patch124: 0124-kcmp-fix-KCMP_FILE-decoding.patch
## v5.8~15 "printsiginfo: fix printing of siginfo_t.si_pid and siginfo_t.si_uid"
#Patch125: 0125-printsiginfo-fix-printing-of-siginfo_t.si_pid-and-si.patch
## v5.8~14 "Use PRINT_FIELD_UID instead of printuid where appropriate"
#Patch126: 0126-Use-PRINT_FIELD_UID-instead-of-printuid-where-approp.patch
## v5.8~10 "Consistently print process ids as signed integers"
#Patch127: 0127-Consistently-print-process-ids-as-signed-integers.patch
## v5.8~9 "Remove tcb parameter of read_int_from_file"
#Patch128: 0128-Remove-tcb-parameter-of-read_int_from_file.patch
## v5.8~6 "Add "struct tcb *" parameters to various functions"
#Patch129: 0129-Add-struct-tcb-parameters-to-various-functions.patch
## v5.8~53 "Modify %process class: trace syscalls associated with process lifecycle"
#Patch130: 0130-Modify-process-class-trace-syscalls-associated-with-.patch
## v5.8~5 "Introduce SYS_FUNC(tkill)"
#Patch131: 0131-Introduce-SYS_FUNC-tkill.patch
## v5.8~4 "tests: check decoding of tkill syscall"
#Patch132: 0132-tests-check-decoding-of-tkill-syscall.patch
## v5.8~3 "tests: check decoding of tgkill syscall"
#Patch133: 0133-tests-check-decoding-of-tgkill-syscall.patch
## v5.8-5-gdea0284 "PID namespace translation support"
#Patch134: 0134-PID-namespace-translation-support.patch
## v5.8-6-g173257d "Use printpid in decoders"
#Patch135: 0135-Use-printpid-in-decoders.patch
## v5.8-7-g18c2208 "Use get_proc_pid for /proc paths"
#Patch136: 0136-Use-get_proc_pid-for-proc-paths.patch
## v5.8-8-g7ecee07 "Implement testing framework for pidns"
#Patch137: 0137-Implement-testing-framework-for-pidns.patch
## v5.8-9-gf350ce0 "Add tests for PID namespace translation"
#Patch138: 0138-Add-tests-for-PID-namespace-translation.patch
# v5.12~55 "tests: add fchmod-y test"
Patch142: 0142-tests-add-fchmod-y-test.patch
# v5.12~54 "tests: introduce create_and_enter_subdir and leave_and_remove_subdir"
Patch143: 0143-tests-introduce-create_and_enter_subdir-and-leave_an.patch
# v5.8~36 "tests: check decoding of faccessat syscall in -P, -y, and -yy modes"
Patch144: 0144-tests-check-decoding-of-faccessat-syscall-in-P-y-and.patch
# v5.12~97 "xmalloc: introduce xasprintf"
Patch145: 0145-xmalloc-introduce-xasprintf.patch
# v5.12~96 "tests: use xasprintf instead of asprintf"
Patch146: 0146-tests-use-xasprintf-instead-of-asprintf.patch
# v5.12~156 "file_handle: print f_handle as a hexadecimal string"
Patch147: 0147-file_handle-print-f_handle-as-a-hexadecimal-string.patch
# v5.10~47 "tests: fix execve test with fresh linux kernels"
Patch148: 0148-tests-fix-execve-test-with-fresh-linux-kernels.patch
# v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
Patch149: 0149-Implement-secontext-full-option-to-display-SELinux-c.patch
## v5.12~55 "tests: add fchmod-y test"
#Patch142: 0142-tests-add-fchmod-y-test.patch
## v5.12~54 "tests: introduce create_and_enter_subdir and leave_and_remove_subdir"
#Patch143: 0143-tests-introduce-create_and_enter_subdir-and-leave_an.patch
## v5.8~36 "tests: check decoding of faccessat syscall in -P, -y, and -yy modes"
#Patch144: 0144-tests-check-decoding-of-faccessat-syscall-in-P-y-and.patch
## v5.12~97 "xmalloc: introduce xasprintf"
#Patch145: 0145-xmalloc-introduce-xasprintf.patch
## v5.12~96 "tests: use xasprintf instead of asprintf"
#Patch146: 0146-tests-use-xasprintf-instead-of-asprintf.patch
## v5.12~156 "file_handle: print f_handle as a hexadecimal string"
#Patch147: 0147-file_handle-print-f_handle-as-a-hexadecimal-string.patch
## v5.10~47 "tests: fix execve test with fresh linux kernels"
#Patch148: 0148-tests-fix-execve-test-with-fresh-linux-kernels.patch
## v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
#Patch149: 0149-Implement-secontext-full-option-to-display-SELinux-c.patch
# v5.13-14-g9623154 "m4/mpers.m4: generate HAVE_*_SELINUX_RUNTIME config defines"
Patch155: 0155-m4-mpers.m4-generate-HAVE_-_SELINUX_RUNTIME-config-d.patch
#Patch155: 0155-m4-mpers.m4-generate-HAVE_-_SELINUX_RUNTIME-config-d.patch
# v5.9~28 "Introduce GLIBC_PREREQ_GE and GLIBC_PREREQ_LT macros"
Patch156: 0156-Introduce-GLIBC_PREREQ_GE-and-GLIBC_PREREQ_LT-macros.patch
# v5.9~27 "tests/ipc_msg.c: disable TEST_MSGCTL_BOGUS_ADDR on glibc >= 2.32"
Patch157: 0157-tests-ipc_msg.c-disable-TEST_MSGCTL_BOGUS_ADDR-on-gl.patch
# v5.10~46 "tests: disable TEST_MSGCTL_BOGUS_ADDR in ipc_msg test on glibc >= 2.31"
Patch158: 0158-tests-disable-TEST_MSGCTL_BOGUS_ADDR-in-ipc_msg-test.patch
# v5.10~22 "tests: disable tests for invalid msgctl commands on glibc >= 2.32"
Patch159: 0159-tests-disable-tests-for-invalid-msgctl-commands-on-g.patch
# v5.9~11 "tests: disable shmctl IPC_STAT test with a bogus address on glibc >= 2.32"
Patch160: 0160-tests-disable-shmctl-IPC_STAT-test-with-a-bogus-addr.patch
# v5.9~10 "tests: disable tests for invalid shmctl commands on glibc >= 2.32"
Patch161: 0161-tests-disable-tests-for-invalid-shmctl-commands-on-g.patch
# v5.9~12 "tests: disable tests for invalid semctl commands on glibc >= 2.32"
Patch162: 0162-tests-disable-tests-for-invalid-semctl-commands-on-g.patch
## v5.9~28 "Introduce GLIBC_PREREQ_GE and GLIBC_PREREQ_LT macros"
#Patch156: 0156-Introduce-GLIBC_PREREQ_GE-and-GLIBC_PREREQ_LT-macros.patch
## v5.9~27 "tests/ipc_msg.c: disable TEST_MSGCTL_BOGUS_ADDR on glibc >= 2.32"
#Patch157: 0157-tests-ipc_msg.c-disable-TEST_MSGCTL_BOGUS_ADDR-on-gl.patch
## v5.10~46 "tests: disable TEST_MSGCTL_BOGUS_ADDR in ipc_msg test on glibc >= 2.31"
#Patch158: 0158-tests-disable-TEST_MSGCTL_BOGUS_ADDR-in-ipc_msg-test.patch
## v5.10~22 "tests: disable tests for invalid msgctl commands on glibc >= 2.32"
#Patch159: 0159-tests-disable-tests-for-invalid-msgctl-commands-on-g.patch
## v5.9~11 "tests: disable shmctl IPC_STAT test with a bogus address on glibc >= 2.32"
#Patch160: 0160-tests-disable-shmctl-IPC_STAT-test-with-a-bogus-addr.patch
## v5.9~10 "tests: disable tests for invalid shmctl commands on glibc >= 2.32"
#Patch161: 0161-tests-disable-tests-for-invalid-shmctl-commands-on-g.patch
## v5.9~12 "tests: disable tests for invalid semctl commands on glibc >= 2.32"
#Patch162: 0162-tests-disable-tests-for-invalid-semctl-commands-on-g.patch
## v5.13-55-g6b2191f "filter_qualify: free allocated data on the error path exit of parse_poke_token"
#Patch163: 0163-filter_qualify-free-allocated-data-on-the-error-path.patch
## v5.13-56-g80dc60c "macros: expand BIT macros, add MASK macros; add *_SAFE macros"
#Patch164: 0164-macros-expand-BIT-macros-add-MASK-macros-add-_SAFE-m.patch
## v5.13-58-g94ae5c2 "trie: use BIT* and MASK* macros"
#Patch165: 0165-trie-use-BIT-and-MASK-macros.patch
## v5.13-65-g41b753e "tee: rewrite num_params access in tee_fetch_buf_data"
#Patch166: 0166-tee-rewrite-num_params-access-in-tee_fetch_buf_data.patch
## v5.15~1 "print_ifindex: fix IFNAME_QUOTED_SZ definition"
#Patch167: 0167-print_ifindex-fix-IFNAME_QUOTED_SZ-definition.patch
## v5.15~18 "m4: fix st_SELINUX check"
#Patch168: 0168-m4-fix-st_SELINUX-check.patch
## v5.16~31 "Implement displaying of expected context upon mismatch"
#Patch169: 0169-Implement-displaying-of-expected-context-upon-mismat.patch
#Patch170: 0170-tests-linkat-reset-errno-before-SELinux-context-mani.patch
#Patch171: 0171-tests-secontext-add-secontext-field-getters.patch
#Patch172: 0172-tests-linkat-provide-fallback-values-for-secontext-f.patch
#Patch173: 0173-tests-secontext-eliminate-separate-secontext_format-.patch
#Patch174: 0174-tests-linkat-reset-context-to-the-expected-one-if-a-.patch
## https://bugzilla.redhat.com/2103068 covscan fixes
# v5.18-5-g2bf0696 "src/xlat: remove remnants of unnecessary idx usage in xlookup"
Patch175: 0175-src-xlat-remove-remnants-of-unnecessary-idx-usage-in.patch
# v5.18-7-ge604d7b "strauss: tips whitespace and phrasing cleanups"
Patch176: 0176-strauss-tips-whitespace-and-phrasing-cleanups.patch
# v5.18-8-g968789d "strauss: fix off-by-one error in strauss array access"
Patch177: 0177-strauss-fix-off-by-one-error-in-strauss-array-access.patch
# v5.18-9-g6d3e97e "util: add offs sanity check to print_clock_t"
Patch178: 0178-util-add-offs-sanity-check-to-print_clock_t.patch
## https://bugzilla.redhat.com/2087693
# v5.18-13-g960e78f "secontext: print context of Unix socket's sun_path field"
Patch179: 0179-secontext-print-context-of-Unix-socket-s-sun_path-fi.patch
# v5.18-18-g676979f "pathtrace, util: do not print " (deleted)" as part of the path"
Patch180: 0180-pathtrace-util-do-not-print-deleted-as-part-of-the-p.patch
# v5.18-19-g3f0e534 "secontext: fix expected SELinux context check for unlinked FDs"
Patch181: 0181-secontext-fix-expected-SELinux-context-check-for-unl.patch
## https://bugzilla.redhat.com/2103137
# v5.18-21-g5338636 "tests/bpf: fix sloppy low FD number usage"
Patch182: 0182-tests-bpf-fix-sloppy-low-FD-number-usage.patch
### Wire up rseq and kexec_file_load in order to avoid kexec_file_load
### test failure on aarch64. Addresses https://bugzilla.redhat.com/1676045
@ -250,12 +294,14 @@ Patch162: 0162-tests-disable-tests-for-invalid-semctl-commands-on-g.patch
Patch2001: 2001-limit-qual_fault-scope-on-aarch64.patch
### RHEL8.2-only: disable ksysent test due to missing rebase
#Patch2002: 2002-disable-ksysent-on-8.2.patch
## RHEL-only: avoid ARRAY_SIZE macro re-definition in libiberty.h
Patch2003: 2003-undef-ARRAY_SIZE.patch
## RHEL-only: glibc-2.32.9000-147-ga16d2abd496bd974a882,
## glibc-2.32.9000-149-gbe9b0b9a012780a403a2 and
## glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f have been backported in RHEL.
Patch2004: 2004-glibc-msgctl-semctl-shmctl-backport-workaround.patch
### RHEL-only: avoid ARRAY_SIZE macro re-definition in libiberty.h
## No longer needed, since upstream commit v5.14~14
#Patch2003: 2003-undef-ARRAY_SIZE.patch
### RHEL-only: glibc-2.32.9000-147-ga16d2abd496bd974a882,
### glibc-2.32.9000-149-gbe9b0b9a012780a403a2 and
### glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f have been backported in RHEL.
## No longer needed, since upstream commit v5.15~9
#Patch2004: 2004-glibc-msgctl-semctl-shmctl-backport-workaround.patch
# We no longer need to build a separate strace32 binary, but we don't want
@ -270,6 +316,12 @@ Provides: strace32 = %{evr}
Obsoletes: strace32 < 4.24
%endif
# Fallback definitions for make_build/make_install macros
%{?!__make: %global __make %_bindir/make}
%{?!__install: %global __install %_bindir/install}
%{?!make_build: %global make_build %__make %{?_smp_mflags}}
%{?!make_install: %global make_install %__make install DESTDIR="%{?buildroot}" INSTALL="%__install -p"}
%description
The strace program intercepts and records the system calls called and
received by a running process. Strace can print a record of each
@ -332,48 +384,69 @@ received by a process.
#%patch110 -p1
#%patch111 -p1
#%patch112 -p1
%patch113 -p1
%patch114 -p1
%patch115 -p1
#%patch113 -p1
#%patch114 -p1
#%patch115 -p1
#%patch116 -p1
#%patch117 -p1
%patch118 -p1
%patch119 -p1
%patch120 -p1
#%patch118 -p1
#%patch119 -p1
#%patch120 -p1
#%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1
%patch127 -p1
%patch128 -p1
%patch129 -p1
%patch130 -p1
%patch131 -p1
%patch132 -p1
%patch133 -p1
%patch134 -p1
%patch135 -p1
%patch136 -p1
%patch137 -p1
%patch138 -p1
%patch142 -p1
%patch143 -p1
%patch144 -p1
%patch145 -p1
%patch146 -p1
%patch147 -p1
%patch148 -p1
%patch149 -p1
%patch155 -p1
%patch156 -p1
%patch157 -p1
%patch158 -p1
%patch159 -p1
%patch160 -p1
%patch161 -p1
%patch162 -p1
#%patch122 -p1
#%patch123 -p1
#%patch124 -p1
#%patch125 -p1
#%patch126 -p1
#%patch127 -p1
#%patch128 -p1
#%patch129 -p1
#%patch130 -p1
#%patch131 -p1
#%patch132 -p1
#%patch133 -p1
#%patch134 -p1
#%patch135 -p1
#%patch136 -p1
#%patch137 -p1
#%patch138 -p1
#%patch142 -p1
#%patch143 -p1
#%patch144 -p1
#%patch145 -p1
#%patch146 -p1
#%patch147 -p1
#%patch148 -p1
#%patch149 -p1
#%patch155 -p1
#%patch156 -p1
#%patch157 -p1
#%patch158 -p1
#%patch159 -p1
#%patch160 -p1
#%patch161 -p1
#%patch162 -p1
#%patch163 -p1
#%patch164 -p1
#%patch165 -p1
#%patch166 -p1
#%patch167 -p1
#%patch168 -p1
#%patch169 -p1
#%patch170 -p1
#%patch171 -p1
#%patch172 -p1
#%patch173 -p1
#%patch174 -p1
%patch175 -p1
%patch176 -p1
%patch177 -p1
%patch178 -p1
%patch179 -p1
%patch180 -p1
%patch181 -p1
%patch182 -p1
#%patch1000 -p1
#%patch1001 -p1
@ -381,15 +454,15 @@ received by a process.
#%patch2000 -p1
%patch2001 -p1
#%patch2002 -p1
%patch2003 -p1
%patch2004 -p1
#%patch2003 -p1
#%patch2004 -p1
chmod a+x tests/*.test
echo -n %version-%release > .tarball-version
echo -n 2020 > .year
echo -n 2020-04-30 > .strace.1.in.date
echo -n 2022 > .year
echo -n 2022-06-22 > doc/.strace.1.in.date
echo -n 2022-06-22 > doc/.strace-log-merge.1.in.date
%build
echo 'BEGIN OF BUILD ENVIRONMENT INFORMATION'
@ -408,18 +481,18 @@ CFLAGS=" $RPM_OPT_FLAGS $LDFLAGS "
[ "x${CFLAGS#* -m64 }" = "x${CFLAGS}" ] || CFLAGS=$(echo "$CFLAGS" | sed 's/ -m64 / /g')
export CFLAGS
CPPFLAGS=" -I%{_includedir} %{optflags} "
CPPFLAGS=" -isystem %{_includedir} %{optflags} "
# Removing explicit -m64 as it breaks mpers
[ "x${CPPFLAGS#* -m64 }" = "x${CPPFLAGS}" ] || CPPFLAGS=$(echo "$CPPFLAGS" | sed 's/ -m64 / /g')
export CPPFLAGS
CFLAGS_FOR_BUILD="$RPM_OPT_FLAGS"; export CFLAGS_FOR_BUILD
%configure --enable-mpers=check --with-libdw --with-libiberty
make %{?_smp_mflags}
%make_build
%install
make DESTDIR=%{buildroot} install
%make_install
%ifarch %{strace32_arches}
ln -s ./strace %{buildroot}%{_bindir}/strace32
@ -442,10 +515,9 @@ chmod u+x tests/*.test tests-m32/*.test tests-mx32/*.test
# We have to limit concurrent execution of tests as some time-sensitive tests
# start to fail if the reported time is way too off from the expected one.
make -j2 -k check VERBOSE=1 V=1 TIMEOUT_DURATION=5400
%make_build -k check VERBOSE=1 V=1
echo 'BEGIN OF TEST SUITE INFORMATION'
tail -n 99999 -- tests*/test-suite.log
tail -n 99999 -- tests*/ksysent.log ||:
tail -n 99999 -- tests*/test-suite.log tests*/ksysent.gen.log
find tests* -type f -name '*.log' -print0 |
xargs -r0 grep -H '^KERNEL BUG:' -- ||:
echo 'END OF TEST SUITE INFORMATION'
@ -461,6 +533,28 @@ echo 'END OF TEST SUITE INFORMATION'
%{_mandir}/man1/*
%changelog
* Mon Jul 11 2022 Eugene Syromiatnikov <esyr@redhat.com> - 5.18-2
- Fix the issues reported by covscan (#2103068).
- Fix SELinux context matching for the deleted paths (#2087693).
- Fix sloppy FD usage in the bpf test (#2103137).
* Wed Jun 22 2022 Eugene Syromiatnikov <esyr@redhat.com> - 5.18-1
- Rebase to v5.18; drop upstream patches on top of 5.13 (#2084000).
* Mon Feb 07 2022 Eugene Syromiatnikov <esyr@redhat.com> - 5.13-4
- Update tests-m32 and tests-mx32 with --secontext=mismatch option support
changes (#2046259).
* Wed Jan 19 2022 Eugene Syromiatnikov <esyr@redhat.com> - 5.13-3
- Add --secontext=mismatch option support (#2038810).
* Wed Jan 05 2022 Eugene Syromiatnikov <esyr@redhat.com> - 5.13-2
- Fix incorrect ifname printing buffer size (#2028158).
* Wed Oct 20 2021 Eugene Syromiatnikov <esyr@redhat.com> - 5.13-1
- Rebase to v5.13; drop upstream patches on top of 5.7 (#2015917).
- Address some issues reported by covscan.
* Mon Aug 09 2021 Eugene Syromiatnikov <esyr@redhat.com> - 5.7-3
- Add SELnux context decoding support (#1946500).