import strace-5.13-4.el8

This commit is contained in:
CentOS Sources 2022-05-10 03:16:00 -04:00 committed by Stepan Oksanichenko
parent fefbb4cf09
commit 02ddc292d1
55 changed files with 8669 additions and 50508 deletions

2
.gitignore vendored
View File

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

View File

@ -1 +1 @@
95c9d5aa664982d53ce1e5ab058d8fb73e200f0c SOURCES/strace-5.7.tar.xz
0f48c474de7d34009d3455f589efe790d24050b5 SOURCES/strace-5.13.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

@ -32,10 +32,10 @@ Index: strace-5.7/m4/mpers.m4
fi
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
Index: strace-5.7/config.h.in
Index: strace-5.7/src/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
--- strace-5.7.orig/src/config.h.in 2021-08-24 21:08:43.304245612 +0200
+++ strace-5.7/src/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
@ -60,7 +60,7 @@ 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 @@
@@ -19317,6 +19217,11 @@
fi
fi
@ -72,7 +72,7 @@ Index: strace-5.7/configure
fi
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
@@ -24314,6 +24319,11 @@
@@ -20001,6 +20006,11 @@
fi
fi

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,77 @@
From a034f8a50cbe15d250457ed2eefbf9db059f724f Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 18 Aug 2021 21:48:38 +0200
Subject: [PATCH 147/150] filter_qualify: free allocated data on the error path
exit of parse_poke_token
While not terribly required due to the fact that issues with option
parsing lead to program termination, these changes avoid leaking data
allocated in the function's scope and not stored elsewhere, which might
come handy if it ever be used dynamically during the runtime.
This also has been reported as resource leaks by covscan, and these
changes should calm it.
* src/filter_qualify.c (parse_poke_token): Go to err label instead of
returning right away; free poke->data, poke, and str_tokenized before
returning false.
References: https://bugzilla.redhat.com/show_bug.cgi?id=1995509
---
src/filter_qualify.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/filter_qualify.c b/src/filter_qualify.c
index df05496..a1a6471 100644
--- a/src/filter_qualify.c
+++ b/src/filter_qualify.c
@@ -169,34 +169,40 @@ parse_poke_token(const char *input, struct inject_opts *fopts, bool isenter)
poke->is_enter = isenter;
if ((val = STR_STRIP_PREFIX(token, "@arg")) == token)
- return false;
+ goto err;
if ((val[0] >= '1') && (val[0] <= '7')) {
poke->arg_no = val[0] - '0';
} else {
- return false;
+ goto err;
}
if (val[1] != '=')
- return false;
+ goto err;
val += 2;
data_len = strlen(val);
if ((data_len == 0) || (data_len % 2) || (data_len > 2048))
- return false;
+ goto err;
data_len /= 2;
poke->data_len = data_len;
poke->data = xmalloc(data_len);
for (size_t i = 0; i < data_len; i++)
if (sscanf(&val[2 * i], "%2hhx", &poke->data[i]) != 1)
- return false;
+ goto err;
if (poke_add(fopts->data.poke_idx, poke))
- return false;
+ goto err;
}
free(str_tokenized);
fopts->data.flags |= flag;
return true;
+
+err:
+ free(poke->data);
+ free(poke);
+ free(str_tokenized);
+ return false;
}
static bool
--
2.1.4

View File

@ -0,0 +1,70 @@
From 3f3dd44f1964c54b55e8c84343579bd7c1924df5 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 18 Aug 2021 21:49:12 +0200
Subject: [PATCH 148/150] macros: expand BIT macros, add MASK macros; add
*_SAFE macros
These macros might make reading a code that often converts between powers
of 2 and values/masks a bit easier; moreover, the *_SAFE versions should
help in cases where the shift values are expected to be equal to the type
bit width (which lead to UB otherwise).
Switching from BIT to BIT32 should also clarify bitness, which may be somewhat
murky at times (cf. printxval, printflags, and printxvals).
* src/macros.h [!BIT] (BIT): Rename to...
[!BIT32] (BIT32): ...this.
[!BIT64] (BIT64): New macro.
[!MASK32] (MASK32): Likewise.
[!MASK64] (MASK64): Likewise.
(BIT32_SAFE, BIT64_SAFE, MASK32_SAFE, MASK64_SAFE): New macros.
(FLAG): Use BIT32.
---
src/macros.h | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/macros.h b/src/macros.h
index 467f5d0..2d7a83d 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -78,10 +78,34 @@ is_filled(const char *ptr, char fill, size_t size)
# define IS_ARRAY_ZERO(arr_) \
is_filled((const char *) (arr_), 0, sizeof(arr_) + MUST_BE_ARRAY(arr_))
-# ifndef BIT
-# define BIT(x_) (1U << (x_))
+# ifndef BIT32
+# define BIT32(x_) (1U << (x_))
# endif
-# define FLAG(name_) name_ = BIT(name_##_BIT)
+# ifndef BIT64
+# define BIT64(x_) (1ULL << (x_))
+# endif
+
+# ifndef MASK32
+# define MASK32(x_) (BIT32(x_) - 1U)
+# endif
+
+# ifndef MASK64
+# define MASK64(x_) (BIT64(x_) - 1ULL)
+# endif
+
+/*
+ * "Safe" versions that avoid UB for values that are >= type bit size
+ * (the usually expected behaviour of the bit shift in that case is zero,
+ * but at least powerpc is notorious for returning the input value when shift
+ * by 64 bits is performed).
+ */
+
+# define BIT32_SAFE(x_) ((x_) < 32 ? BIT32(x_) : 0)
+# define BIT64_SAFE(x_) ((x_) < 64 ? BIT64(x_) : 0)
+# define MASK32_SAFE(x_) (BIT32_SAFE(x_) - 1U)
+# define MASK64_SAFE(x_) (BIT64_SAFE(x_) - 1ULL)
+
+# define FLAG(name_) name_ = BIT32(name_##_BIT)
#endif /* !STRACE_MACROS_H */
--
2.1.4

View File

@ -0,0 +1,151 @@
From 8ef5456338a947944cc03b95c22c837af5884ddc Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 18 Aug 2021 21:51:22 +0200
Subject: [PATCH 149/150] trie: use BIT* and MASK* macros
This makes reading the code a bit easier. It also solves some issues
where there is a hypothertical possibility of having bit shifts of size
64, by virtue of using the *_SAFE macros (that should silence some
reported "left shifting by more than 63 bits has undefined behavior"
covscan issues).
* src/trie.c (trie_create): Use BIT32, MASK64.
(trie_create_data_block): Use BIT32, change iterator variable type
to size_t.
(trie_get_node): Use BIT64, MASK64.
(trie_data_block_calc_pos): Use BIT32, MASK64, MASK64_SAFE.
(trie_iterate_keys_node): Use BIT64, MASK64, MASK64_SAFE.
(trie_free_node): Use BIT64.
---
src/trie.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/trie.c b/src/trie.c
index 586ff25..0a231e4 100644
--- a/src/trie.c
+++ b/src/trie.c
@@ -15,6 +15,7 @@
#include <stdio.h>
#include "trie.h"
+#include "macros.h"
#include "xmalloc.h"
static const uint8_t ptr_sz_lg = (sizeof(void *) == 8 ? 6 : 5);
@@ -87,7 +88,7 @@ trie_create(uint8_t key_size, uint8_t item_size_lg, uint8_t node_key_bits,
/ t->node_key_bits;
if (item_size_lg != 6)
- t->empty_value &= (((uint64_t) 1 << (1 << t->item_size_lg)) - 1);
+ t->empty_value &= MASK64(BIT32(t->item_size_lg));
return t;
}
@@ -96,8 +97,8 @@ static void *
trie_create_data_block(struct trie *t)
{
uint64_t fill_value = t->empty_value;
- for (int i = 1; i < 1 << (6 - t->item_size_lg); i++) {
- fill_value <<= (1 << t->item_size_lg);
+ for (size_t i = 1; i < BIT32(6 - t->item_size_lg); i++) {
+ fill_value <<= BIT32(t->item_size_lg);
fill_value |= t->empty_value;
}
@@ -105,7 +106,7 @@ trie_create_data_block(struct trie *t)
if (sz < 6)
sz = 6;
- size_t count = 1 << (sz - 6);
+ size_t count = BIT32(sz - 6);
uint64_t *data_block = xcalloc(count, 8);
for (size_t i = 0; i < count; i++)
@@ -119,7 +120,7 @@ trie_get_node(struct trie *t, uint64_t key, bool auto_create)
{
void **cur_node = &(t->data);
- if (t->key_size < 64 && key > (uint64_t) 1 << t->key_size)
+ if (t->key_size < 64 && key > MASK64(t->key_size))
return NULL;
for (uint8_t cur_depth = 0; cur_depth <= t->max_depth; cur_depth++) {
@@ -133,13 +134,13 @@ trie_get_node(struct trie *t, uint64_t key, bool auto_create)
if (cur_depth == t->max_depth)
*cur_node = trie_create_data_block(t);
else
- *cur_node = xcalloc(1 << sz, 1);
+ *cur_node = xcalloc(BIT64(sz), 1);
}
if (cur_depth == t->max_depth)
break;
- size_t pos = (key >> offs) & ((1 << (sz - ptr_sz_lg)) - 1);
+ size_t pos = (key >> offs) & MASK64(sz - ptr_sz_lg);
cur_node = (((void **) (*cur_node)) + pos);
}
@@ -152,7 +153,7 @@ trie_data_block_calc_pos(struct trie *t, uint64_t key,
{
uint64_t key_mask;
- key_mask = (1 << t->data_block_key_bits) - 1;
+ key_mask = MASK64(t->data_block_key_bits);
*pos = (key & key_mask) >> (6 - t->item_size_lg);
if (t->item_size_lg == 6) {
@@ -161,10 +162,10 @@ trie_data_block_calc_pos(struct trie *t, uint64_t key,
return;
}
- key_mask = (1 << (6 - t->item_size_lg)) - 1;
- *offs = (key & key_mask) * (1 << t->item_size_lg);
+ key_mask = MASK64(6 - t->item_size_lg);
+ *offs = (key & key_mask) << t->item_size_lg;
- *mask = (((uint64_t) 1 << (1 << t->item_size_lg)) - 1) << *offs;
+ *mask = MASK64_SAFE(BIT32(t->item_size_lg)) << *offs;
}
bool
@@ -211,7 +212,7 @@ trie_iterate_keys_node(struct trie *t,
return 0;
if (t->key_size < 64) {
- uint64_t key_max = ((uint64_t) 1 << t->key_size) - 1;
+ uint64_t key_max = MASK64(t->key_size);
if (end > key_max)
end = key_max;
}
@@ -228,15 +229,14 @@ trie_iterate_keys_node(struct trie *t,
t->key_size :
trie_get_node_bit_offs(t, depth - 1);
- uint64_t first_key_in_node = start &
- (uint64_t) -1 << parent_node_bit_off;
+ uint64_t first_key_in_node = start & ~MASK64_SAFE(parent_node_bit_off);
uint8_t node_bit_off = trie_get_node_bit_offs(t, depth);
uint8_t node_key_bits = parent_node_bit_off - node_bit_off;
- uint64_t mask = ((uint64_t) 1 << (node_key_bits)) - 1;
+ uint64_t mask = MASK64_SAFE(node_key_bits);
uint64_t start_index = (start >> node_bit_off) & mask;
uint64_t end_index = (end >> node_bit_off) & mask;
- uint64_t child_key_count = (uint64_t) 1 << node_bit_off;
+ uint64_t child_key_count = BIT64(node_bit_off);
uint64_t count = 0;
@@ -274,7 +274,7 @@ trie_free_node(struct trie *t, void *node, uint8_t depth)
if (depth >= t->max_depth)
goto free_node;
- size_t sz = 1 << (trie_get_node_size(t, depth) - ptr_sz_lg);
+ size_t sz = BIT64(trie_get_node_size(t, depth) - ptr_sz_lg);
for (size_t i = 0; i < sz; i++)
trie_free_node(t, ((void **) node)[i], depth + 1);
--
2.1.4

View File

@ -0,0 +1,52 @@
From 3a68f90c2a5a208b475cc2014f85ae04541ec5b6 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Fri, 20 Aug 2021 21:31:01 +0200
Subject: [PATCH 150/150] tee: rewrite num_params access in tee_fetch_buf_data
Pointer to num_params field of the fetched structure is passed in a
separate function argument which provokes covscan complaints about
uninitialised accesses and also tingles my aliasing rules senses.
Rewrite to access it via the arg_struct argument which is fetched
earlier in the function flow.
* src/tee.c (TEE_FETCH_BUF_DATA): Change &arg_.num_params
to offsetof(typeof(arg_), num_params).
(tee_fetch_buf_data): Accept offset of the num_params field instead
of pointer to it; reconstruct the num_params pointer using it.
---
src/tee.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/tee.c b/src/tee.c
index f9eda52..d7e9b15 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -33,7 +33,7 @@ struct tee_ioctl_shm_register_fd_data {
#define TEE_FETCH_BUF_DATA(buf_, arg_, params_) \
tee_fetch_buf_data(tcp, arg, &buf_, sizeof(arg_), \
- &arg_, &arg_.num_params, \
+ &arg_, offsetof(typeof(arg_), num_params), \
params_)
/* session id is printed as 0x%x in libteec */
@@ -56,7 +56,7 @@ tee_fetch_buf_data(struct tcb *const tcp,
struct tee_ioctl_buf_data *buf,
size_t arg_size,
void *arg_struct,
- unsigned *num_params,
+ size_t num_params_offs,
uint64_t *params)
{
if (umove_or_printaddr(tcp, arg, buf))
@@ -69,6 +69,7 @@ tee_fetch_buf_data(struct tcb *const tcp,
tee_print_buf(buf);
return RVAL_IOCTL_DECODED;
}
+ uint32_t *num_params = (uint32_t *) (arg_struct + num_params_offs);
if (entering(tcp) &&
(arg_size + TEE_IOCTL_PARAM_SIZE(*num_params) != buf->buf_len)) {
/*
--
2.1.4

View File

@ -0,0 +1,55 @@
From e27b06773eaf5c0307bcc5637d7457be9be1e6ea Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 1 Dec 2021 17:11:02 +0100
Subject: [PATCH] print_ifindex: fix IFNAME_QUOTED_SZ definition
sizeof(IFNAMSIZ) instead of IFNAMSIZ was mistakenly used
for IFNAME_QUOTED_SZ initial definition in commit v4.23~87
"print_ifindex: respect xlat style settings".
* src/print_ifindex.c (IFNAME_QUOTED_SZ): Use IFNAMSIZ
instead of sizeof(IFNAMSIZ).
* NEWS: Mention it.
Reported-by: Paulo Andrade <pandrade@redhat.com>
Suggested-by: Paulo Andrade <pandrade@redhat.com>
Fixes: v4.23~87 "print_ifindex: respect xlat style settings"
References: https://bugzilla.redhat.com/show_bug.cgi?id=2028146
---
NEWS | 4 ++++
src/print_ifindex.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 9bab673..a3036b8 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,12 @@ Noteworthy changes in release ?.?? (????-??-??)
PTRACE_*, RTM_*, RTPROT_*, TRAP_*, UFFD_*, UFFDIO_*, and V4L2_* constants.
* Updated lists of ioctl commands from Linux 5.13.
+ * Bug fixes
+ * Fixed insufficient buffer size used for network interface name printing,
+ that previously led to assertions on attempts of printing interface names
+ that require quoting, for example, names longer than 4 characters in -xx
+ mode (addresses RHBZ bug #2028146).
+
* Portability
* On powerpc and powerpc64, linux kernel >= 2.6.23 is required.
Older versions without a decent PTRACE_GETREGS support will not work.
diff --git a/src/print_ifindex.c b/src/print_ifindex.c
index ec48093..dc9d592 100644
--- a/src/print_ifindex.c
+++ b/src/print_ifindex.c
@@ -13,7 +13,7 @@
# define INI_PFX "if_nametoindex(\""
# define INI_SFX "\")"
-# define IFNAME_QUOTED_SZ (sizeof(IFNAMSIZ) * 4 + 3)
+# define IFNAME_QUOTED_SZ (IFNAMSIZ * 4 + 3)
const char *
get_ifname(const unsigned int ifindex)
--
2.1.4

View File

@ -0,0 +1,208 @@
From b8f375c2c8140e759122bca3e3469386d3ba5184 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Mon, 29 Nov 2021 08:00:00 +0000
Subject: [PATCH 168/174] m4: fix st_SELINUX check
* m4/st_selinux.m4: Make sure selinux support is enabled only if
all expected functions are provided by libselinux.
Fixes: v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
---
m4/st_selinux.m4 | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/m4/st_selinux.m4 b/m4/st_selinux.m4
index da72a48..7b24eba 100644
--- a/m4/st_selinux.m4
+++ b/m4/st_selinux.m4
@@ -34,29 +34,25 @@ AS_IF([test "x$with_libselinux" != xno],
AS_IF([test "x$found_selinux_h" = xyes],
[saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $libselinux_LDFLAGS"
- AC_CHECK_LIB([selinux],[getpidcon],
- [libselinux_LIBS="-lselinux"
- enable_secontext=yes
- ],
- [if test "x$with_libselinux" != xcheck; then
- AC_MSG_FAILURE([failed to find getpidcon in libselinux])
- fi
- ]
- )
- AC_CHECK_LIB([selinux],[getfilecon],
- [libselinux_LIBS="-lselinux"
- enable_secontext=yes
- ],
- [if test "x$with_libselinux" != xcheck; then
- AC_MSG_FAILURE([failed to find getfilecon in libselinux])
- fi
- ]
+ missing=
+ for func in getpidcon getfilecon; do
+ AC_CHECK_LIB([selinux], [$func], [:],
+ [missing="$missing $func"])
+ done
+ AS_IF([test "x$missing" = x],
+ [libselinux_LIBS="-lselinux"
+ enable_secontext=yes
+ ],
+ [AS_IF([test "x$with_libselinux" != xcheck],
+ [AC_MSG_FAILURE([failed to find in libselinux:$missing])]
+ )
+ ]
)
LDFLAGS="$saved_LDFLAGS"
],
- [if test "x$with_libselinux" != xcheck; then
- AC_MSG_FAILURE([failed to find selinux.h])
- fi
+ [AS_IF([test "x$with_libselinux" != xcheck],
+ [AC_MSG_FAILURE([failed to find selinux.h])]
+ )
]
)
]
--- old/configure 2022-02-07 20:17:58.364068436 +0100
+++ new/configure 2022-02-07 20:19:17.092067347 +0100
@@ -18437,9 +18437,12 @@
if test "x$found_selinux_h" = xyes; then :
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $libselinux_LDFLAGS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpidcon in -lselinux" >&5
-$as_echo_n "checking for getpidcon in -lselinux... " >&6; }
-if ${ac_cv_lib_selinux_getpidcon+:} false; then :
+ missing=
+ for func in getpidcon getfilecon; do
+ as_ac_Lib=`$as_echo "ac_cv_lib_selinux_$func" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $func in -lselinux" >&5
+$as_echo_n "checking for $func in -lselinux... " >&6; }
+if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -18453,101 +18456,59 @@
#ifdef __cplusplus
extern "C"
#endif
-char getpidcon ();
+char $func ();
int
main ()
{
-return getpidcon ();
+return $func ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_selinux_getpidcon=yes
+ eval "$as_ac_Lib=yes"
else
- ac_cv_lib_selinux_getpidcon=no
+ eval "$as_ac_Lib=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_getpidcon" >&5
-$as_echo "$ac_cv_lib_selinux_getpidcon" >&6; }
-if test "x$ac_cv_lib_selinux_getpidcon" = xyes; then :
- libselinux_LIBS="-lselinux"
- enable_secontext=yes
-
+eval ac_res=\$$as_ac_Lib
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
+ :
else
- if test "x$with_libselinux" != xcheck; then
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to find getpidcon in libselinux
-See \`config.log' for more details" "$LINENO" 5; }
- fi
-
-
+ missing="$missing $func"
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getfilecon in -lselinux" >&5
-$as_echo_n "checking for getfilecon in -lselinux... " >&6; }
-if ${ac_cv_lib_selinux_getfilecon+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lselinux $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getfilecon ();
-int
-main ()
-{
-return getfilecon ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_selinux_getfilecon=yes
-else
- ac_cv_lib_selinux_getfilecon=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_getfilecon" >&5
-$as_echo "$ac_cv_lib_selinux_getfilecon" >&6; }
-if test "x$ac_cv_lib_selinux_getfilecon" = xyes; then :
+ done
+ if test "x$missing" = x; then :
libselinux_LIBS="-lselinux"
- enable_secontext=yes
+ enable_secontext=yes
else
- if test "x$with_libselinux" != xcheck; then
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ if test "x$with_libselinux" != xcheck; then :
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to find getfilecon in libselinux
+as_fn_error $? "failed to find in libselinux:$missing
See \`config.log' for more details" "$LINENO" 5; }
- fi
-
fi
+
+fi
LDFLAGS="$saved_LDFLAGS"
else
- if test "x$with_libselinux" != xcheck; then
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ if test "x$with_libselinux" != xcheck; then :
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to find selinux.h
See \`config.log' for more details" "$LINENO" 5; }
- fi
+
+fi
fi
--
2.1.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,122 @@
From f5fd689e40322a7b08a97eb2d26f192610728230 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 18 Jan 2022 16:10:28 +0100
Subject: [PATCH 170/174] tests/linkat: reset errno before SELinux context
manipulation
To avoid printing a stale error information in case of mismatch check
failure.
* tests/linkat.c: Include <errno.h>.
(main): Add "errno = 0" before update_secontext_field calls.
---
tests/linkat.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/linkat.c b/tests/linkat.c
index 1a869e3..c3e2ee4 100644
--- a/tests/linkat.c
+++ b/tests/linkat.c
@@ -10,6 +10,7 @@
#include "tests.h"
#include "scno.h"
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -91,6 +92,7 @@ main(void)
free(sample_1_secontext);
#ifdef PRINT_SECONTEXT_MISMATCH
+ errno = 0;
update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
@@ -112,6 +114,7 @@ main(void)
free(sample_1_secontext);
#endif
+ errno = 0;
update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -142,6 +145,7 @@ main(void)
int dfd_old = get_dir_fd(".");
char *cwd = get_fd_path(dfd_old);
+ errno = 0;
update_secontext_field(".", SECONTEXT_TYPE, "default_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
--- a/tests-m32/linkat.c
+++ b/tests-m32/linkat.c
@@ -10,6 +10,7 @@
#include "tests.h"
#include "scno.h"
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -91,6 +92,7 @@ main(void)
free(sample_1_secontext);
#ifdef PRINT_SECONTEXT_MISMATCH
+ errno = 0;
update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
@@ -112,6 +114,7 @@ main(void)
free(sample_1_secontext);
#endif
+ errno = 0;
update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -142,6 +145,7 @@ main(void)
int dfd_old = get_dir_fd(".");
char *cwd = get_fd_path(dfd_old);
+ errno = 0;
update_secontext_field(".", SECONTEXT_TYPE, "default_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
--- a/tests-mx32/linkat.c
+++ b/tests-mx32/linkat.c
@@ -10,6 +10,7 @@
#include "tests.h"
#include "scno.h"
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -91,6 +92,7 @@ main(void)
free(sample_1_secontext);
#ifdef PRINT_SECONTEXT_MISMATCH
+ errno = 0;
update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
@@ -112,6 +114,7 @@ main(void)
free(sample_1_secontext);
#endif
+ errno = 0;
update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -142,6 +145,7 @@ main(void)
int dfd_old = get_dir_fd(".");
char *cwd = get_fd_path(dfd_old);
+ errno = 0;
update_secontext_field(".", SECONTEXT_TYPE, "default_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
--
2.1.4

View File

@ -0,0 +1,356 @@
From 4951286eb634c00c11883b851c91f3a21975eabd Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 18 Jan 2022 18:03:57 +0100
Subject: [PATCH 171/174] tests/secontext: add secontext field getters
* tests/secontext.h (get_secontext_field, get_secontext_field_file): New
declarations.
* tests/secontext.c (get_type_from_context): Rename to...
(get_secontext_field): ...this; remove "static" qualifier; add "field"
argument, use it.
(raw_expected_secontext_short_file, raw_secontext_short_pid): Replace
get_type_from_context call with get_secontext_field.
(get_secontext_field_file): New function.
(raw_secontext_short_file): Replace body with get_secontext_field_file
call.
---
tests/secontext.c | 27 +++++++++++++++------------
tests/secontext.h | 20 ++++++++++++++++++++
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/tests/secontext.c b/tests/secontext.c
index 848eea9..52211ed 100644
--- a/tests/secontext.c
+++ b/tests/secontext.c
@@ -56,8 +56,8 @@ strip_trailing_newlines(char *context)
return context;
}
-static char *
-get_type_from_context(const char *full_context)
+char *
+get_secontext_field(const char *full_context, enum secontext_field field)
{
int saved_errno = errno;
@@ -72,7 +72,7 @@ get_type_from_context(const char *full_context)
char *context = NULL;
for (token = strtok_r(ctx_copy, ":", &saveptr), i = 0;
token; token = strtok_r(NULL, ":", &saveptr), i++) {
- if (i == 2) {
+ if (i == field) {
context = xstrdup(token);
break;
}
@@ -122,7 +122,7 @@ raw_expected_secontext_short_file(const char *filename)
int saved_errno = errno;
char *ctx = raw_expected_secontext_full_file(filename);
- char *type = get_type_from_context(ctx);
+ char *type = get_secontext_field(ctx, SECONTEXT_TYPE);
free(ctx);
errno = saved_errno;
@@ -144,20 +144,23 @@ raw_secontext_full_file(const char *filename)
return full_secontext;
}
-static char *
-raw_secontext_short_file(const char *filename)
+char *
+get_secontext_field_file(const char *file, enum secontext_field field)
{
- int saved_errno = errno;
-
- char *ctx = raw_secontext_full_file(filename);
- char *type = get_type_from_context(ctx);
+ char *ctx = raw_secontext_full_file(file);
+ char *type = get_secontext_field(ctx, field);
free(ctx);
- errno = saved_errno;
return type;
}
static char *
+raw_secontext_short_file(const char *filename)
+{
+ return get_secontext_field_file(filename, SECONTEXT_TYPE);
+}
+
+static char *
raw_secontext_full_pid(pid_t pid)
{
int saved_errno = errno;
@@ -178,7 +181,7 @@ raw_secontext_short_pid(pid_t pid)
int saved_errno = errno;
char *ctx = raw_secontext_full_pid(pid);
- char *type = get_type_from_context(ctx);
+ char *type = get_secontext_field(ctx, SECONTEXT_TYPE);
free(ctx);
errno = saved_errno;
diff --git a/tests/secontext.h b/tests/secontext.h
index 1d0251a..e5571d5 100644
--- a/tests/secontext.h
+++ b/tests/secontext.h
@@ -23,6 +23,15 @@ enum secontext_field {
#if defined TEST_SECONTEXT && defined HAVE_SELINUX_RUNTIME
+/**
+ * Parse a SELinux context string and return a specified field, duplicated
+ * in a separate string. The caller is responsible for freeing the memory
+ * pointed by the returned value.
+ */
+char *get_secontext_field(const char *full_context, enum secontext_field field);
+
+char *get_secontext_field_file(const char *file, enum secontext_field field);
+
void update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue);
@@ -48,6 +57,17 @@ void update_secontext_field(const char *file, enum secontext_field field,
#else
+static inline char *
+get_secontext_field(const char *ctx, enum secontext_field field)
+{
+ return NULL;
+}
+static inline char *
+get_secontext_field_file(const char *file, enum secontext_field field)
+{
+ return NULL;
+}
+
static inline void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
diff --git a/tests-m32/secontext.c b/tests-m32/secontext.c
index 848eea9..52211ed 100644
--- a/tests-m32/secontext.c
+++ b/tests-m32/secontext.c
@@ -56,8 +56,8 @@ strip_trailing_newlines(char *context)
return context;
}
-static char *
-get_type_from_context(const char *full_context)
+char *
+get_secontext_field(const char *full_context, enum secontext_field field)
{
int saved_errno = errno;
@@ -72,7 +72,7 @@ get_type_from_context(const char *full_context)
char *context = NULL;
for (token = strtok_r(ctx_copy, ":", &saveptr), i = 0;
token; token = strtok_r(NULL, ":", &saveptr), i++) {
- if (i == 2) {
+ if (i == field) {
context = xstrdup(token);
break;
}
@@ -122,7 +122,7 @@ raw_expected_secontext_short_file(const char *filename)
int saved_errno = errno;
char *ctx = raw_expected_secontext_full_file(filename);
- char *type = get_type_from_context(ctx);
+ char *type = get_secontext_field(ctx, SECONTEXT_TYPE);
free(ctx);
errno = saved_errno;
@@ -144,20 +144,23 @@ raw_secontext_full_file(const char *filename)
return full_secontext;
}
-static char *
-raw_secontext_short_file(const char *filename)
+char *
+get_secontext_field_file(const char *file, enum secontext_field field)
{
- int saved_errno = errno;
-
- char *ctx = raw_secontext_full_file(filename);
- char *type = get_type_from_context(ctx);
+ char *ctx = raw_secontext_full_file(file);
+ char *type = get_secontext_field(ctx, field);
free(ctx);
- errno = saved_errno;
return type;
}
static char *
+raw_secontext_short_file(const char *filename)
+{
+ return get_secontext_field_file(filename, SECONTEXT_TYPE);
+}
+
+static char *
raw_secontext_full_pid(pid_t pid)
{
int saved_errno = errno;
@@ -178,7 +181,7 @@ raw_secontext_short_pid(pid_t pid)
int saved_errno = errno;
char *ctx = raw_secontext_full_pid(pid);
- char *type = get_type_from_context(ctx);
+ char *type = get_secontext_field(ctx, SECONTEXT_TYPE);
free(ctx);
errno = saved_errno;
diff --git a/tests-m32/secontext.h b/tests-m32/secontext.h
index 1d0251a..e5571d5 100644
--- a/tests-m32/secontext.h
+++ b/tests-m32/secontext.h
@@ -23,6 +23,15 @@ enum secontext_field {
#if defined TEST_SECONTEXT && defined HAVE_SELINUX_RUNTIME
+/**
+ * Parse a SELinux context string and return a specified field, duplicated
+ * in a separate string. The caller is responsible for freeing the memory
+ * pointed by the returned value.
+ */
+char *get_secontext_field(const char *full_context, enum secontext_field field);
+
+char *get_secontext_field_file(const char *file, enum secontext_field field);
+
void update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue);
@@ -48,6 +57,17 @@ void update_secontext_field(const char *file, enum secontext_field field,
#else
+static inline char *
+get_secontext_field(const char *ctx, enum secontext_field field)
+{
+ return NULL;
+}
+static inline char *
+get_secontext_field_file(const char *file, enum secontext_field field)
+{
+ return NULL;
+}
+
static inline void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
diff --git a/tests-mx32/secontext.c b/tests-mx32/secontext.c
index 848eea9..52211ed 100644
--- a/tests-mx32/secontext.c
+++ b/tests-mx32/secontext.c
@@ -56,8 +56,8 @@ strip_trailing_newlines(char *context)
return context;
}
-static char *
-get_type_from_context(const char *full_context)
+char *
+get_secontext_field(const char *full_context, enum secontext_field field)
{
int saved_errno = errno;
@@ -72,7 +72,7 @@ get_type_from_context(const char *full_context)
char *context = NULL;
for (token = strtok_r(ctx_copy, ":", &saveptr), i = 0;
token; token = strtok_r(NULL, ":", &saveptr), i++) {
- if (i == 2) {
+ if (i == field) {
context = xstrdup(token);
break;
}
@@ -122,7 +122,7 @@ raw_expected_secontext_short_file(const char *filename)
int saved_errno = errno;
char *ctx = raw_expected_secontext_full_file(filename);
- char *type = get_type_from_context(ctx);
+ char *type = get_secontext_field(ctx, SECONTEXT_TYPE);
free(ctx);
errno = saved_errno;
@@ -144,20 +144,23 @@ raw_secontext_full_file(const char *filename)
return full_secontext;
}
-static char *
-raw_secontext_short_file(const char *filename)
+char *
+get_secontext_field_file(const char *file, enum secontext_field field)
{
- int saved_errno = errno;
-
- char *ctx = raw_secontext_full_file(filename);
- char *type = get_type_from_context(ctx);
+ char *ctx = raw_secontext_full_file(file);
+ char *type = get_secontext_field(ctx, field);
free(ctx);
- errno = saved_errno;
return type;
}
static char *
+raw_secontext_short_file(const char *filename)
+{
+ return get_secontext_field_file(filename, SECONTEXT_TYPE);
+}
+
+static char *
raw_secontext_full_pid(pid_t pid)
{
int saved_errno = errno;
@@ -178,7 +181,7 @@ raw_secontext_short_pid(pid_t pid)
int saved_errno = errno;
char *ctx = raw_secontext_full_pid(pid);
- char *type = get_type_from_context(ctx);
+ char *type = get_secontext_field(ctx, SECONTEXT_TYPE);
free(ctx);
errno = saved_errno;
diff --git a/tests-mx32/secontext.h b/tests-mx32/secontext.h
index 1d0251a..e5571d5 100644
--- a/tests-mx32/secontext.h
+++ b/tests-mx32/secontext.h
@@ -23,6 +23,15 @@ enum secontext_field {
#if defined TEST_SECONTEXT && defined HAVE_SELINUX_RUNTIME
+/**
+ * Parse a SELinux context string and return a specified field, duplicated
+ * in a separate string. The caller is responsible for freeing the memory
+ * pointed by the returned value.
+ */
+char *get_secontext_field(const char *full_context, enum secontext_field field);
+
+char *get_secontext_field_file(const char *file, enum secontext_field field);
+
void update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue);
@@ -48,6 +57,17 @@ void update_secontext_field(const char *file, enum secontext_field field,
#else
+static inline char *
+get_secontext_field(const char *ctx, enum secontext_field field)
+{
+ return NULL;
+}
+static inline char *
+get_secontext_field_file(const char *file, enum secontext_field field)
+{
+ return NULL;
+}
+
static inline void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
--
2.1.4

View File

@ -0,0 +1,181 @@
From 97e2742a7f1e6e113354911d04505ada3bfb5d70 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 18 Jan 2022 18:04:42 +0100
Subject: [PATCH 172/174] tests/linkat: provide fallback values for secontext
fields changes
* tests/linkat.c (mangle_secontext_field): New function.
(main): Replace calls to update_secontext_field
with mangle_secontext_field calls.
---
tests/linkat.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/tests/linkat.c b/tests/linkat.c
index c3e2ee4..decb736 100644
--- a/tests/linkat.c
+++ b/tests/linkat.c
@@ -21,6 +21,20 @@
#include "secontext.h"
#include "xmalloc.h"
+static void
+mangle_secontext_field(const char *path, enum secontext_field field,
+ const char *new_val, const char *fallback_val)
+{
+ char *orig = get_secontext_field_file(path, field);
+ if (!orig)
+ return;
+
+ update_secontext_field(path, field,
+ strcmp(new_val, orig) ? new_val : fallback_val);
+
+ free(orig);
+}
+
int
main(void)
{
@@ -93,7 +107,8 @@ main(void)
#ifdef PRINT_SECONTEXT_MISMATCH
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
+ mangle_secontext_field(sample_1, SECONTEXT_USER, "system_u",
+ "unconfined_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
# ifdef PRINT_SECONTEXT_FULL
@@ -115,7 +130,8 @@ main(void)
#endif
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(sample_1, SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -146,7 +162,8 @@ main(void)
char *cwd = get_fd_path(dfd_old);
errno = 0;
- update_secontext_field(".", SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(".", SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
#ifdef PRINT_SECONTEXT_MISMATCH
diff --git a/tests-m32/linkat.c b/tests-m32/linkat.c
index c3e2ee4..decb736 100644
--- a/tests-m32/linkat.c
+++ b/tests-m32/linkat.c
@@ -21,6 +21,20 @@
#include "secontext.h"
#include "xmalloc.h"
+static void
+mangle_secontext_field(const char *path, enum secontext_field field,
+ const char *new_val, const char *fallback_val)
+{
+ char *orig = get_secontext_field_file(path, field);
+ if (!orig)
+ return;
+
+ update_secontext_field(path, field,
+ strcmp(new_val, orig) ? new_val : fallback_val);
+
+ free(orig);
+}
+
int
main(void)
{
@@ -93,7 +107,8 @@ main(void)
#ifdef PRINT_SECONTEXT_MISMATCH
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
+ mangle_secontext_field(sample_1, SECONTEXT_USER, "system_u",
+ "unconfined_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
# ifdef PRINT_SECONTEXT_FULL
@@ -115,7 +130,8 @@ main(void)
#endif
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(sample_1, SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -146,7 +162,8 @@ main(void)
char *cwd = get_fd_path(dfd_old);
errno = 0;
- update_secontext_field(".", SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(".", SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
#ifdef PRINT_SECONTEXT_MISMATCH
diff --git a/tests-mx32/linkat.c b/tests-mx32/linkat.c
index c3e2ee4..decb736 100644
--- a/tests-mx32/linkat.c
+++ b/tests-mx32/linkat.c
@@ -21,6 +21,20 @@
#include "secontext.h"
#include "xmalloc.h"
+static void
+mangle_secontext_field(const char *path, enum secontext_field field,
+ const char *new_val, const char *fallback_val)
+{
+ char *orig = get_secontext_field_file(path, field);
+ if (!orig)
+ return;
+
+ update_secontext_field(path, field,
+ strcmp(new_val, orig) ? new_val : fallback_val);
+
+ free(orig);
+}
+
int
main(void)
{
@@ -93,7 +107,8 @@ main(void)
#ifdef PRINT_SECONTEXT_MISMATCH
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
+ mangle_secontext_field(sample_1, SECONTEXT_USER, "system_u",
+ "unconfined_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
# ifdef PRINT_SECONTEXT_FULL
@@ -115,7 +130,8 @@ main(void)
#endif
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(sample_1, SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -146,7 +162,8 @@ main(void)
char *cwd = get_fd_path(dfd_old);
errno = 0;
- update_secontext_field(".", SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(".", SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
#ifdef PRINT_SECONTEXT_MISMATCH
--
2.1.4

View File

@ -0,0 +1,63 @@
From 6e8aa3749cb7e11e9a59db996f79f036bf7ef263 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 18 Jan 2022 18:05:19 +0100
Subject: [PATCH 173/174] tests/secontext: eliminate separate secontext_format
declaration
* tests/secontext.c (secontext_format): Remove declaration, supply
the attributes to the definition.
---
tests/secontext.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/tests/secontext.c b/tests/secontext.c
index 52211ed..ba271c8 100644
--- a/tests/secontext.c
+++ b/tests/secontext.c
@@ -23,10 +23,7 @@
# define TEST_SECONTEXT
# include "secontext.h"
-static char *
-secontext_format(char *context, const char *fmt)
- ATTRIBUTE_FORMAT((printf, 2, 0)) ATTRIBUTE_MALLOC;
-
+ATTRIBUTE_FORMAT((printf, 2, 0)) ATTRIBUTE_MALLOC
static char *
secontext_format(char *context, const char *fmt)
{
diff --git a/tests-m32/secontext.c b/tests-m32/secontext.c
index 52211ed..ba271c8 100644
--- a/tests-m32/secontext.c
+++ b/tests-m32/secontext.c
@@ -23,10 +23,7 @@
# define TEST_SECONTEXT
# include "secontext.h"
-static char *
-secontext_format(char *context, const char *fmt)
- ATTRIBUTE_FORMAT((printf, 2, 0)) ATTRIBUTE_MALLOC;
-
+ATTRIBUTE_FORMAT((printf, 2, 0)) ATTRIBUTE_MALLOC
static char *
secontext_format(char *context, const char *fmt)
{
diff --git a/tests-mx32/secontext.c b/tests-mx32/secontext.c
index 52211ed..ba271c8 100644
--- a/tests-mx32/secontext.c
+++ b/tests-mx32/secontext.c
@@ -23,10 +23,7 @@
# define TEST_SECONTEXT
# include "secontext.h"
-static char *
-secontext_format(char *context, const char *fmt)
- ATTRIBUTE_FORMAT((printf, 2, 0)) ATTRIBUTE_MALLOC;
-
+ATTRIBUTE_FORMAT((printf, 2, 0)) ATTRIBUTE_MALLOC
static char *
secontext_format(char *context, const char *fmt)
{
--
2.1.4

View File

@ -0,0 +1,190 @@
From 78a81bcfb71ef3d9f6e8b1a32e123fbbc6112a60 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 18 Jan 2022 18:24:34 +0100
Subject: [PATCH 174/174] tests/linkat: reset context to the expected one if a
mismatch has been detected
* tests/secontext.h (reset_secontext_file): New declaration.
* tests/secontext.c (reset_secontext_file): New function.
* tests/linkat.c (main): Check that there is no initial mismatch
in the sample_1 context, reset it otherwise.
---
tests/linkat.c | 3 +++
tests/secontext.c | 7 +++++++
tests/secontext.h | 7 +++++++
3 files changed, 17 insertions(+)
diff --git a/tests/linkat.c b/tests/linkat.c
index decb736..781b85a 100644
--- a/tests/linkat.c
+++ b/tests/linkat.c
@@ -103,6 +103,9 @@ main(void)
if (close(fd_sample_2))
perror_msg_and_fail("close");
+ if (*sample_1_secontext && strstr(sample_1_secontext, "!!"))
+ reset_secontext_file(sample_1);
+
free(sample_1_secontext);
#ifdef PRINT_SECONTEXT_MISMATCH
diff --git a/tests/secontext.c b/tests/secontext.c
index ba271c8..94fadd4 100644
--- a/tests/secontext.c
+++ b/tests/secontext.c
@@ -235,6 +235,13 @@ secontext_short_pid(pid_t pid)
return FORMAT_SPACE_AFTER(raw_secontext_short_pid(pid));
}
+void reset_secontext_file(const char *file)
+{
+ char *proper_ctx = raw_expected_secontext_full_file(file);
+ (void) setfilecon(file, proper_ctx);
+ free(proper_ctx);
+}
+
void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
diff --git a/tests/secontext.h b/tests/secontext.h
index e5571d5..387263e 100644
--- a/tests/secontext.h
+++ b/tests/secontext.h
@@ -32,6 +32,8 @@ char *get_secontext_field(const char *full_context, enum secontext_field field);
char *get_secontext_field_file(const char *file, enum secontext_field field);
+void reset_secontext_file(const char *file);
+
void update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue);
@@ -69,6 +71,11 @@ get_secontext_field_file(const char *file, enum secontext_field field)
}
static inline void
+reset_secontext_file(const char *file)
+{
+}
+
+static inline void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
{
diff --git a/tests-m32/linkat.c b/tests-m32/linkat.c
index decb736..781b85a 100644
--- a/tests-m32/linkat.c
+++ b/tests-m32/linkat.c
@@ -103,6 +103,9 @@ main(void)
if (close(fd_sample_2))
perror_msg_and_fail("close");
+ if (*sample_1_secontext && strstr(sample_1_secontext, "!!"))
+ reset_secontext_file(sample_1);
+
free(sample_1_secontext);
#ifdef PRINT_SECONTEXT_MISMATCH
diff --git a/tests-m32/secontext.c b/tests-m32/secontext.c
index ba271c8..94fadd4 100644
--- a/tests-m32/secontext.c
+++ b/tests-m32/secontext.c
@@ -235,6 +235,13 @@ secontext_short_pid(pid_t pid)
return FORMAT_SPACE_AFTER(raw_secontext_short_pid(pid));
}
+void reset_secontext_file(const char *file)
+{
+ char *proper_ctx = raw_expected_secontext_full_file(file);
+ (void) setfilecon(file, proper_ctx);
+ free(proper_ctx);
+}
+
void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
diff --git a/tests-m32/secontext.h b/tests-m32/secontext.h
index e5571d5..387263e 100644
--- a/tests-m32/secontext.h
+++ b/tests-m32/secontext.h
@@ -32,6 +32,8 @@ char *get_secontext_field(const char *full_context, enum secontext_field field);
char *get_secontext_field_file(const char *file, enum secontext_field field);
+void reset_secontext_file(const char *file);
+
void update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue);
@@ -69,6 +71,11 @@ get_secontext_field_file(const char *file, enum secontext_field field)
}
static inline void
+reset_secontext_file(const char *file)
+{
+}
+
+static inline void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
{
diff --git a/tests-mx32/linkat.c b/tests-mx32/linkat.c
index decb736..781b85a 100644
--- a/tests-mx32/linkat.c
+++ b/tests-mx32/linkat.c
@@ -103,6 +103,9 @@ main(void)
if (close(fd_sample_2))
perror_msg_and_fail("close");
+ if (*sample_1_secontext && strstr(sample_1_secontext, "!!"))
+ reset_secontext_file(sample_1);
+
free(sample_1_secontext);
#ifdef PRINT_SECONTEXT_MISMATCH
diff --git a/tests-mx32/secontext.c b/tests-mx32/secontext.c
index ba271c8..94fadd4 100644
--- a/tests-mx32/secontext.c
+++ b/tests-mx32/secontext.c
@@ -235,6 +235,13 @@ secontext_short_pid(pid_t pid)
return FORMAT_SPACE_AFTER(raw_secontext_short_pid(pid));
}
+void reset_secontext_file(const char *file)
+{
+ char *proper_ctx = raw_expected_secontext_full_file(file);
+ (void) setfilecon(file, proper_ctx);
+ free(proper_ctx);
+}
+
void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
diff --git a/tests-mx32/secontext.h b/tests-mx32/secontext.h
index e5571d5..387263e 100644
--- a/tests-mx32/secontext.h
+++ b/tests-mx32/secontext.h
@@ -32,6 +32,8 @@ char *get_secontext_field(const char *full_context, enum secontext_field field);
char *get_secontext_field_file(const char *file, enum secontext_field field);
+void reset_secontext_file(const char *file);
+
void update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue);
@@ -69,6 +71,11 @@ get_secontext_field_file(const char *file, enum secontext_field field)
}
static inline void
+reset_secontext_file(const char *file)
+{
+}
+
+static inline void
update_secontext_field(const char *file, enum secontext_field field,
const char *newvalue)
{
--
2.1.4

View File

@ -1,7 +1,7 @@
Index: strace-5.7/unwind.c
Index: strace-5.12/src/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
--- strace-5.12.orig/src/unwind.c 2018-12-10 01:00:00.000000000 +0100
+++ strace-5.12/src/unwind.c 2020-06-02 11:13:42.777871147 +0200
@@ -9,6 +9,12 @@
#include "unwind.h"

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.13
Release: 4%{?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,119 @@ 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
# 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
### Wire up rseq and kexec_file_load in order to avoid kexec_file_load
### test failure on aarch64. Addresses https://bugzilla.redhat.com/1676045
@ -270,6 +292,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 +360,60 @@ 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
#%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
#%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
#%patch1000 -p1
#%patch1001 -p1
@ -388,7 +428,7 @@ 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 2021-10-21 > doc/.strace.1.in.date
%build
@ -408,18 +448,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 +482,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 +500,20 @@ echo 'END OF TEST SUITE INFORMATION'
%{_mandir}/man1/*
%changelog
* 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).