Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
turistu committed May 6, 2024
2 parents 700d2c8 + 2d672be commit 26d54ae
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 39 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ Noteworthy changes in release ?.? (????-??-??)
==============================================

* Improvements
* Implemented --always-show-pid option.
* The --user|-u option has learned to recognize numeric UID:GID pair, allowing
e.g. statically-built strace to be used without invoking nss plugins.
* Updated lists of TCP_* constants.
* Updated decoding of pidfd_send_signal syscall.
* Updated lists of CAN_*, IORING_*, KEY_*, LSM_*, MPOL_*, NT_*, RWF_*,
PIDFD_*, PTP_*, TCP_*, and *_MAGIC constants.
* Updated lists of ioctl commands from Linux 6.9.

Noteworthy changes in release 6.8 (2024-03-20)
Expand Down
5 changes: 5 additions & 0 deletions doc/strace.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,11 @@ Print command names for PIDs.
.if '@ENABLE_SECONTEXT_FALSE@'#' .BR !full,mismatch
.if '@ENABLE_SECONTEXT_FALSE@'#' which prints only the type instead of full context
.if '@ENABLE_SECONTEXT_FALSE@'#' and doesn't check for context mismatches.
.TP
.B \-\-always\-show\-pid
Show PID prefix also for the process started by strace.
Implied when \-f and \-o are both specified.
.RE
.SS Statistics
.TP 12
.B \-c
Expand Down
4 changes: 3 additions & 1 deletion src/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ SYS_FUNC(rt_tgsigqueueinfo)
return RVAL_DECODED;
}

#include "xlat/pidfd_send_signal_flags.h"

SYS_FUNC(pidfd_send_signal)
{
/* int pidfd */
Expand All @@ -740,7 +742,7 @@ SYS_FUNC(pidfd_send_signal)
tprint_arg_next();

/* unsigned int flags */
PRINT_VAL_X((unsigned int) tcp->u_arg[3]);
printflags(pidfd_send_signal_flags, tcp->u_arg[3], "PIDFD_SIGNAL_???");

return RVAL_DECODED;
}
Expand Down
14 changes: 12 additions & 2 deletions src/strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ static int post_attach_sigstop = TCB_IGNORE_ONE_SIGSTOP;
#define use_seize (post_attach_sigstop == 0)

static bool detach_on_execve;
static bool always_show_pid;

static int exit_code;
static int strace_child;
Expand Down Expand Up @@ -469,6 +470,8 @@ Output format:\n\
print PIDs in strace's namespace, too\n\
-Y, --decode-pids=comm\n\
print command names associated with PIDs\n\
--always-show-pid\n\
show PID prefix also for the process started by strace\n\
\n\
Statistics:\n\
-c, --summary-only\n\
Expand Down Expand Up @@ -2362,6 +2365,7 @@ init(int argc, char *argv[])
GETOPT_TIPS,
GETOPT_ARGV0,
GETOPT_STACK_TRACE_FRAME_LIMIT,
GETOPT_ALWAYS_SHOW_PID,

GETOPT_QUAL_TRACE,
GETOPT_QUAL_TRACE_FD,
Expand Down Expand Up @@ -2427,6 +2431,7 @@ init(int argc, char *argv[])
{ "seccomp-bpf", no_argument, 0, GETOPT_SECCOMP },
{ "tips", optional_argument, 0, GETOPT_TIPS },
{ "argv0", required_argument, 0, GETOPT_ARGV0 },
{ "always-show-pid", no_argument, 0, GETOPT_ALWAYS_SHOW_PID },

{ "trace", required_argument, 0, GETOPT_QUAL_TRACE },
{ "trace-fds", required_argument, 0, GETOPT_QUAL_TRACE_FD },
Expand Down Expand Up @@ -2722,6 +2727,9 @@ init(int argc, char *argv[])
case GETOPT_ARGV0:
argv0 = optarg;
break;
case GETOPT_ALWAYS_SHOW_PID:
always_show_pid = true;
break;
case GETOPT_QUAL_SECONTEXT:
qualify_secontext(optarg ? optarg : secontext_qual);
break;
Expand Down Expand Up @@ -3173,9 +3181,11 @@ init(int argc, char *argv[])
* -ff: no (every pid has its own file); or
* -f: yes (there can be more pids in the future); or
* -p PID1,PID2: yes (there are already more than one pid)
* --always-show-pid: yes
*/
print_pid_pfx = outfname && !output_separately &&
(followfork || nprocs > 1);
print_pid_pfx = (outfname && !output_separately &&
(followfork || nprocs > 1)) ||
always_show_pid;
}

static struct tcb *
Expand Down
1 change: 1 addition & 0 deletions src/xlat/evdev_keycode.in
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ BTN_DPAD_RIGHT

KEY_ALS_TOGGLE
KEY_ROTATE_LOCK_TOGGLE
KEY_REFRESH_RATE_TOGGLE

KEY_BUTTONCONFIG
KEY_TASKMANAGER
Expand Down
1 change: 1 addition & 0 deletions src/xlat/fsmagic.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ DMA_BUF_MAGIC 0x444d4142
CRAMFS_MAGIC_WEND 0x453dcd28
DEVMEM_MAGIC 0x454d444d
GPFS_SUPER_MAGIC 0x47504653
PID_FS_MAGIC 0x50494446
PIPEFS_MAGIC 0x50495045
REISERFS_SUPER_MAGIC 0x52654973
SECRETMEM_MAGIC 0x5345434d
Expand Down
2 changes: 2 additions & 0 deletions src/xlat/lsm_ids.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ LSM_ID_SAFESETID
LSM_ID_LOCKDOWN
LSM_ID_BPF
LSM_ID_LANDLOCK
LSM_ID_IMA
LSM_ID_EVM
13 changes: 7 additions & 6 deletions src/xlat/mpol_modes.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#value_indexed
MPOL_DEFAULT 0
MPOL_PREFERRED 1
MPOL_BIND 2
MPOL_INTERLEAVE 3
MPOL_LOCAL 4
MPOL_PREFERRED_MANY 5
MPOL_DEFAULT 0
MPOL_PREFERRED 1
MPOL_BIND 2
MPOL_INTERLEAVE 3
MPOL_LOCAL 4
MPOL_PREFERRED_MANY 5
MPOL_WEIGHTED_INTERLEAVE 6
2 changes: 2 additions & 0 deletions src/xlat/nt_descriptor_types.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ NT_ARM_TAGGED_ADDR_CTRL 0x409
NT_ARM_PAC_ENABLED_KEYS 0x40a
NT_ARM_SSVE 0x40b
NT_ARM_ZA 0x40c
NT_ARM_ZT 0x40d
NT_ARM_FPMR 0x40e
NT_METAG_CBUF 0x500
NT_METAG_RPIPE 0x501
NT_METAG_TLS 0x502
Expand Down
3 changes: 2 additions & 1 deletion src/xlat/pidfd_open_flags.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PIDFD_NONBLOCK O_NONBLOCK
PIDFD_NONBLOCK O_NONBLOCK
PIDFD_THREAD O_EXCL
3 changes: 3 additions & 0 deletions src/xlat/pidfd_send_signal_flags.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PIDFD_SIGNAL_THREAD (1U << 0)
PIDFD_SIGNAL_THREAD_GROUP (1U << 1)
PIDFD_SIGNAL_PROCESS_GROUP (1U << 2)
1 change: 1 addition & 0 deletions src/xlat/ptp_extts_flags.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ PTP_ENABLE_FEATURE
PTP_RISING_EDGE
PTP_FALLING_EDGE
PTP_STRICT_FLAGS
PTP_EXT_OFFSET
1 change: 1 addition & 0 deletions src/xlat/rwf_flags.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ RWF_DSYNC 0x02
RWF_SYNC 0x04
RWF_NOWAIT 0x08
RWF_APPEND 0x10
RWF_NOAPPEND 0x20
2 changes: 2 additions & 0 deletions src/xlat/sock_can_raw_options.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ CAN_RAW_LOOPBACK 3
CAN_RAW_RECV_OWN_MSGS 4
CAN_RAW_FD_FRAMES 5
CAN_RAW_JOIN_FILTERS 6
CAN_RAW_XL_FRAMES 7
CAN_RAW_XL_VCID_OPTS 8
2 changes: 2 additions & 0 deletions src/xlat/uring_ops.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ IORING_OP_WAITID
IORING_OP_FUTEX_WAIT
IORING_OP_FUTEX_WAKE
IORING_OP_FUTEX_WAITV
IORING_OP_FIXED_FD_INSTALL
IORING_OP_FTRUNCATE
5 changes: 5 additions & 0 deletions src/xlat/uring_register_opcodes.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ IORING_REGISTER_RING_FDS
IORING_UNREGISTER_RING_FDS
IORING_REGISTER_PBUF_RING
IORING_UNREGISTER_PBUF_RING
IORING_REGISTER_SYNC_CANCEL
IORING_REGISTER_FILE_ALLOC_RANGE
IORING_REGISTER_PBUF_STATUS
IORING_REGISTER_NAPI
IORING_UNREGISTER_NAPI
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ status-successful-threads
status-unfinished
status-unfinished-threads
statx
strace--always-show-pid
strace--decode-pids-comm
strace--strings-in-hex
strace--strings-in-hex-all
Expand Down
3 changes: 2 additions & 1 deletion tests/gen_tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ lookup_dcookie -a27
lsm_get_self_attr -a49 -s2
lsm_get_self_attr-success --inject=lsm_get_self_attr:retval=96 -a49 -s2 --trace=lsm_get_self_attr
lsm_list_modules -a32
lsm_list_modules-success --inject=lsm_list_modules:retval=15 -a32 --trace=lsm_list_modules
lsm_list_modules-success --inject=lsm_list_modules:retval=17 -a32 --trace=lsm_list_modules
lsm_set_self_attr -a46
lstat -a31 --no-abbrev --trace-path=stat.sample --trace-path=/dev/full
lstat64 -a32 --no-abbrev --trace-path=stat.sample --trace-path=/dev/full
Expand Down Expand Up @@ -1068,6 +1068,7 @@ strace--absolute-timestamps-format-unix-precision-ms +strace-ttt.test 3 --absolu
strace--absolute-timestamps-format-unix-precision-ns +strace-ttt.test 9 --absolute-timestamps=format:unix --absolute-timestamps=precision:ns
strace--absolute-timestamps-format-unix-precision-s +strace-ttt.test 0 --absolute-timestamps=format:unix --absolute-timestamps=precision:s
strace--absolute-timestamps-format-unix-precision-us +strace-ttt.test 6 --absolute-timestamps=precision:us --absolute-timestamps=format:unix
strace--always-show-pid --always-show-pid --trace=fchdir -a15
strace--decode-pids-comm --decode-pids=comm --trace=getppid,tgkill --signal='!SIGCHLD,SIGCONT' -q -f -a 18
strace--follow-forks-output-separately +strace-ff.test --follow-forks --output-separately
strace--relative-timestamps +strace-r.test --relative-timestamps
Expand Down
26 changes: 13 additions & 13 deletions tests/io_uring_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ main(void)


/* Invalid op */
static const unsigned int invalid_ops[] = { 0xbadc0dedU, 24 };
static const unsigned int invalid_ops[] = { 0xbadc0dedU, 29 };

for (size_t i = 0; i < ARRAY_SIZE(invalid_ops); i++) {
sys_io_uring_register(fd_null, invalid_ops[i], path_null,
Expand Down Expand Up @@ -343,12 +343,12 @@ main(void)
probe->ops[0].flags = 0;
probe->ops[0].resv2 = 0xbeefface;

probe->ops[1].op = 53;
probe->ops[1].op = 55;
probe->ops[1].resv = 0;
probe->ops[1].flags = IO_URING_OP_SUPPORTED;
probe->ops[1].resv2 = 0xdeadc0de;

probe->ops[2].op = 54;
probe->ops[2].op = 56;
probe->ops[2].resv = 0xaf;
probe->ops[2].flags = 0xbeef;
probe->ops[2].resv2 = 0;
Expand All @@ -363,32 +363,32 @@ main(void)
", ops_len=%hhu, resv2=[0, %#x, 0], ops=["
"{op=" XLAT_FMT_U ", resv=0xde, flags=0, resv2=0xbeefface}, "
"{op=" XLAT_FMT_U ", flags=" XLAT_FMT ", resv2=0xdeadc0de}, "
"{op=54" NRAW(" /* IORING_OP_??? */") ", resv=0xaf, flags="
"{op=56" NRAW(" /* IORING_OP_??? */") ", resv=0xaf, flags="
XLAT_FMT "}, {op=254" NRAW(" /* IORING_OP_??? */")
", flags=0xc0de" NRAW(" /* IO_URING_OP_??? */") "}]}"
#if RETVAL_INJECTED
" => {last_op=" XLAT_FMT_U ", ops_len=%hhu, resv2=[0, %#x, 0], "
"ops=[{op=" XLAT_FMT_U ", resv=0xde, flags=0, resv2=0xbeefface}"
", {op=" XLAT_FMT_U ", flags=" XLAT_FMT ", resv2=0xdeadc0de}"
", {op=54" NRAW(" /* IORING_OP_??? */") ", resv=0xaf, flags="
", {op=56" NRAW(" /* IORING_OP_??? */") ", resv=0xaf, flags="
XLAT_FMT "}, {op=254" NRAW(" /* IORING_OP_??? */")
", flags=0xc0de" NRAW(" /* IO_URING_OP_??? */") "}, ...]}"
#endif
", 4) = %s\n",
fd_null, path_null, XLAT_ARGS(IORING_REGISTER_PROBE),
XLAT_ARGS(IORING_OP_EPOLL_CTL), probe->ops_len, probe->resv2[1],
XLAT_ARGS(IORING_OP_NOP), XLAT_ARGS(IORING_OP_FUTEX_WAITV),
XLAT_ARGS(IORING_OP_NOP), XLAT_ARGS(IORING_OP_FTRUNCATE),
XLAT_ARGS(IO_URING_OP_SUPPORTED),
XLAT_ARGS(IO_URING_OP_SUPPORTED|0xbeee),
#if RETVAL_INJECTED
XLAT_ARGS(IORING_OP_EPOLL_CTL), probe->ops_len, probe->resv2[1],
XLAT_ARGS(IORING_OP_NOP), XLAT_ARGS(IORING_OP_FUTEX_WAITV),
XLAT_ARGS(IORING_OP_NOP), XLAT_ARGS(IORING_OP_FTRUNCATE),
XLAT_ARGS(IO_URING_OP_SUPPORTED),
XLAT_ARGS(IO_URING_OP_SUPPORTED|0xbeee),
#endif
errstr);

probe->last_op = 54;
probe->last_op = 56;
probe->resv2[1] = 0;
fill_memory_ex(probe->ops, sizeof(probe->ops[0]) * (DEFAULT_STRLEN + 1),
0x40, 0x80);
Expand All @@ -397,7 +397,7 @@ main(void)
printf("io_uring_register(%u<%s>, " XLAT_FMT,
fd_null, path_null, XLAT_ARGS(IORING_REGISTER_PROBE));
for (size_t c = 0; c < 1 + RETVAL_INJECTED; c++) {
printf("%s{last_op=54" NRAW(" /* IORING_OP_??? */")
printf("%s{last_op=56" NRAW(" /* IORING_OP_??? */")
", ops_len=%hhu, ops=[",
c ? " => " : ", ", probe->ops_len);
for (size_t i = 0; i < DEFAULT_STRLEN; i++) {
Expand Down Expand Up @@ -459,18 +459,18 @@ main(void)
{ ARG_STR(IORING_RESTRICTION_REGISTER_OP), true,
"register_op=", ARG_STR(IORING_REGISTER_BUFFERS), true },
{ ARG_STR(IORING_RESTRICTION_REGISTER_OP), true,
"register_op=", ARG_STR(IORING_UNREGISTER_PBUF_RING),
"register_op=", ARG_STR(IORING_UNREGISTER_NAPI),
true },
{ ARG_STR(IORING_RESTRICTION_REGISTER_OP), true,
"register_op=", 24, " /* IORING_REGISTER_??? */", false },
"register_op=", 29, " /* IORING_REGISTER_??? */", false },
{ ARG_STR(IORING_RESTRICTION_REGISTER_OP), true,
"register_op=", 255, " /* IORING_REGISTER_??? */", false },
{ ARG_STR(IORING_RESTRICTION_SQE_OP), true,
"sqe_op=", ARG_STR(IORING_OP_NOP), true },
{ ARG_STR(IORING_RESTRICTION_SQE_OP), true,
"sqe_op=", ARG_STR(IORING_OP_FUTEX_WAITV), true },
"sqe_op=", ARG_STR(IORING_OP_FTRUNCATE), true },
{ ARG_STR(IORING_RESTRICTION_SQE_OP), true,
"sqe_op=", 54, " /* IORING_OP_??? */", false },
"sqe_op=", 56, " /* IORING_OP_??? */", false },
{ ARG_STR(IORING_RESTRICTION_SQE_OP), true,
"sqe_op=", 255, " /* IORING_OP_??? */", false },
{ ARG_STR(IORING_RESTRICTION_SQE_FLAGS_ALLOWED), true,
Expand Down
5 changes: 3 additions & 2 deletions tests/ioctl_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ test_no_device(void)
static const struct strval32 extts_flags[] = {
{ ARG_XLAT_KNOWN(0x1, "PTP_ENABLE_FEATURE") },
{ ARG_XLAT_KNOWN(0xdeadbabe, "PTP_RISING_EDGE|PTP_FALLING_EDGE"
"|PTP_STRICT_FLAGS|0xdeadbab0") },
{ ARG_XLAT_UNKNOWN(0xbadbeef0, "PTP_???") },
"|PTP_STRICT_FLAGS|PTP_EXT_OFFSET"
"|0xdeadbaa0") },
{ ARG_XLAT_UNKNOWN(0xbadbeee0, "PTP_???") },
{ ARG_STR(0) },
};
for (const struct strval32 *c = ioc_extts; c < ARRAY_END(ioc_extts);
Expand Down
4 changes: 3 additions & 1 deletion tests/lsm_list_modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ main(void)
{ ARG_STR(LSM_ID_APPARMOR) },
{ ARG_STR(LSM_ID_BPF) },
{ ARG_STR(LSM_ID_CAPABILITY) },
{ ARG_STR(LSM_ID_EVM) },
{ ARG_STR(LSM_ID_IMA) },
{ ARG_STR(LSM_ID_LANDLOCK) },
{ ARG_STR(LSM_ID_LOADPIN) },
{ ARG_STR(LSM_ID_LOCKDOWN) },
Expand All @@ -58,7 +60,7 @@ main(void)
{ ARG_STR(LSM_ID_YAMA) },
{ 1, "0x1 /* LSM_ID_??? */" },
{ 99, "0x63 /* LSM_ID_??? */" },
{ 111, "0x6f /* LSM_ID_??? */" }
{ 113, "0x71 /* LSM_ID_??? */" }
};
TAIL_ALLOC_OBJECT_CONST_ARR(uint64_t, ids, ARRAY_SIZE(test_ids));
for (unsigned int i = 0; i < ARRAY_SIZE(test_ids); ++i)
Expand Down
9 changes: 6 additions & 3 deletions tests/mbind.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ static struct {
{ ARG_STR(0x5),
"0x5 /* MPOL_PREFERRED_MANY */",
"MPOL_PREFERRED_MANY" },
{ ARG_STR(0x6),
"0x6 /* MPOL_WEIGHTED_INTERLEAVE */",
"MPOL_WEIGHTED_INTERLEAVE" },
{ ARG_STR(0x8000),
"0x8000 /* MPOL_DEFAULT|MPOL_F_STATIC_NODES */",
"MPOL_DEFAULT|MPOL_F_STATIC_NODES" },
Expand All @@ -85,9 +88,9 @@ static struct {
"|MPOL_F_NUMA_BALANCING */",
"MPOL_INTERLEAVE|MPOL_F_STATIC_NODES|MPOL_F_RELATIVE_NODES"
"|MPOL_F_NUMA_BALANCING" },
{ ARG_STR(0x6),
"0x6 /* MPOL_??? */",
"0x6 /* MPOL_??? */" },
{ ARG_STR(0x7),
"0x7 /* MPOL_??? */",
"0x7 /* MPOL_??? */" },
{ ARG_STR(0xffff1fff),
"0xffff1fff /* MPOL_??? */",
"0xffff1fff /* MPOL_??? */" },
Expand Down
18 changes: 15 additions & 3 deletions tests/pidfd_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,26 @@ main(void)
printf("pidfd_open(-1, PIDFD_NONBLOCK) = %s\n", errstr);
#endif

k_pidfd_open(0, O_EXCL);
#ifndef PATH_TRACING
pidns_print_leader();
printf("pidfd_open(0, PIDFD_THREAD) = %s\n", errstr);
#endif

k_pidfd_open(-1U, O_EXCL);
#ifndef PATH_TRACING
pidns_print_leader();
printf("pidfd_open(-1, PIDFD_THREAD) = %s\n", errstr);
#endif

k_pidfd_open(0, -1U);
#ifndef PATH_TRACING
pidns_print_leader();
printf("pidfd_open(0, PIDFD_NONBLOCK|%#x) = %s\n",
-1U & (~O_NONBLOCK), errstr);
printf("pidfd_open(0, PIDFD_NONBLOCK|PIDFD_THREAD|%#x) = %s\n",
-1U & (~(O_NONBLOCK | O_EXCL)), errstr);
#endif

const unsigned int flags = 0xfacefeed & (~O_NONBLOCK);
const unsigned int flags = 0xfacefeed & (~(O_NONBLOCK | O_EXCL));
const int pid = getpid();

k_pidfd_open(pid, flags);
Expand Down
Loading

0 comments on commit 26d54ae

Please sign in to comment.